Administrator
2022-10-21 892b50e242e3c59a738b92dfdfee1bf1ff8932f2
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("价格代码数量:", 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()
        # 最多填充的代码数量
        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)