From 892b50e242e3c59a738b92dfdfee1bf1ff8932f2 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 21 十月 2022 16:59:58 +0800 Subject: [PATCH] 新策略修改 --- juejin.py | 37 ++++++++++++++++++++++++++++++++----- 1 files changed, 32 insertions(+), 5 deletions(-) diff --git a/juejin.py b/juejin.py index 1c171c3..20379aa 100644 --- a/juejin.py +++ b/juejin.py @@ -6,6 +6,7 @@ import datetime import json +import logging import time as t import schedule @@ -24,10 +25,15 @@ import redis_manager import authority import decimal + +import trade_gui from l2_code_operate import L2CodeOperate +from l2_data_manager import L2LimitUpMoneyStatisticUtil from log import logger_juejin_tick, logger_system +from trade_queue_manager import JueJinBuy1VolumnManager redisManager = redis_manager.RedisManager() +__jueJinBuy1VolumnManager = JueJinBuy1VolumnManager() # 璁剧疆璐︽埛淇℃伅 @@ -173,8 +179,6 @@ def on_tick(context, tick): - if global_util.TEST: - return # print(tick["created_at"]) relative_timestamp = t.time() % (24 * 60 * 60) + 8 * 60 * 60 # 9鐐�20-15:05鎺ュ彈鏁版嵁 @@ -193,6 +197,16 @@ # 淇濆瓨鏈�鏂颁环 symbol = symbol.split(".")[1] + time_ = tick["created_at"].strftime("%H:%M:%S") + data_=(symbol,time_,tick["quotes"][0]["bid_v"], tick["quotes"][0]["bid_p"]) + logger_juejin_tick.info("涔�1閲� {},{},{},{}", data_[1], data_[0], data_[2], + data_[3]) + need_sync = __jueJinBuy1VolumnManager.save(data_[0], data_[1], data_[2],data_[3]) + if need_sync: + # 鍚屾鏁版嵁 + L2LimitUpMoneyStatisticUtil.verify_num(data_[0], data_[2], data_[1]) + + # print(tick["created_at"],tick["quotes"][0]["bid_v"]) accpt_price(symbol, price) __prices_now[symbol] = price @@ -220,6 +234,7 @@ # 鑾峰彇鍒扮幇浠� def accpt_prices(prices): + print("浠锋牸浠g爜鏁伴噺锛�", len(prices)) now_str = datetime.datetime.now().strftime("%H:%M:%S") now_strs = now_str.split(":") now_second = int(now_strs[0]) * 60 * 60 + int(now_strs[1]) * 60 + int(now_strs[2]) @@ -237,7 +252,7 @@ # 鑾峰彇鏀剁洏浠� pricePre = gpcode_manager.get_price_pre(code) if pricePre is not None: - rate = round((price - pricePre) * 100 / pricePre, 1) + rate = round((price - pricePre) * 100 / pricePre, 2) if rate >= 0: # 鏆傚瓨娑ㄥ箙涓烘鐨勪唬鐮� _code_list.append((rate, code)) @@ -246,9 +261,23 @@ _delete_list.append((rate, code)) # 鎺掑簭 new_code_list = sorted(_code_list, key=lambda e: e.__getitem__(0), reverse=True) + # 棰勫~鍏呬笅鍗曚唬鐮� + _buy_win_codes = [] + for d in new_code_list: + _buy_win_codes.append(d[1]) + for d in _delete_list: + _buy_win_codes.append(d[1]) + try: + trade_gui.THSBuyWinManagerNew.fill_codes(_buy_win_codes) + except Exception as e: + logging.exception(e) + pass + client_ids = data_process.getValidL2Clients() # 鏈�澶氬~鍏呯殑浠g爜鏁伴噺 max_count = len(client_ids) * 8 + if max_count == 0: + max_count = 8 # 鎴彇鍓嶅嚑涓唬鐮佸~鍏� add_list = new_code_list[:max_count] # 鍚庨潰鐨勪唬鐮佸叏閮ㄥ垹闄� @@ -272,8 +301,6 @@ for code in add_code_list: if not gpcode_manager.is_listen(code): L2CodeOperate.get_instance().add_operate(1, code, "鐜颁环鍙樺寲") - - print(add_code_list, del_list) -- Gitblit v1.8.0