Administrator
2024-07-11 e70bdf6ab8e20c122cd5eb9e5fd6e384ab903b8d
main.py
@@ -18,7 +18,7 @@
from third_data import kpl_data_manager, kpl_util
from third_data.kpl_data_manager import PullTask, KPLCodeJXBlockManager, KPLLimitUpDataRecordManager
from trade import huaxin_trade_api, huaxin_trade_data_update, huaxin_sell_util, backtest_trade, buy_strategy
from trade.buy_strategy import BuyStrategyDataManager
from trade.buy_strategy import BuyStrategyDataManager, StrategyBuyOrderRefManager
from trade.trade_manager import CodeTradeStateManager
from trade.trade_settings import WantBuyCodesManager, TradeStateManager
from utils import middle_api_protocol, outside_api_command_manager, constant, tool, huaxin_util, socket_util, sell_util, \
@@ -216,7 +216,7 @@
                    for k in temp_dict:
                        volume = sum([x["volume"] for x in temp_dict[k]])
                        x = temp_dict[k][0]
                        r["buy_list"].append({"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": volume})
                        r["buy_list"].append({"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": volume, "type":StrategyBuyOrderRefManager().get_strategy_type(x["orderRef"])})
                    r["createTime"] = int(buys[0]["tradeTime"].replace(":", ""))
                if "sell_list" not in r:
@@ -328,11 +328,12 @@
    else:
        money = 10000
    if strategy_type == buy_strategy.STRATEGY_TYPE_RISE_HIGH_WITH_BLOCKS:
        return int(money*0.2)
    elif  strategy_type == buy_strategy.STRATEGY_TYPE_LIMIT_UP:
        return int(money * 0.8)
    elif strategy_type == buy_strategy.STRATEGY_TYPE_LIMIT_UP:
        return int(money * 0.2)
    else:
        return money
def read_l2_results(trade_call_back_queue):
    while True:
@@ -371,7 +372,7 @@
                            result = huaxin_trade_api.order(1, cb_code, volume, buy_price, blocking=True)
                            if type(result) == dict and result['code'] == 0:
                                orderRef = result['data']['orderRef']
                                async_log_util.info(logger_trade, f"可转载策略下单结果:({orderRef},{strategy_type})")
                                StrategyBuyOrderRefManager().add(orderRef, strategy_type)
                            CodeTradeStateManager().set_trade_state(cb_code, strategy_type,
                                                                    CodeTradeStateManager.TRADE_STATE_ALREADY_BUY)
                            # 移除想买单