| | |
| | | from trade.sell.sell_rule_manager import TradeRuleManager |
| | | from trade.trade_data_manager import RadicalBuyDealCodesManager |
| | | from trade.trade_manager import CodesTradeStateManager |
| | | from utils import socket_util, middle_api_protocol, tool, huaxin_util, global_util, trade_util |
| | | from utils import socket_util, middle_api_protocol, tool, huaxin_util, global_util, trade_util, init_data_util |
| | | |
| | | trade_data_request_queue = queue.Queue() |
| | | |
| | |
| | | L1DataManager.set_l1_current_price(code, price) |
| | | huaxin_l1_data_manager.set_buy1_data(code, d[5], d[6]) |
| | | |
| | | @classmethod |
| | | def __process_buy_open_limit_up_datas(cls, datas): |
| | | """ |
| | | 处理排1的数据 |
| | | @param datas: [(代码, 现价, 涨幅, 量, 当前时间, 买1价, 买1量, 买2价, 买2量, 更新时间)] |
| | | @return: |
| | | """ |
| | | # 9:25之后不再处理 |
| | | if tool.get_now_time_as_int() > int("092500"): |
| | | return |
| | | for d in datas: |
| | | if gpcode_manager.BuyOpenLimitUpCodeManager().is_in_cache(d[0]): |
| | | #09:19:50 到 09:20:00判断是否要撤单 |
| | | if int("09:19:50") <=tool.get_now_time_as_int()<int("09:20:00"): |
| | | async_log_util.info(logger_debug, f"排1撤单:{d}") |
| | | # 获取L1现价 |
| | | @classmethod |
| | | def get_l1_current_price(cls, code): |
| | |
| | | request_id = data_json["request_id"] |
| | | datas = data["data"] |
| | | cls.__save_l1_current_price(datas) |
| | | cls.__process_buy_open_limit_up_datas(datas) |
| | | # 9:30之前采用非线程 |
| | | if int(tool.get_now_time_str().replace(":", "")) < int("093000"): |
| | | HuaXinL1TargetCodesManager.set_level_1_codes_datas(datas, request_id=request_id) |
| | |
| | | # 预埋单 |
| | | def __test_pre_place_order(): |
| | | logger_debug.info("进入预埋单测试") |
| | | price = round(21.98*1.1, 2) |
| | | code = "002253" |
| | | shadow_price = tool.get_shadow_price(price) |
| | | codes = gpcode_manager.BuyOpenLimitUpCodeManager().get_codes() |
| | | if codes: |
| | | for code in codes: |
| | | # 获取昨日收盘价格 |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | if not limit_up_price: |
| | | init_data_util.re_set_price_pre(code) |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | if not limit_up_price: |
| | | logger_debug.info(f"没有获取到涨停价:{code}") |
| | | continue |
| | | shadow_price = tool.get_shadow_price(limit_up_price) |
| | | if not constant.TRADE_ENABLE: |
| | | return |
| | | try: |
| | | result = huaxin_trade_api.order(1, code, 100, price, blocking=True, |
| | | result = huaxin_trade_api.order(1, code, 100, limit_up_price, blocking=True, |
| | | shadow_price=shadow_price) |
| | | async_log_util.info(logger_trade, f"{code}下单结束:{result}") |
| | | except Exception as e: |