本文整理汇总了Python中zipline.finance.blotter.Blotter.process_split方法的典型用法代码示例。如果您正苦于以下问题:Python Blotter.process_split方法的具体用法?Python Blotter.process_split怎么用?Python Blotter.process_split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipline.finance.blotter.Blotter
的用法示例。
在下文中一共展示了Blotter.process_split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_blotter_processes_splits
# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import process_split [as 别名]
def test_blotter_processes_splits(self):
sim_params = factory.create_simulation_parameters()
blotter = Blotter()
blotter.set_date(sim_params.period_start)
# set up two open limit orders with very low limit prices,
# one for sid 1 and one for sid 2
blotter.order(1, 100, LimitOrder(10))
blotter.order(2, 100, LimitOrder(10))
# send in a split for sid 2
split_event = factory.create_split(2, 0.33333,
sim_params.period_start +
timedelta(days=1))
blotter.process_split(split_event)
for sid in [1, 2]:
order_lists = blotter.open_orders[sid]
self.assertIsNotNone(order_lists)
self.assertEqual(1, len(order_lists))
aapl_order = blotter.open_orders[1][0].to_dict()
fls_order = blotter.open_orders[2][0].to_dict()
# make sure the aapl order didn't change
self.assertEqual(100, aapl_order['amount'])
self.assertEqual(10, aapl_order['limit'])
self.assertEqual(1, aapl_order['sid'])
# make sure the fls order did change
# to 300 shares at 3.33
self.assertEqual(300, fls_order['amount'])
self.assertEqual(3.33, fls_order['limit'])
self.assertEqual(2, fls_order['sid'])