Administrator
2024-07-05 6397e3d93ab5ce306a7079b1521318a631804535
bug修改
2个文件已修改
71 ■■■■ 已修改文件
huaxin_client/l2_client_for_cb.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client_for_cb.py
@@ -281,10 +281,12 @@
                        "ExecType": pTransaction['ExecType'].decode()}
                huaxin_l2_log.info(logger_local_huaxin_l2_transaction, f"{item}")
                result = self.buyStrategyDataManager.add_transaction_info(item)
                if result[0]:
                    l2_transaction_price_queue.put_nowait(
                        (pTransaction['SecurityID'], pTransaction['TradePrice'], pTransaction['TradeTime'], result))
                results = self.buyStrategyDataManager.add_transaction_info(item)
                for result in results:
                    if result[0]:
                        l2_transaction_price_queue.put_nowait(
                            (pTransaction['SecurityID'], pTransaction['TradePrice'], pTransaction['TradeTime'], results))
                        break
        except Exception as e:
            logger_local_huaxin_l2_error.exception(e)
@@ -300,10 +302,12 @@
                        "SellNo": pTick['SellNo'],
                        "ExecType": '1'}
                huaxin_l2_log.info(logger_local_huaxin_l2_transaction, f"{item}")
                result = self.buyStrategyDataManager.add_transaction_info(item)
                if result[0]:
                    l2_transaction_price_queue.put_nowait(
                        (pTick['SecurityID'], pTick['Price'], pTick['TickTime'], result))
                results = self.buyStrategyDataManager.add_transaction_info(item)
                for result in results:
                    if result[0]:
                        l2_transaction_price_queue.put_nowait(
                            (pTick['SecurityID'], pTick['Price'], pTick['TickTime'], results))
                        break
        except Exception as e:
            logger_local_huaxin_l2_error.exception(e)
main.py
@@ -282,33 +282,34 @@
                code, trade_time = result[0], result[1]
                buy_infos = result[3]
                for buy_info in buy_infos:
                    # 策略类型
                    strategy_type = buy_info[1]
                    # 获取股票代码的可转债代码
                    cb_code = target_codes_manager.get_cb_code(code)
                    if CodeTradeStateManager().get_trade_state(cb_code, strategy_type) == CodeTradeStateManager.TRADE_STATE_ALREADY_BUY:
                        async_log_util.info(logger_trade, f"已经下单过:{result}")
                        continue
                    # 获取可转债的涨停价
                    market_info = code_market_manager.get_market_info(cb_code)
                    limit_up_price = target_codes_manager.get_limit_up_price(cb_code)
                    if market_info:
                        if market_info.rate > 0.139:
                            async_log_util.info(logger_trade, f"可转债涨幅过高::{cb_code}-{market_info.rate}")
                    if buy_info[0]:
                        # 策略类型
                        strategy_type = buy_info[1]
                        # 获取股票代码的可转债代码
                        cb_code = target_codes_manager.get_cb_code(code)
                        if CodeTradeStateManager().get_trade_state(cb_code, strategy_type) == CodeTradeStateManager.TRADE_STATE_ALREADY_BUY:
                            async_log_util.info(logger_trade, f"已经下单过:{result}")
                            continue
                        # 获取可转债的涨停价
                        market_info = code_market_manager.get_market_info(cb_code)
                        limit_up_price = target_codes_manager.get_limit_up_price(cb_code)
                        if market_info:
                            if market_info.rate > 0.139:
                                async_log_util.info(logger_trade, f"可转债涨幅过高::{cb_code}-{market_info.rate}")
                                continue
                        volume = int(__get_buy_money() / float(limit_up_price))
                        volume = (volume // 10) * 10
                        buy_price = round(min(float(market_info.price * 1.02), float(limit_up_price)), 3)
                        async_log_util.info(logger_trade, f"准备下单:{cb_code}-{buy_price}")
                        # 买入20股
                        result = huaxin_trade_api.order(1, cb_code, volume, buy_price, blocking=True)
                        CodeTradeStateManager().set_trade_state(cb_code, strategy_type,
                                                                CodeTradeStateManager.TRADE_STATE_ALREADY_BUY)
                        async_log_util.info(logger_trade, f"可转债下单结果:{result}")
                        huaxin_trade_data_update.add_position_list()
                        huaxin_trade_data_update.add_money_list()
                        huaxin_trade_data_update.add_deal_list()
                            volume = int(__get_buy_money() / float(limit_up_price))
                            volume = (volume // 10) * 10
                            buy_price = round(min(float(market_info.price * 1.02), float(limit_up_price)), 3)
                            async_log_util.info(logger_trade, f"准备下单:{cb_code}-{buy_price}")
                            # 买入20股
                            result = huaxin_trade_api.order(1, cb_code, volume, buy_price, blocking=True)
                            CodeTradeStateManager().set_trade_state(cb_code, strategy_type,
                                                                    CodeTradeStateManager.TRADE_STATE_ALREADY_BUY)
                            async_log_util.info(logger_trade, f"可转债下单结果:{result}")
                            huaxin_trade_data_update.add_position_list()
                            huaxin_trade_data_update.add_money_list()
                            huaxin_trade_data_update.add_deal_list()
        except Exception as e:
            logger_debug.exception(e)
            time.sleep(1)