| | |
| | | import gm.api as gmapi |
| | | |
| | | import big_money_num_manager |
| | | import client_manager |
| | | import code_volumn_manager |
| | | import data_process |
| | | import constant |
| | | import global_data_loader |
| | | import global_util |
| | | import gpcode_manager |
| | | import threading |
| | | |
| | | import l2_trade_util |
| | | import server |
| | | import tool |
| | | |
| | |
| | | |
| | | import trade_gui |
| | | from l2_code_operate import L2CodeOperate |
| | | from l2_data_manager import L2LimitUpMoneyStatisticUtil |
| | | from l2_data_manager import L2LimitUpMoneyStatisticUtil, L2DataUtil |
| | | from log import logger_juejin_tick, logger_system |
| | | from trade_data_manager import CodeActualPriceProcessor |
| | | from trade_queue_manager import JueJinBuy1VolumnManager |
| | | |
| | | redisManager = redis_manager.RedisManager() |
| | | redisManager = redis_manager.RedisManager(0) |
| | | __jueJinBuy1VolumnManager = JueJinBuy1VolumnManager() |
| | | __actualPriceProcessor = CodeActualPriceProcessor() |
| | | |
| | | |
| | | # 设置账户信息 |
| | |
| | | |
| | | def init_data(): |
| | | # 载入行业股票代码 |
| | | global_util.load_industry() |
| | | global_data_loader.load_industry() |
| | | # 载入代码自由流通市值 |
| | | global_util.load_zyltgb() |
| | | global_data_loader.load_zyltgb() |
| | | # 载入量 |
| | | global_util.load_volumn() |
| | | global_data_loader.load_volumn() |
| | | |
| | | |
| | | # 每日初始化 |
| | |
| | | logger_system.info("每日初始化") |
| | | |
| | | # 今日实时涨停 |
| | | global_util.add_limit_up_codes([], True) |
| | | global_data_loader.add_limit_up_codes([], True) |
| | | # 主要获取收盘价 |
| | | get_latest_info(None) |
| | | # 获取60天最大量与昨日量 |
| | |
| | | global_util.limit_up_time.clear() |
| | | init_data() |
| | | # 初始化同花顺主站 |
| | | l2_clients = data_process.getValidL2Clients() |
| | | l2_clients = client_manager.getValidL2Clients() |
| | | for client in l2_clients: |
| | | server.repair_ths_main_site(client) |
| | | |
| | |
| | | start2 = 60 * 60 * 12 + 50 * 60 |
| | | end2 = 60 * 60 * 15 + 5 * 60 |
| | | # TODO 测试 |
| | | if (start1 < relative_timestamp < end1 or start2 < relative_timestamp < end2) or global_util.TEST: |
| | | if (start1 < relative_timestamp < end1 or start2 < relative_timestamp < end2) or constant.TEST: |
| | | symbol = tick['symbol'] |
| | | price = tick['price'] |
| | | # print(symbol,price) |
| | |
| | | |
| | | # 保存最新价 |
| | | symbol = symbol.split(".")[1] |
| | | JueJinManager.add_listen_code(symbol) |
| | | 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], |
| | |
| | | else: |
| | | # 暂存涨幅为负的代码 |
| | | _delete_list.append((rate, code)) |
| | | try: |
| | | __actualPriceProcessor.process_rate(code, rate, now_str) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | |
| | | try: |
| | | __actualPriceProcessor.save_current_price(code, price, gpcode_manager.get_limit_up_price_by_preprice(pricePre) == tool.to_price(decimal.Decimal(d["price"]))) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | |
| | | # 排序 |
| | | new_code_list = sorted(_code_list, key=lambda e: e.__getitem__(0), reverse=True) |
| | | # 预填充下单代码 |
| | |
| | | logging.exception(e) |
| | | pass |
| | | |
| | | client_ids = data_process.getValidL2Clients() |
| | | client_ids = client_manager.getValidL2Clients() |
| | | # 最多填充的代码数量 |
| | | max_count = len(client_ids) * 8 |
| | | if max_count == 0: |
| | |
| | | # 增加应该增加的代码 |
| | | for code in add_code_list: |
| | | if not gpcode_manager.is_listen(code): |
| | | if not l2_trade_util.is_in_forbidden_trade_codes(code): |
| | | L2CodeOperate.get_instance().add_operate(1, code, "现价变化") |
| | | else: |
| | | if l2_trade_util.is_in_forbidden_trade_codes(code): |
| | | L2CodeOperate.get_instance().add_operate(0, code, "现价变化") |
| | | |
| | | print(add_code_list, del_list) |
| | | |
| | |
| | | def stop(self): |
| | | gmapi.stop() |
| | | |
| | | @classmethod |
| | | def add_listen_code(cls, code): |
| | | redis = redisManager.getRedis() |
| | | redis.setex("juejin_listen_code-{}".format(code), 20, "1") |
| | | |
| | | @classmethod |
| | | def get_listen_codes_lenth(cls): |
| | | redis = redisManager.getRedis() |
| | | keys = redis.keys("juejin_listen_code-*") |
| | | return len(keys) |
| | | |
| | | |
| | | def trade(code, volume): |
| | | account_id, s_id, token = getAccountInfo() |