L后比例调整/交易线程池增加至20个/下单请求2次
| | |
| | | |
| | | class MyTradeActionCallback(command_manager.TradeActionCallback): |
| | | __tradeSimpleApi = TradeSimpleApi() |
| | | trade_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10) |
| | | trade_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=20) |
| | | |
| | | def OnTrade(self, client_id, request_id, sk, type_, data): |
| | | if type_ == 1: |
| | |
| | | if temp_rate >= 1: |
| | | if temp_rate > 3: |
| | | temp_rate = 3 |
| | | deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) |
| | | deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) if is_up else round((temp_rate * 10.5 - 7.5) / 100, 4) |
| | | |
| | | base_rate += block_rate |
| | | base_rate += deal_rate |
| | |
| | | sinfo = f"b_{code}_{timestamp}" |
| | | if not order_ref: |
| | | order_ref = huaxin_util.create_order_ref() |
| | | request_id = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": ClientSocketManager.CLIENT_TYPE_TRADE, "trade_type": 1, |
| | | "direction": direction, |
| | | "code": code, |
| | | "order_ref": order_ref, |
| | | "volume": volume, |
| | | "price_type": price_type, |
| | | "price": price, "shadow_price": shadow_price, "sinfo": sinfo, "blocking": blocking}, |
| | | request_id=request_id, |
| | | blocking=blocking, |
| | | is_pipe=is_pipe_channel_normal()) |
| | | if not request_id: |
| | | request_id = __get_request_id(ClientSocketManager.CLIENT_TYPE_TRADE) |
| | | for i in range(2): |
| | | request_id = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": ClientSocketManager.CLIENT_TYPE_TRADE, "trade_type": 1, |
| | | "direction": direction, |
| | | "code": code, |
| | | "order_ref": order_ref, |
| | | "volume": volume, |
| | | "price_type": price_type, |
| | | "price": price, "shadow_price": shadow_price, "sinfo": sinfo, "blocking": blocking}, |
| | | request_id=request_id, |
| | | blocking=blocking, |
| | | is_pipe=is_pipe_channel_normal()) |
| | | try: |
| | | if blocking: |
| | | return __read_response(request_id, blocking) |