strategy/instant_time_market.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
strategy/kpl_api.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
strategy/order_methods.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
strategy/trade_setting.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
strategy/instant_time_market.py
@@ -7,6 +7,7 @@ import datetime import utils from log_module.log import logger_common from strategy.trade_setting import TradeSetting from utils import huaxin_util, tool # 引入华鑫API(小辉整理) from strategy import l1_data_api @@ -28,6 +29,10 @@ def index_market_current(): logging.info(f"index_market_trend进入") while True: if not TradeSetting().get_running(): # 已经暂停 time.sleep(1) continue try: # 在data_cache中获取到推送过来的实时指数行情数据 stock_index_dict = data_cache.stock_index_dict strategy/kpl_api.py
@@ -233,8 +233,28 @@ its_stock = getCodesByPlate(i[0]) # print(f"======={i[0]}=======") its_stock = json.loads(its_stock) l = its_stock['list'][0] # print(f"its_stock['list'] === {its_stock['list']}") # print(f"its_stock['list'][0] === {its_stock['list'][0]}") # logger.info(f"its_stock['list'] === {its_stock['list']}") logger.info(f"its_stock['list'][0] === {its_stock['list'][0]}") # 将板块强度下面对应的个股列表打印到日志中 # for i in l: # if l[41] != 1: # logger.info( # f"l === 个股代码:{l[0]},公司名称:{l[1]},主力资金推测:{l[2]},未知0值:{l[3]},概念:{l[4]},最新价:{l[5]},当日当时涨幅:{l[6]}%," # f"成交额:{round(l[7] / 100000000, 2)} 亿,实际换手率:{l[8]}%,未知0值:{l[9]},实际流通:{round(l[10] / 100000000, 2)}亿," # f"主力买:{round(l[11] / 100000000, 2)}亿," # f"主力卖:{round(l[12] / 100000000, 2)}亿," # f"主力净额:{round(l[13] / 10000, 2)}万,买成占比:{l[14]}%,卖成占比:{l[15]}%,净成占比:{l[16]}%,买流占比:{l[17]}%,卖流占比:{l[18]}%,净流占比:{l[19]}%," # f"区间涨幅:{l[20]}%,量比:{l[21]},未知0:{l[22]},上板情况:{l[23]},上板排名:{l[24]},换手率:{l[25]}%," # f"未知空值:{l[26]},未知零值:{l[27]},收盘封单:{l[28]},最大封单:{l[29]},未知空值?:{l[30]}," # f"?:{l[30]}%,?:{l[31]},??:{l[32]},振幅:{l[33]}%,未知0????:{l[34]},未知0?????:{l[35]}," # f"?=:{l[36]},?总市值:{l[37]},?流通市值:{l[38]},最终归属概念(收盘后出数据?):{l[39]},领涨次数:{l[40]}," # f"41未知1值:{l[41]},第三季度机构持仓【str数据勿用运算符】:{l[42]}万,?年预测净利润:{l[43]},上年预测净利润:{l[44]},年内预测净利润:{l[45]}" # ) # 获取该概念板块的的子版块 # its_son_plate = json.loads(getSonPlate(i[0])) # logger.info(f"its_son_plate=={its_son_plate['List']}") @@ -247,10 +267,9 @@ stock_power_list = [] for s in its_stock['list']: # 过滤掉涨幅大于 and s[6] < 6.5 且小于0%的 和 名称中包含ST的 和 涨速小于等于0%的 和 只要昨日未涨停 和 上证或深证的正股 and s[9] > 0.0025 if s[6] > 0 and s[1].find("ST") < 0 and s[1].find("XD") < 0 and s[23].find("板") < 0 and s[24].find( "板") < 0 and (s[0].startswith('60') or s[0].startswith('00')) and s[9] > 1: if s[6] > 0 and s[1].find("ST") < 0 and s[1].find("XD") < 0 and s[23].find("板") < 0 and s[24].find("板") < 0 and (s[0].startswith('60') or s[0].startswith('00')) and s[9] > 1: # print(f"{s[1]},个股代码:{s[0]}, 涨幅:{s[6]}% 涨速:{s[9]}% 概念:{s[4]} 主力资金推测:{s[2]} 领涨次数:{s[40]} 今日第几板:{s[23]} 是否破版{s[24]}") # 对个股强度属性列表进行初始化 # 对个股强度 主要 属性列表进行装填 its_stock_power = [s[1], s[0], s[6], s[9], s[4], s[2], s[40]] # 逐个选择性添加its_stock中的元素到个股强度列表中 # print(f"its_stock_power===={its_stock_power}") @@ -268,6 +287,7 @@ market_sift_plate = json.loads(data) # logger_kpl_jingxuan_in 打印的日志专用于开盘了数据的存储分析,不能轻易删除 # print(f"market_sift_plate 数 ======{len(market_sift_plate['list'])}") # 行情》精选板块》排名前20中》对应个股》符合条件的个股 # logger.info(f"market_sift_plate['list']======{market_sift_plate['list']}") # logger.info(f"market_sift_plate['list'][0] ======{market_sift_plate['list'][0]}") # 初始化精选板块对应个股字典 strategy/order_methods.py
@@ -8,6 +8,7 @@ from strategy import data_cache, account_management import data_server from log_module.log import logger_debug, logger_common from strategy.trade_setting import TradeSetting from trade import huaxin_trade_api, huaxin_trade_data_update, middle_api_protocol from utils import huaxin_util, tool @@ -19,6 +20,12 @@ # 下单买入函数(按金额,以限价买)【按金额买 基础版】 def buy_order_by_value(symbol, buy_order_value, sec_name, current_price): # 自动买 开关监听方法 if not TradeSetting().get_auto_buy(): # 暂停自动买 logger.info(f"在交易方法函数处 关闭了 自动买") return price = round(float(current_price), 2) volume = (int(buy_order_value / price) // 100) * 100 if volume < 100: @@ -78,6 +85,11 @@ # 下单卖出函数(按持仓数量,在限价卖)【按量卖 基础版】 def sell_order_by_volume(symbol, volume, sec_name, current_price): # 自动卖开关监听方法 if not TradeSetting().get_auto_sell(): # 暂停自动卖 logger.info(f"在交易方法函数处 关闭了 自动卖") return # price = round(float(price), 2) # 调用笼子价计算工具计算下单价格 order_price = tool.get_buy_min_price(current_price) @@ -111,6 +123,7 @@ :param index: 持仓对象列表中的个股对应序列号 :return: 尝试返回的订单数据 """ logger.info(f"当前个股持仓手数【当前函数被调用时传进来的同步数据data_cache中的持仓数据】==={position_volume_yesterday}") # sell_order_volume = int(position_volume_yesterday * part_of_volume) sell_order_volume = round(position_volume_yesterday * part_of_volume / 100) * 100 strategy/trade_setting.py
@@ -39,7 +39,9 @@ result = RedisUtils.get(self.__get_redis(), self.__TYPE_AUTO_SELL) if result is not None: self.auto_sell = int(result) ''' GUI中 暂停运行 自动买开关方法 自动卖开关方法 ''' def set_auto_buy(self, auto_buy): self.auto_buy = 1 if auto_buy else 0 RedisUtils.setex_async(self.__db, self.__TYPE_AUTO_BUY, tool.get_expire(), self.auto_buy) @@ -60,3 +62,10 @@ def get_auto_sell(self): return self.auto_sell if __name__ == '__main__': if TradeSetting().get_auto_buy(): print("自动买") else: print("不自动买")