def test_integration( mocker, touch_order: TouchOrderExecutor, topic: str, quote: typing.Dict, touch_count: int, ask_volume: int, bid_volume: int, ): touch_order.infos = { "2890": StatusInfo( close=11, buy_price=11, sell_price=11, high=11, low=11, change_price=1, change_rate=1.0, volume=1, total_volume=10, ask_volume=7, bid_volume=0, ) } touch_order.touch = mocker.MagicMock() touch_order.integration(topic, quote) assert touch_order.touch.call_count == touch_count assert touch_order.infos["2890"].ask_volume == ask_volume assert touch_order.infos["2890"].bid_volume == bid_volume
def test_touch_storecond( mocker, contract: Future, order: Order, touch_order: TouchOrderExecutor, code: str, price: PriceGap, close_price: float, order_count: int, ): touch_order.conditions = { "TXFD0": [ StoreCond( close=price, order_contract=contract["TXFC0"], order=order, excuted=False, ) ] } touch_order.infos["TXFD0"] = StatusInfo( close=close_price, buy_price=11, sell_price=11, high=11, low=11, change_price=11, change_rate=1, volume=1, total_volume=1, ) touch_order.touch(code) assert touch_order.api.place_order.call_count == order_count