コード例 #1
0
    def test_market_record4(self):
        OMS = OrderManagementSystem(10.0, 9.99, 0.01, 5, 9.7)
        OMS.record("strategy")
        OMS.receive(["strategy", "limit", "sell", 1200, 9.99])
        a = OMS.strategy_record.active_order == {9.99: [200, 'sell']}
        b = OMS.strategy_record.position == -1000
        c = OMS.strategy_record.filled_order == [['sell', 9.99, 1000]]

        assert a
        assert b
        assert c
コード例 #2
0
 def test_market_record3(self):
     OMS = OrderManagementSystem(10.0, 9.99, 0.01, 5, 9.7)
     OMS.record("strategy")
     OMS.receive(["strategy", "limit", "buy", 1200, 10.0])
     a = OMS.strategy_record.active_order == {10.0: [200, 'buy']}
     b = OMS.strategy_record.position == 1000
     c = OMS.strategy_record.filled_order == [['buy', 10.0, 1000]]
     OMS.receive(["ZIagent", "market", "sell", 200, 9.7])
     d = OMS.strategy_record.active_order == {}
     e = OMS.strategy_record.position == 1200
     f = OMS.strategy_record.filled_order == [['buy', 10.0, 1000],
                                              ['buy', 10.0, 200]]
     assert a
     assert b
     assert c
     assert d
     assert e
     assert f
コード例 #3
0
 def test_limit_record(self):
     OMS = OrderManagementSystem(10.0, 9.98, 0.01, 5, 9.7)
     OMS.record("strategy")
     OMS.receive(["strategy", "limit", "sell", 2300, 9.7])
     a = OMS.strategy_record.filled_order == [['sell', 9.98, 1000],
                                              ['sell', 9.97, 1000],
                                              ['sell', 9.96, 300]]
     d = OMS.strategy_record.position == -2300
     OMS.receive(["strategy", "limit", "sell", 2300, 10.7])
     b = OMS.strategy_record.active_order[10.7] == [2300, 'sell']
     OMS.receive(["strategy", "cancel", "sell", 2300, 10.7])
     c = OMS.strategy_record.active_order == {}
     e = OMS.strategy_record.position == -2300
     assert a
     assert b
     assert c
     assert d
     assert e
コード例 #4
0
 def test_market_record(self):
     OMS = OrderManagementSystem(10.0, 9.98, 0.01, 5, 9.7)
     OMS.record("strategy")
     OMS.receive(["strategy", "market", "buy", 2300, 9.7])
     OMS.receive(["ZIagent", "market", "buy", 2300, 9.7])
     a = OMS.strategy_record.filled_order == [['buy', 10.00, 1000],
                                              ['buy', 10.01, 1000],
                                              ['buy', 10.02, 300]]
     d = OMS.strategy_record.position == 2300
     OMS.receive(["strategy", "market", "sell", 1300, 10.7])
     OMS.receive(["ZIagent", "limit", "buy", 2300, 9.7])
     OMS.receive(["ZIagent", "cancel", "buy", 2300, 9.97])
     b = OMS.strategy_record.active_order == {}
     c = OMS.strategy_record.filled_order == [['buy', 10.00, 1000],
                                              ['buy', 10.01, 1000],
                                              ['buy', 10.02, 300],
                                              ['sell', 9.98, 1000],
                                              ['sell', 9.97, 300]]
     e = OMS.strategy_record.position == 1000
     assert a
     assert b
     assert c
     assert d
     assert e