| | |
| | | |
| | | # 预埋单 |
| | | def __test_pre_place_order(): |
| | | logger_debug.info("进入预埋单测试") |
| | | 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) |
| | | logger_debug.info(f"进入预埋单测试:{codes}") |
| | | try: |
| | | if codes: |
| | | for code in codes: |
| | | # 获取昨日收盘价格 |
| | | 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: |
| | | volume = tool.get_buy_volume_by_money(limit_up_price, constant.AVAILABLE_BUY_MONEYS[0]) |
| | | result = huaxin_trade_api.order(huaxin_trade_api.TRADE_DIRECTION_BUY, code, volume, limit_up_price, |
| | | bolcking=False, |
| | | shadow_price=shadow_price, shadow_volume=volume) |
| | | async_log_util.info(logger_trade, f"{code}下单结束:{result}") |
| | | buy_open_limit_up_strategy.BuyOpenLimitupDataManager().set_place_order_info(code, volume, volume, |
| | | result.get("order_ref")) |
| | | except Exception as e: |
| | | pass |
| | | if not limit_up_price: |
| | | init_data_util.re_set_price_pre(code, force=True) |
| | | 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: |
| | | volume = tool.get_buy_volume_by_money(limit_up_price, constant.AVAILABLE_BUY_MONEYS[0]) |
| | | result = huaxin_trade_api.order(huaxin_trade_api.TRADE_DIRECTION_BUY, code, volume, limit_up_price, |
| | | bolcking=False, |
| | | shadow_price=shadow_price, shadow_volume=volume) |
| | | async_log_util.info(logger_trade, f"{code}下单结束:{result}") |
| | | buy_open_limit_up_strategy.BuyOpenLimitupDataManager().set_place_order_info(code, volume, volume, |
| | | result.get("order_ref")) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | |
| | | |
| | | def __subscript_fixed_codes_l2(): |
| | |
| | | def __init(): |
| | | def run_pending(): |
| | | schedule.every().day.at("15:10:00").do(zyltgb_util.update_all_zylt_volumes) |
| | | schedule.every().day.at("01:05:00").do(__test_pre_place_order) |
| | | schedule.every().day.at("01:02:00").do(__test_pre_place_order) |
| | | schedule.every().day.at("09:10:00").do(__subscript_fixed_codes_l2) |
| | | schedule.every().day.at("08:00:01").do(history_k_data_manager.update_history_k_bars) |
| | | schedule.every().day.at("08:30:01").do(history_k_data_manager.update_history_k_bars) |
| | |
| | | schedule.every().day.at("09:00:01").do(huaxin_trade_data_update.add_money_list) |
| | | schedule.every().day.at("09:15:20").do(huaxin_trade_data_update.add_money_list) |
| | | while True: |
| | | schedule.run_pending() |
| | | time.sleep(1) |
| | | try: |
| | | schedule.run_pending() |
| | | except: |
| | | pass |
| | | finally: |
| | | time.sleep(1) |
| | | # 9点半后终止运行 |
| | | # if tool.trade_time_sub(tool.get_now_time_str(), "09:30:00") > 0: |
| | | # break |