当前位置: 首页>>代码示例>>Python>>正文


Python Blotter.process_splits方法代码示例

本文整理汇总了Python中zipline.finance.blotter.Blotter.process_splits方法的典型用法代码示例。如果您正苦于以下问题:Python Blotter.process_splits方法的具体用法?Python Blotter.process_splits怎么用?Python Blotter.process_splits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zipline.finance.blotter.Blotter的用法示例。


在下文中一共展示了Blotter.process_splits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_blotter_processes_splits

# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import process_splits [as 别名]
    def test_blotter_processes_splits(self):
        blotter = Blotter("daily", self.env.asset_finder, slippage_func=FixedSlippage())

        # set up two open limit orders with very low limit prices,
        # one for sid 1 and one for sid 2
        blotter.order(blotter.asset_finder.retrieve_asset(1), 100, LimitOrder(10))
        blotter.order(blotter.asset_finder.retrieve_asset(2), 100, LimitOrder(10))

        # send in a split for sid 2
        blotter.process_splits([(2, 0.3333)])

        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"])
开发者ID:jasonwirth,项目名称:zipline,代码行数:31,代码来源:test_finance.py

示例2: test_blotter_processes_splits

# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import process_splits [as 别名]
    def test_blotter_processes_splits(self):
        blotter = Blotter('daily',  equity_slippage=FixedSlippage())

        # set up two open limit orders with very low limit prices,
        # one for sid 1 and one for sid 2
        asset1 = self.asset_finder.retrieve_asset(1)
        asset2 = self.asset_finder.retrieve_asset(2)
        asset133 = self.asset_finder.retrieve_asset(133)

        blotter.order(asset1, 100, LimitOrder(10))
        blotter.order(asset2, 100, LimitOrder(10))

        # send in splits for assets 133 and 2.  We have no open orders for
        # asset 133 so it should be ignored.
        blotter.process_splits([(asset133, 0.5), (asset2, 0.3333)])

        for asset in [asset1, asset2]:
            order_lists = blotter.open_orders[asset]
            self.assertIsNotNone(order_lists)
            self.assertEqual(1, len(order_lists))

        asset1_order = blotter.open_orders[1][0]
        asset2_order = blotter.open_orders[2][0]

        # make sure the asset1 order didn't change
        self.assertEqual(100, asset1_order.amount)
        self.assertEqual(10, asset1_order.limit)
        self.assertEqual(1, asset1_order.asset)

        # make sure the asset2 order did change
        # to 300 shares at 3.33
        self.assertEqual(300, asset2_order.amount)
        self.assertEqual(3.33, asset2_order.limit)
        self.assertEqual(2, asset2_order.asset)
开发者ID:zhou,项目名称:zipline,代码行数:36,代码来源:test_finance.py


注:本文中的zipline.finance.blotter.Blotter.process_splits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。