本文整理汇总了Python中pyalgotrade.dataseries.aligned.datetime_aligned函数的典型用法代码示例。如果您正苦于以下问题:Python datetime_aligned函数的具体用法?Python datetime_aligned怎么用?Python datetime_aligned使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了datetime_aligned函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: multipleDatetimeAligned
def multipleDatetimeAligned(self, feed):
# in case of multiple dataseries, add multiple datatime aligned function
ds = dict()
ds[self.__instrumentList[0]] = feed[self.__instrumentList[0]].getAdjCloseDataSeries()
for i in range(1,len(self.__instrumentList)) :
ds[self.__instrumentList[0]], ds[self.__instrumentList[i]] = \
aligned.datetime_aligned(ds[self.__instrumentList[0]], feed[self.__instrumentList[i]].getAdjCloseDataSeries())
for i in range(1,len(self.__instrumentList)) :
ds[self.__instrumentList[0]], ds[self.__instrumentList[i]] = \
aligned.datetime_aligned(ds[self.__instrumentList[0]], ds[self.__instrumentList[i]])
return ds
开发者ID:vdaytona,项目名称:Quant-Ver1,代码行数:11,代码来源:mean_reversion_v1.py
示例2: testIncremental_Recursive
def testIncremental_Recursive(self):
size = 20
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
# Align the aligned dataseries again with respect to each other.
ads1, ads2 = aligned.datetime_aligned(ads1, ads2)
now = datetime.datetime.now()
for i in range(size):
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(len(ads1), len(ads2))
self.assertEqual(ads1[:], ads2[:])
self.assertEqual(ads1.getDateTimes()[:], ads2.getDateTimes()[:])
开发者ID:akkineniramesh,项目名称:pyalgotrade,代码行数:15,代码来源:dataseries_test.py
示例3: __init__
def __init__(self, ds1, ds2, windowSize):
# We're going to use datetime aligned versions of the dataseries.
self.__ds1, self.__ds2 = aligned.datetime_aligned(ds1, ds2)
self.__windowSize = windowSize
self.__hedgeRatio = None
self.__spread = None
self.__spreadMean = None
self.__spreadStd = None
self.__zScore = None
开发者ID:arippbbc,项目名称:pyalgotrade,代码行数:9,代码来源:statarb_erniechan.py
示例4: testFullyAligned_Recursive
def testFullyAligned_Recursive(self):
size = 20
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
# Align the aligned dataseries again with respect to each other.
ads1, ads2 = aligned.datetime_aligned(ads1, ads2)
now = datetime.datetime.now()
for i in range(size):
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(len(ds1), len(ds2))
for ads in [ads1, ads2]:
self.assertEqual(len(ads), size)
for i in range(size):
self.assertEqual(ads.getValueAbsolute(i), i)
self.assertEqual(ads.getDateTimes()[i], now + datetime.timedelta(seconds=i))
开发者ID:akkineniramesh,项目名称:pyalgotrade,代码行数:20,代码来源:dataseries_test.py
示例5: testNotAligned_Recursive
def testNotAligned_Recursive(self):
size = 20
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
# Align the aligned dataseries again with respect to each other.
ads1, ads2 = aligned.datetime_aligned(ads1, ads2)
now = datetime.datetime.now()
for i in range(size):
if i % 2 == 0:
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
else:
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(len(ds1), len(ds2))
for ads in [ads1, ads2]:
self.assertEqual(ads.getLength(), 0)
self.assertEqual(ads.getFirstValidPos(), 0)
self.assertEqual(ads.getValueAbsolute(0), None)
self.assertEqual(ads.getDateTimes(), [])
开发者ID:Barcelons281,项目名称:pyalgotrade,代码行数:22,代码来源:dataseries_test.py
示例6: testIncremental
def testIncremental(self):
size = 20
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
now = datetime.datetime.now()
for i in range(size):
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(ads1.getLength(), ads2.getLength())
self.assertEqual(ads1[:], ads2[:])
self.assertEqual(ads1.getDateTimes()[:], ads2.getDateTimes()[:])
开发者ID:Barcelons281,项目名称:pyalgotrade,代码行数:13,代码来源:dataseries_test.py
示例7: testBoundedSources
def testBoundedSources(self):
ds1 = dataseries.SequenceDataSeries(1)
ds2 = dataseries.SequenceDataSeries(1)
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
now = datetime.datetime.now()
ds1.appendWithDateTime(now + datetime.timedelta(seconds=1), 1)
ds1.appendWithDateTime(now + datetime.timedelta(seconds=2), 2)
ds1.appendWithDateTime(now + datetime.timedelta(seconds=3), 3)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=2), 2)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=3), 3)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=4), 4)
self.assertEqual(ads1[:], [2, 3])
self.assertEqual(ads2[:], [2, 3])
开发者ID:akkineniramesh,项目名称:pyalgotrade,代码行数:14,代码来源:dataseries_test.py
示例8: testBounded
def testBounded(self):
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2, 1)
now = datetime.datetime.now()
ds1.appendWithDateTime(now + datetime.timedelta(seconds=1), 1)
ds1.appendWithDateTime(now + datetime.timedelta(seconds=2), 2)
ds1.appendWithDateTime(now + datetime.timedelta(seconds=3), 3)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=2), 2)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=3), 3)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=4), 4)
self.assertEqual(ads1.getValues(), [3])
self.assertEqual(ads2.getValues(), [3])
开发者ID:Barcelons281,项目名称:pyalgotrade,代码行数:14,代码来源:dataseries_test.py
示例9: testPartiallyAligned_Recursive
def testPartiallyAligned_Recursive(self):
size = 20
commonDateTimes = []
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
# Align the aligned dataseries again with respect to each other.
ads1, ads2 = aligned.datetime_aligned(ads1, ads2)
now = datetime.datetime.now()
for i in range(size):
if i % 3 == 0:
commonDateTimes.append(now + datetime.timedelta(seconds=i))
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
elif i % 2 == 0:
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
else:
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(len(ads1), len(ads2))
self.assertEqual(ads1[:], ads2[:])
self.assertEqual(ads1.getDateTimes(), commonDateTimes)
self.assertEqual(ads2.getDateTimes(), commonDateTimes)
开发者ID:akkineniramesh,项目名称:pyalgotrade,代码行数:24,代码来源:dataseries_test.py
示例10: testNotAligned
def testNotAligned(self):
size = 20
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
now = datetime.datetime.now()
for i in range(size):
if i % 2 == 0:
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
else:
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(len(ds1), len(ds2))
for ads in [ads1, ads2]:
self.assertEqual(len(ads), 0)
self.assertEqual(ads.getValueAbsolute(0), None)
self.assertEqual(ads.getDateTimes(), [])
开发者ID:akkineniramesh,项目名称:pyalgotrade,代码行数:19,代码来源:dataseries_test.py
示例11: testFullyAligned
def testFullyAligned(self):
size = 20
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
now = datetime.datetime.now()
for i in range(size):
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(len(ds1), len(ds2))
for ads in [ads1, ads2]:
self.assertEqual(ads.getLength(), size)
self.assertEqual(ads.getFirstValidPos(), 0)
for i in range(size):
self.assertEqual(ads.getValueAbsolute(i), i)
self.assertEqual(ads.getDateTimes()[i], now + datetime.timedelta(seconds=i))
开发者ID:Barcelons281,项目名称:pyalgotrade,代码行数:19,代码来源:dataseries_test.py
示例12: testPartiallyAligned
def testPartiallyAligned(self):
size = 20
commonDateTimes = []
ds1 = dataseries.SequenceDataSeries()
ds2 = dataseries.SequenceDataSeries()
ads1, ads2 = aligned.datetime_aligned(ds1, ds2)
now = datetime.datetime.now()
for i in range(size):
if i % 3 == 0:
commonDateTimes.append(now + datetime.timedelta(seconds=i))
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
elif i % 2 == 0:
ds1.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
else:
ds2.appendWithDateTime(now + datetime.timedelta(seconds=i), i)
self.assertEqual(ads1.getLength(), ads2.getLength())
self.assertEqual(ads1[:], ads2[:])
self.assertEqual(ads1.getDateTimes(), commonDateTimes)
self.assertEqual(ads2.getDateTimes(), commonDateTimes)
开发者ID:Barcelons281,项目名称:pyalgotrade,代码行数:22,代码来源:dataseries_test.py
注:本文中的pyalgotrade.dataseries.aligned.datetime_aligned函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论