| | |
| | | from huaxin_client.client_network import SendResponseSkManager |
| | | from log_module import async_log_util, log_export |
| | | from records import huaxin_trade_record_manager |
| | | from third_data.kpl_data_manager import PullTask |
| | | 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 |
| | | from trade.buy_strategy import BuyStrategyDataManager |
| | | from utils import middle_api_protocol, outside_api_command_manager, constant, tool, huaxin_util, socket_util, sell_util, \ |
| | | output_util, l2_huaxin_util |
| | | output_util, l2_huaxin_util, output_data_util |
| | | |
| | | middle_api_protocol.SERVER_PORT = 10008 |
| | | middle_api_protocol.SERVER_HOST = "43.138.167.68" |
| | |
| | | "buy1Money": output_util.money_desc( |
| | | underlying_market.buy1_price * underlying_market.buy1_volume), |
| | | "preClosePrice": underlying_market.pre_close_price} |
| | | |
| | | r["underlyingDetailInfo"] = output_data_util.load_code_detail_info(underlying_market.code) |
| | | r["underlyingDetailInfo"]["price"] = underlying_market.price |
| | | |
| | | # 获取买点与卖点 |
| | | if "buy_list" not in r: |
| | | buys = huaxin_trade_record_manager.DealRecordManager().list_buy_by_code_cache(cb_code) |
| | |
| | | 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: |
| | | buy_price = round( min( float(market_info.price*1.02) ,float(limit_up_price)),3) |
| | | 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, 20, buy_price, blocking=True) |
| | |
| | | try: |
| | | result = queue_market.get() |
| | | if result: |
| | | # 代码, 最近的价格, 涨幅, 买1价, 买1量, 成交总量 |
| | | # (代码, 最近的价格, 涨幅, 买1价, 买1量, 成交总量, 买入量, 卖出量, 昨日收盘价, 时间戳) |
| | | code_market_manager.set_market_info(result) |
| | | code = result[0] |
| | | # 正股需要加载板块 |
| | | if code.find("11")!=0 and code.find("12")!=0: |
| | | limit_up_price = tool.get_limit_up_price(code, result[8]) |
| | | |
| | | KPLCodeJXBlockManager().load_jx_blocks(result[0], result[3], |
| | | float(limit_up_price), |
| | | KPLLimitUpDataRecordManager.get_current_reasons()) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | time.sleep(1) |
| | |
| | | logger_debug.exception(e) |
| | | |
| | | |
| | | def __kpl_limit_up_callback(results): |
| | | if results: |
| | | result_list = kpl_util.parseLimitUpData(results) |
| | | kpl_data_manager.KPLLimitUpDataRecordManager.save_record(tool.get_now_date_str(), result_list) |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | # ===========初始化数据========== |
| | | try: |
| | |
| | | huaxin_trade_data_update.run() |
| | | |
| | | # 定时拉取开盘啦涨停数据 |
| | | PullTask.run_limit_up_task() |
| | | PullTask.run_limit_up_task(__kpl_limit_up_callback) |
| | | |
| | | # 仿真交易不运行交易客户端 |
| | | # # ===========运行交易外部API========== |