| | |
| | | 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) |