神奇九转触发条件,神奇九转信号图解

首页 > 经验 > 作者:YD1662022-11-07 23:26:27

pro = ts.pro_api() #查询当前所有正常上市交易的股票列表 data = pro.stock_basic(exchange = '', list_status = 'L', fields = 'ts_code, symbol, name, area, industry, list_date')

ts_code symbol name area industry list_date 0 000001.SZ 000001 平安银行 深圳 银行 19910403 1 000002.SZ 000002 万科A 深圳 全国地产 19910129 2 000004.SZ 000004 国农科技 深圳 生物制药 19910114 3 000005.SZ 000005 世纪星源 深圳 房产服务 19901210 4 000006.SZ 000006 深振业A 深圳 区域地产 19920427 5 000007.SZ 000007 全新好 深圳 酒店餐饮 19920413 6 000008.SZ 000008 神州高铁 北京 运输设备 19920507 7 000009.SZ 000009 中国宝安 深圳 综合类 19910625 8 000010.SZ 000010 美丽生态 深圳 建筑施工 19951027 9 000011.SZ 000011 深物业A 深圳 区域地产 19920330 10000012.SZ000012南玻A深圳玻璃199202282.2 daily股票日线行情数据接口

获取股票日线行情数据。

数据说明:交易日每天15点~16点之间。本接口是未复权行情,停牌期间不提供数据。

调取说明:基础积分每分钟内最多调取500次,每次5000条数据,相当于23年历史。

神奇九转触发条件,神奇九转信号图解(5)

神奇九转触发条件,神奇九转信号图解(6)

pro = ts.pro_api() df = pro.daily(ts_code = '000001.SZ', start_date = '20180701', end_date = '20180718') #多个股票 df = pro.daily(ts_code = '000001.SZ, 600000.SH', start_date = '20180701', end_date = '20180718') #通过日期取历史某一天的全部历史 df = pro.daily(trade_date='20180810')

ts_code trade_date open high low close pre_close change pct_chg vol amount 0 000001.SZ 20180718 8.75 8.85 8.69 8.70 8.72 -0.02 -0.23 525152.77 460697.377 1 000001.SZ 20180717 8.74 8.75 8.66 8.72 8.73 -0.01 -0.11 375356.33 326396.994 2 000001.SZ 20180716 8.85 8.90 8.69 8.73 8.88 -0.15 -1.69 689845.58 603427.713 3 000001.SZ 20180713 8.92 8.94 8.82 8.88 8.88 0.00 0.00 603378.21 535401.175 4 000001.SZ 20180712 8.60 8.97 8.58 8.88 8.64 0.24 2.78 1140492.31 1008658.828 5 000001.SZ 20180711 8.76 8.83 8.68 8.78 8.98 -0.20 -2.23 851296.70 744765.824 6 000001.SZ 20180710 9.02 9.02 8.89 8.98 9.03 -0.05 -0.55 896862.02 803038.965 7 000001.SZ 20180709 8.69 9.03 8.68 9.03 8.66 0.37 4.27 1409954.60 1255007.609 8 000001.SZ 20180706 8.61 8.78 8.45 8.66 8.60 0.06 0.70 988282.69 852071.526 9 000001.SZ 20180705 8.62 8.73 8.55 8.60 8.61 -0.01 -0.12 835768.77 722169.579三、神奇九转指标策略选股的Python实现3.1 代码说明

从Tushare获取的股票基础数据存放在Mysql数据中。从数据库中找出所有非ST股票,然后循环检查每一只股票当前日期是否符合神奇九转指标策略(包括卖出和买入),符合策略的股票数据显示在表格中。

注:因篇幅原因,以下代码为主要实现逻辑,非全部代码。如需请联系。

3.2 主要代码

def get_nine_turn_index(self): lstBuy = [] lstSell = [] dfBuy = self.get_data_from_file(IDX_BUY) dfSell = self.get_data_from_file(IDX_SELL) if dfBuy.empty or dfSell.empty: stData = cmnDB().get_all_stock_basic_data(noST=True) idx = 0 iTop = 15 total = len(stData) start = time.perf_counter() for itm in stData: st = self.get_stock_json_data(itm) stCode = itm[0] data = cmnDB().get_nine_turn_data(stCode, lmt=iTop) data = data.iloc[:iTop] oClose = data.close.values if self.get_is_nine_turn_buy_stock(oClose): st['idx_type'] = IDX_BUY lstBuy.append(st) elif self.get_is_nine_turn_sell_stock(oClose): st['idx_type'] = IDX_SELL lstSell.append(st) idx = 1 cmn.show_progress_bar(idx, total, start, oBar=oGauge) # 生成csv文件 self.make_nine_turn_file(lstBuy, IDX_BUY) self.make_nine_turn_file(lstSell, IDX_SELL) # 转换为DataFrame dfBuy = pd.DataFrame(lstBuy) dfSell = pd.DataFrame(lstSell) df = dfBuy.append(dfSell, ignore_index=True) self.show_data_in_grid(df) """ ================================================== *** Name: get_is_nine_turn_buy_stock *** Desc: check the stock meet the magic nine turn index of buy *** Param: oClose - close value records of stock *** Return: Boolean: True / False """ def get_is_nine_turn_buy_stock(self, oClose): rtn = False iCount = 0 for idx in range(len(oClose) - 5): if oClose[idx] < oClose[idx 4]: iCount = 1 if iCount == 8: rtn = True break else: break return rtn """ ================================================== *** Name: get_is_nine_turn_sell_stock *** Desc: check the stock meet the magic nine turn index of sell *** Param: oClose - close value records of stock *** Return: Boolean: True / False """ def get_is_nine_turn_sell_stock(self, oClose): rtn = False iCount = 0 for idx in range(len(oClose) - 5): if oClose[idx] > oClose[idx 4]: iCount = 1 if iCount == 8: rtn = True break else: break return rtn3.3 实现结果数据样例

神奇九转触发条件,神奇九转信号图解(7)

符合九转买入结构股票

神奇九转触发条件,神奇九转信号图解(8)

上一页123下一页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.