예제 #1
0
 def test_PutMultipleCol(self):
     #Checks to make sure multiple valid columns can be added to a dataframe
     with Network() as n:
         forex = pd.read_csv("forex.csv")
         forex2 = forex.copy()
         del forex2['Zero']
         del forex2['AskPrice2']
         del forex2['BidPrice2']
         sourceDict = {'forex': forex, 'forex2': forex2}
         df = seriesSource('forex')
         newDf = seriesSource('forex2')
         columnDictTest = {
             'DateTime': forex['DateTime'],
             'AskPrice1': forex['AskPrice1'],
             'BidPrice1': forex['BidPrice1'],
             'AskPrice2': forex['AskPrice2'],
             'BidPrice2': forex['BidPrice2'],
             'Zero': forex['Zero']
         }
         columnDict = ['AskPrice2', 'BidPrice2', 'Zero']
         putColumns(df, columnDict, newDf, name='test')
         toComp = pd.DataFrame(columns=list(forex2))
         for key in columnDictTest.keys():
             toComp[key] = columnDictTest[key]
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_frame_equal(toComp, toComp2))
         n.report()
예제 #2
0
 def testLog(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         log(seriesSource('fake'))
         sinkDict = piEval(n, sourceDict)
         n.report()
         self.assertTrue(y == np.log(x) for x, y in zip(sourceDict['fake'], sinkDict['__0__']))
예제 #3
0
 def testCeiling2(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries3()}  # here series are loaded
         ceiling(seriesSource('fake'))
         sinkDict = piEval(n, sourceDict)
         n.report()
         self.assertTrue(y == ceil(x) for x, y in zip(sourceDict['fake'].values, sinkDict['__0__'].values))
예제 #4
0
 def test_greaterOrEqual_2(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         greaterOrEqual(seriesSource('fake'), seriesSource('fake'))
         sinkDict = piEval(n, sourceDict)
         for x in sinkDict['__0__']:
             self.assertTrue(x)
     print("End of GE Test 2")
예제 #5
0
 def test_notEqual_1(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         notEqual(seriesSource('fake'), seriesSource('fake'))
         sinkDict = piEval(n, sourceDict)
         for x in sinkDict['__0__']:
             self.assertFalse(x)
     print("End of NE Test 1")
예제 #6
0
 def testABS(self):
     with Network() as n:
          sourceDict = {'fake': randomWalkSeries2()}  # here series are loaded
          abs(seriesSource('fake'))
          sinkDict = piEval(n, sourceDict)
          n.report()
          for x in sinkDict['__0__']:
              print(x)
              self.assertGreaterEqual(x, 0)
예제 #7
0
 def test_TimeWeightMeanTINY_6Min(self):
     with Network() as n:
         forex = pd.read_csv('forex-tiny-ez.csv')
         sourceDict = {'forex': forex}
         df = seriesSource('forex')
         timeW = 360
         timeWeightMean(df, timewindow=timeW, name="test")
         sinkDict = piEval(n, sourceDict)
         n.report()
예제 #8
0
 def test_TimeWeightSTDINT(self):
     with Network() as n:
         forex = pd.read_csv('forex.csv')
         sourceDict = {'forex': forex}
         df = seriesSource('forex')
         timeW = 2
         timeWeightSTD(df, timewindow=timeW, name="test")
         sinkDict = piEval(n, sourceDict)
         n.report()
예제 #9
0
 def test_TimeWeightMeanDateTimeMinutes(self):
     with Network() as n:
         forex = pd.read_csv('forex.csv')
         sourceDict = {'forex': forex}
         df = seriesSource('forex')
         timeW = timedelta(minutes=5)
         timeWeightMean(df, timewindow=timeW, name="test")
         sinkDict = piEval(n, sourceDict)
         n.report()
예제 #10
0
 def test_STDEV_Series(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         df = seriesSource('fake')
         stdev(df, name="test")
         toComp = sourceDict['fake'].std()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertEqual(toComp, toComp2)
         n.report()
예제 #11
0
 def test_lessorEqual_5(self):
     with Network() as n:
         sourceDict = {
             'fake': randomWalkSeries3()
         }  # here series are loaded
         lessOrEqual(seriesSource('fake'), seriesSource('fake'))
         sinkDict = piEval(n, sourceDict)
         for x in sinkDict['__0__'].values:
             self.assertTrue(x)
     print("End of LE Test 2")
예제 #12
0
 def test_SMASeries(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}
         df = seriesSource('fake')
         sma(df, window=10, name="test")
         toComp = sourceDict['fake'].rolling(window=10).mean()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_series_equal(toComp, toComp2))
         n.report()
예제 #13
0
 def test_SUMSeries(self):
     #Basic sumtest for Series object
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         df = seriesSource('fake')
         sum(df, name="test")
         toComp = sourceDict['fake'].sum()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertEqual(toComp, toComp2)
         n.report()
예제 #14
0
 def test_STDEV_WindowString(self):
     with Network() as n:
         forex = pd.read_csv("forex.csv")
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         stdev(df, window="AskPrice1", name="test")
         toComp = sourceDict['forex'].loc[:, "AskPrice1"].std()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertEqual(toComp, toComp2)
         n.report()
예제 #15
0
 def test_STDEV_Window1(self):
     with Network() as n:
         forex = pd.read_csv("forex.csv")
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         stdev(df, window=1, name="test")
         toComp = sourceDict['forex'].std(axis=1)
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_series_equal(toComp, toComp2))
         n.report()
예제 #16
0
 def test_EMADataframe(self):
     with Network() as n:
         forex = pd.read_csv("forex.csv")
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         ema(df, span=10, name="test")
         toComp = sourceDict['forex'].ewm(span=10).mean()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_frame_equal(toComp, toComp2))
         n.report()
예제 #17
0
 def test_Equal_2(self):
     with Network() as n:
         sourceDict = {
             'fake': randomWalkSeries3()
         }  # here series are loaded
         equal(seriesSource('fake'), seriesSource('fake'))
         sinkDict = piEval(n, sourceDict)
         for x in sinkDict['__0__'].values:
             print(x)
             self.assertTrue(x)
     print("End of Equal Test")
예제 #18
0
 def test_lessThan(self):
     with Network() as n:
         sourceDict = {
             'fake': randomWalkSeries(),
             'fake2': randomWalkSeries2()
         }  # here series are loaded
         lessThan(seriesSource('fake2'), seriesSource('fake'))
         sinkDict = piEval(n, sourceDict)
         for x in sinkDict['__0__']:
             self.assertTrue(x)
     print("End of LT Test")
예제 #19
0
 def test_lessorEqual_3(self):
     with Network() as n:
         sourceDict = {
             'fake': randomWalkSeries(),
             'fake2': randomWalkSeries2()
         }  # here series are loaded
         lessOrEqual(seriesSource('fake'), seriesSource('fake2'))
         sinkDict = piEval(n, sourceDict)
         for x in sinkDict['__0__']:
             self.assertFalse(x)
     print("End of LE Test 3")
 def test_SMA_Strategy_MINI(self):
     with Network() as n:
         forex = pd.read_csv("forex-mini.csv")
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         simple_2SMA_Strategy(df,
                              shortWindow=10,
                              longWindow=200,
                              name="test")
         sinkDict = piEval(n, sourceDict)
         n.report()
예제 #21
0
 def test_LessThanOrEqual_Equal_Series(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         a = seriesSource('fake')
         b = seriesSource('fake')
         lessOrEqual(a, b, name='test')
         toComp = pd.Series.le(sourceDict['fake'], sourceDict['fake'])
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_series_equal(toComp, toComp2))
         n.report()
 def testMinRolling(self):
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         df = seriesSource('fake')
         min(df, name="test", window=5)
         toComp = sourceDict['fake']
         toCompSeries = pd.Series(toComp).rolling(window=5).min()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertTrue(
             x == y for x, y in zip(toCompSeries.values, toComp2.values))
         n.report()
예제 #23
0
 def test_SIMPLE2SMA_TINY_EZ(self):
     with Network() as n:
         forex = pd.read_csv("forex-tiny-ez.csv")
         sourceDict = {'forex': forex}
         df = seriesSource('forex')
         simple_2SMA_Strategy(df,
                              shortWindow=1,
                              longWindow=2,
                              quantity=1,
                              name='2SMA')
         sinkDict = piEval(n, sourceDict)
         n.report()
예제 #24
0
 def test_SUMDataframe(self):
     #Basis sumtest for Dataframe object
     with Network() as n:
         forex = pd.read_csv('forex.csv')
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         sum(df, name="test")
         toComp = sourceDict['forex'].sum()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertEqual(toComp.all(), toComp2.all())
         n.report()
예제 #25
0
 def test_DELAYSeries(self):
     #Basic delay test for Series
     with Network() as n:
         sourceDict = {'fake': randomWalkSeries()}  # here series are loaded
         df = seriesSource('fake')
         sample = 3
         delay(df, sample, name='test')
         toComp = sourceDict['fake'].shift(periods=sample)
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_series_equal(toComp, toComp2))
         n.report()
