-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0390cea
commit 1868180
Showing
5 changed files
with
56 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
PairsTrading/DistanceApproach/DistanceApproachExample-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
PairsTrading/DistanceApproach/TestBasicDistanceApproach.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from datetime import datetime | ||
from turtle import distance | ||
from BasicDistanceApproach import BasicDistanceApproach | ||
import unittest | ||
import pandas as pd | ||
|
||
class TestDistanceApproach(unittest.TestCase): | ||
|
||
''' | ||
- Tests that the correct exceptions are raised when trying to pass flawed data to setPairsData or setTradeData | ||
- Tests that a well formed dataframe is excepted by setPairsData and setTradeData | ||
''' | ||
def testSetData(self): | ||
distanceClass = BasicDistanceApproach() | ||
#Checks that an error exception is returned from a distance class with the appropriate messsage | ||
def assertExceptionMessage(message: str, data): | ||
with self.assertRaises(Exception) as cm: | ||
distanceClass.setPairsData(data) | ||
self.assertEqual(cm.exception.args[0],message) | ||
with self.assertRaises(Exception) as cm: | ||
distanceClass.setTradeData(data) | ||
self.assertEqual(cm.exception.args[0],message) | ||
|
||
exampleDate = pd.to_datetime(datetime(2020,4,5)) | ||
dfNotEnoughColumns = pd.DataFrame({'Dates' : ['date']}) | ||
dfFirstNotDateTime = pd.DataFrame({'Price' : [1], 'Date' : [exampleDate]}) | ||
dfNoneNumericalColumn = pd.DataFrame({'Date' : [exampleDate], 'Price1' : [1], 'Price2' : ['dog']}) | ||
wellFormedDF = pd.DataFrame({'Date': [exampleDate], 'Price1' : [1], 'Price2' : [2.4494]}) | ||
|
||
assertExceptionMessage(distanceClass.NotEnoughColumnsException,dfNotEnoughColumns) | ||
assertExceptionMessage(distanceClass.dateTimeException,dfFirstNotDateTime) | ||
assertExceptionMessage(distanceClass.nonNumericalException, dfNoneNumericalColumn) | ||
self.assertEqual(distanceClass.setPairsData(wellFormedDF),True) | ||
self.assertEqual(distanceClass.setTradeData(wellFormedDF),True) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file was deleted.
Oops, something went wrong.