| | |
| | | |
| | | |
| | | # 开始交易 |
| | | def start_buy(code, capture_timestamp, last_data, last_data_index, mode=0): |
| | | def start_buy(code, capture_timestamp, last_data, last_data_index, mode=0, exec_index=None): |
| | | def is_forbidden(code): |
| | | if l2_trade_util.is_in_forbidden_trade_codes(code): |
| | | return Exception("禁止交易") |
| | |
| | | async_log_util.info(logger_trade, "{} trade.manager.start_buy 判断是否可买".format(code)) |
| | | __CodesTradeStateManager.set_trade_state(code, TRADE_STATE_BUY_PLACE_ORDER) |
| | | # 状态改变过后必须要有本地下单编号 |
| | | __buy(code, price, trade_state, capture_timestamp, last_data, last_data_index, mode) |
| | | __buy(code, price, trade_state, capture_timestamp, last_data, last_data_index, mode, exec_index=exec_index) |
| | | finally: |
| | | async_log_util.info(logger_trade, "{} trade.manager.start_buy 结束".format(code)) |
| | | |
| | |
| | | |
| | | # 购买 |
| | | # @tool.async_call |
| | | def __buy(code, price, trade_state, capture_timestamp, last_data, last_data_index, mode=0): |
| | | def __buy(code, price, trade_state, capture_timestamp, last_data, last_data_index, mode=0, exec_index=None): |
| | | async_log_util.info(logger_trade, "{} trade_manager.__buy 开始".format(code)) |
| | | try: |
| | | if constant.API_TRADE_ENABLE: |
| | |
| | | elif constant.TRADE_WAY == constant.TRADE_WAY_HUAXIN: |
| | | order_ref = huaxin_util.create_order_ref() |
| | | TradeOrderIdManager().add_order_ref(code, order_ref) |
| | | trade_huaxin.order_volume(code, price, count, last_data, order_ref=order_ref) |
| | | trade_huaxin.order_volume(code, price, count, last_data, order_ref=order_ref, exec_index=exec_index) |
| | | else: |
| | | guiTrade.buy(code, price) |
| | | __place_order_success(code, capture_timestamp, last_data, last_data_index) |