首页 » 排名链接 » 根据MACD指标自动盯盘软件的使用开发(日期排除万难指标发送短信开发)

根据MACD指标自动盯盘软件的使用开发(日期排除万难指标发送短信开发)

萌界大人物 2024-10-23 19:22:20 0

扫一扫用手机浏览

文章目录 [+]

找了一圈,市面上也没有现成的软件.于是找到我让我给他开发一个工具.

开始他的需求并不复杂, 就是根据品种的5分钟MACD指标,去判定入场时机.

当5分钟MACD指标出现金叉/死叉时给他发送短信提醒,后面他再自己判断是否入场建仓.

根据MACD指标自动盯盘软件的使用开发(日期排除万难指标发送短信开发) 排名链接
(图片来自网络侵删)
2 开发步骤2.1 数据源

数据源采用的是同花顺的IFIND数据接口,采用Python开发.

# 高频序列:获取分钟数据def high_frequency():thsUrl = 'https://quantapi.51ifind.com/api/v1/high_frequency'thsPara = {"codes":"000001.SZ","indicators":"open,high,low,close,volume,amount,changeRatio","starttime":"2022-07-05 09:15:00","endtime":"2022-07-05 15:15:00"}thsResponse = requests.post(url=thsUrl, json=thsPara, headers=thsHeaders)print(thsResponse.content)2.2主要代码

def compute_macd_5(codes):# 当前时间 前推 一个月内的 5分钟 K 数据curr_time = dt.now()today = dt.now().weekday()if today == 0 :#周一hours = 72else:hours = 20s_time = curr_time - datetime.timedelta(hours=hours)s_time_str = dt.strftime(s_time,time_sp)rs = high_frequency(codes=codes,starttime=s_time_str,endtime=dt.strftime((curr_time),time_sp))if len(rs) ==0:return Falsers_table = rs['table']dif, dea, hist = ta.MACD(np.array(rs_table['close']), fastperiod=12, slowperiod=26, signalperiod=9)df3 = pd.DataFrame({'dif':dif[33:],'dea':dea[33:],'hist':hist[33:]},index=rs['time'][33:],columns=['dif','dea','hist'])# 寻找MACD金叉和死叉datenumber = int(df3.shape[0])jin_cha = Nonesi_cha = Nonefor i in range(datenumber-1):if ((df3.iloc[i,0]<=df3.iloc[i,1]) & (df3.iloc[i+1,0]>=df3.iloc[i+1,1])):print("MACD金叉的日期:"+df3.index[i+1])if ((df3.iloc[i,0]>=df3.iloc[i,1]) & (df3.iloc[i+1,0]<=df3.iloc[i+1,1])):print("MACD死叉的日期:"+df3.index[i+1])2.3 运行结果

MACD死叉的日期:2022-08-04 02:30

MACD金叉的日期:2022-08-04 09:35

MACD死叉的日期:2022-08-04 11:10

MACD金叉的日期:2022-08-04 14:50

总结最后得出5分钟MACD 发生金叉/死叉的具体时间,我们的主要功能也就写完了. 然后再调用发送短信的接口.就可以正常使用了. 经过测试通知短信的延时最长不超过1分钟,对于这个频率的交易也够用了.#### 下一篇我们准备回测这个策略,看下具体收益率.
标签:

相关文章