예제 #26
0
 def test_SMADataframe(self):
     with Network() as n:
         forex = pd.read_csv("forex.csv")
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         sma(df, window=5, name="test")
         toComp = sourceDict['forex'].rolling(window=5,
                                              closed="right").mean()
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_frame_equal(toComp, toComp2))
         n.report()
예제 #27
0
 def test_LessThanOrEqual_Equal_DataFrame(self):
     with Network() as n:
         forex = pd.read_csv('forex.csv')
         sourceDict = {'forex': forex}  # here series are loaded
         a = seriesSource('forex')
         b = seriesSource('forex')
         lessOrEqual(a, b, name='test')
         toComp = pd.Series.le(sourceDict['forex'], sourceDict['forex'])
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_frame_equal(toComp, toComp2))
         n.report()
예제 #28
0
 def test_LessThanOrEqual_error(self):
     with Network() as n:
         sourceDict = {
             'fake': randomWalkSeries(),
             "fake2": randomWalkDataframe()
         }  # here series are loaded
         a = seriesSource('fake')
         b = seriesSource('fake2')
         lessOrEqual(a, b, name='test')
         sinkDict = piEval(n, sourceDict)
         self.assertRaises(Exception, piEval, n, sourceDict)
         n.report()
예제 #29
0
 def test_DELAYDataframe(self):
     #Basic delay test for Dataframe
     with Network() as n:
         forex = pd.read_csv("forex.csv")
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         sample = 3
         delay(df, sample, name='test')
         toComp = sourceDict['forex'].shift(periods=sample)
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_frame_equal(toComp, toComp2))
         n.report()
예제 #30
0
 def test_GetColString(self):
     #Checks to make sure inputting a single string returns the correct column as a pd.series object
     with Network() as n:
         forex = pd.read_csv("forex.csv")
         sourceDict = {'forex': forex}  # here series are loaded
         df = seriesSource('forex')
         columnNames = "DateTime"
         getColumns(df, columnNames, name='test')
         toComp = sourceDict['forex'].get(columnNames)
         sinkDict = piEval(n, sourceDict)
         toComp2 = sinkDict['test']
         self.assertIsNone(pd.testing.assert_series_equal(toComp, toComp2))
         n.report()