| | |
| | | import datetime |
| | | import json |
| | | import time as t |
| | | import schedule |
| | | |
| | | import gm.api as gmapi |
| | | |
| | | import global_util |
| | | import gpcode_manager |
| | | import threading |
| | | |
| | | import server |
| | | import tool |
| | | |
| | | import redis_manager |
| | | import authority |
| | | import decimal |
| | | from l2_code_operate import L2CodeOperate |
| | | from log import logger_juejin_tick |
| | | from log import logger_juejin_tick, logger_system |
| | | |
| | | redisManager = redis_manager.RedisManager() |
| | | |
| | |
| | | return account_id, strategy_id, token |
| | | |
| | | |
| | | # 每日初始化 |
| | | def everyday_init(): |
| | | logger_system.info("每日初始化") |
| | | # 载入行业股票代码 |
| | | global_util.load_industry() |
| | | # 载入代码自由流通市值 |
| | | global_util.load_zyltgb() |
| | | # 今日实时涨停 |
| | | global_util.add_limit_up_codes([], True) |
| | | # 主要获取收盘价 |
| | | get_latest_info(None) |
| | | |
| | | |
| | | def __run_schedule(): |
| | | while True: |
| | | schedule.run_pending() |
| | | |
| | | |
| | | def init(context): |
| | | # gmapi.subscribe(symbols="SZSE.002529", frequency="1d", count=30) |
| | | |
| | | # 订阅浦发银行, bar频率为一天和一分钟 |
| | | # 订阅订阅多个频率的数据,可多次调用subscribe |
| | | # 获取需要监听的股票 |
| | | print("掘金初始化") |
| | | logger_system.info("掘金初始化") |
| | | schedule.every().day.at("09:00:00").do(everyday_init) |
| | | t1 = threading.Thread(target=lambda: __run_schedule()) |
| | | # 后台运行 |
| | | t1.setDaemon(True) |
| | | t1.start() |
| | | |
| | | # 多个时间点获取收盘价 |
| | | gmapi.schedule(schedule_func=get_latest_info, date_rule='1d', time_rule='08:30:00') |
| | | gmapi.schedule(schedule_func=get_latest_info, date_rule='1d', time_rule='08:50:00') |
| | |
| | | def get_current_info(): |
| | | data = gpcode_manager.get_gp_list(); |
| | | results = JueJinManager.get_gp_current_info(data); |
| | | logger_juejin_tick.debug("定时获取:{}",results) |
| | | logger_juejin_tick.debug("定时获取:{}", results) |
| | | for result in results: |
| | | price = result["price"] |
| | | symbol = result['symbol'] |
| | |
| | | def recieve_msg(pipe): |
| | | while True: |
| | | value = pipe.recv() |
| | | print("跨进程通信:",value) |
| | | jsonValue= json.loads(value) |
| | | action=jsonValue["type"] |
| | | print("跨进程通信:", value) |
| | | jsonValue = json.loads(value) |
| | | action = jsonValue["type"] |
| | | if action == 'resub': |
| | | re_subscribe_tick() |
| | | elif action == 'accpt_price': |
| | | try: |
| | | datas=jsonValue["data"] |
| | | datas = jsonValue["data"] |
| | | for data in datas: |
| | | accpt_price(data["code"],float(data["price"])) |
| | | accpt_price(data["code"], float(data["price"])) |
| | | except Exception as e: |
| | | print(str(e)) |
| | | |
| | | |
| | | |
| | | |
| | | class JueJinManager: |
| | |
| | | print(result) |
| | | |
| | | |
| | | # 获取近90天的最大量与最近的量 |
| | | def get_volumns(codes): |
| | | end = datetime.datetime.now() |
| | | # 获取近90天的历史数据 |
| | |
| | | start_time="{:%Y-%m-%d}".format(start), |
| | | fields="symbol,volume,eob", |
| | | end_time="{:%Y-%m-%d}".format(end)) |
| | | print(len(results)) |
| | | _fresult = {} |
| | | |
| | | for result in results: |
| | |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | # trade("SZSE.000521", 100) |
| | | # print("") |
| | | # JueJinManager.get_gp_latest_info(["000592","002808"]) |
| | | get_current_info() |
| | | |
| | | # data_process.saveCodeVolumn(get_volumns(["000333","002911"])) |
| | | # _redis_manager = redis_manager.RedisManager() |
| | | # redis = _redis_manager.getRedis() |
| | | # keys = redis.keys("test-inrec") |
| | | # print(keys) |
| | | _fresult=get_volumns(["000333","002531"]) |
| | | print(_fresult) |