当前位置: 首页 > news >正文

网站的建设可以起到什么作用是什么原因网页平面设计培训

网站的建设可以起到什么作用是什么原因,网页平面设计培训,做配单ic去什么网站好,网络推广公司司Backtrader 文档学习-Indicators混合时间周期 1.不同时间周期 如果数据源在Cerebro引擎中具有不同的时间范围和不同的长度#xff0c;指示器将会终止。 比如#xff1a;data0是日线#xff0c;data1是月线 。 pivotpoint btind.PivotPoint(self.data1) sellsignal self…Backtrader 文档学习-Indicators混合时间周期 1.不同时间周期 如果数据源在Cerebro引擎中具有不同的时间范围和不同的长度指示器将会终止。 比如data0是日线data1是月线 。 pivotpoint btind.PivotPoint(self.data1) sellsignal self.data0.close pivotpoint.s1当收盘低于s1线第一支撑位时为卖出信号 PivotPoint可以在更大的时间范围内工作 在以前的版本报错 return self.array[self.idx ago] IndexError: array index out of range 原因是self.data.close提供第一个bar的值但PivotPoint以及s1行只有在一个完整月过去后才会有值相当于self.data0.close的22个值。在这22个close值s1的Line还没有值从底层数组获取它的尝试失败报错超出范围。 Line对象支持ago运算符Python中的__call__特殊方法来传递自身的延迟版本 close1 self.data.close(-1) In this example the object close1 (when accessed via [0]) always contains the previous value (-1) delivered by close. The syntax has been reused to accomodate adapting timeframes. Let’s rewrite the above pivotpoint snippet: 对象close1通过[0]访问时始终包含close提供的前一个值-1。语法将重写以适应时间框架。重写上面的pivotpoint 片段 pivotpoint btind.PivotPoint(self.data1) sellsignal self.data0.close pivotpoint.s1()看看是如何在没有参数的情况下执行的在后台没有提供任何参数。发生了以下情况: pivotpoint.s1返回内部LinesCoupler对象该对象遵循较大范围周期coupler用来自实际s1的最新值填充从默认值NaN开始 。 在后面章节中的参数说明 PivotPoint Formula: pivot (h l c) / 3 # variants duplicate close or add opensupport1 2.0 * pivot - highsupport2 pivot - (high - low)resistance1 2.0 * pivot - lowresistance2 pivot (high - low) 对应计算后的Lineps1s2r1r2 运行结果 0069,0069,0014,2005-04-11,3080.60,3043.16,0.00 0070,0070,0014,2005-04-12,3065.18,3043.16,0.00 0071,0071,0014,2005-04-13,3080.54,3043.16,0.00 0072,0072,0014,2005-04-14,3075.33,3043.16,0.00 0073,0073,0014,2005-04-15,3013.89,3043.16,1.00 0074,0074,0015,2005-04-18,2947.79,2988.96,1.00 0075,0075,0015,2005-04-19,2957.37,2988.96,1.00 0076,0076,0015,2005-04-20,2944.33,2988.96,1.00 0077,0077,0015,2005-04-21,2950.34,2988.96,1.00 0078,0078,0015,2005-04-22,2976.39,2988.96,1.00 0079,0079,0016,2005-04-25,2987.05,2935.07,0.00 0080,0080,0016,2005-04-26,2983.22,2935.07,0.00 0081,0081,0016,2005-04-27,2942.62,2935.07,0.00在长度为74 的时候close s1 。出现signal 。 2.代码 from __future__ import (absolute_import, division, print_function,unicode_literals)import argparseimport backtrader as bt import backtrader.feeds as btfeeds import backtrader.indicators as btind import backtrader.utils.flushfileclass St(bt.Strategy):params dict(multiTrue)def __init__(self):self.pp pp btind.PivotPoint(self.data1)#print(dir(pp))pp.plotinfo.plot False # deactivate plottingif self.p.multi:pp1 pp() # couple the entire indicatorsself.sellsignal self.data0.close pp1.s1()else:self.sellsignal self.data0.close pp.s1()def next(self):txt , .join([%04d % len(self),%04d % len(self.data0),%04d % len(self.data1),self.data.datetime.date(0).isoformat(),%.2f % self.data0.close[0],%.2f % self.pp.s1[0],%.2f % self.sellsignal[0]])print(txt)def runstrat():args parse_args()cerebro bt.Cerebro()data btfeeds.BacktraderCSVData(datanameargs.data)cerebro.adddata(data)cerebro.resampledata(data, timeframebt.TimeFrame.Weeks) # 增加周线cerebro.resampledata(data, timeframebt.TimeFrame.Months) # 增加月线cerebro.addstrategy(St, multiargs.multi)cerebro.run(stdstatsFalse, runonceFalse)if args.plot:cerebro.plot(stylebar)def parse_args():parser argparse.ArgumentParser(formatter_classargparse.ArgumentDefaultsHelpFormatter,descriptionSample for pivot point and cross plotting)parser.add_argument(--data, requiredFalse,default./datas/2005-2006-day-001.txt,helpData to be read in)parser.add_argument(--multi, requiredFalse, actionstore_true,helpCouple all lines of the indicator)parser.add_argument(--plot, requiredFalse, actionstore_true,help(Plot the result))return parser.parse_args()if __name__ __main__:runstrat() 允许参数说明 python ./mixing-timeframes.py --help usage: mixing-timeframes.py [-h] [--data DATA] [--multi] [--plot]Sample for pivot point and cross plottingoptional arguments:-h, --help show this help message and exit--data DATA Data to be read in (default: ./datas/2005-2006-day-001.txt)--multi Couple all lines of the indicator (default: False)--plot Plot the result (default: False)可以看到日线、周线和月线三个周期的数据在cerebro 通过init中Indicator的初始化在next中打印数据长度数据和signal执行结果 3. 修改为不用args参数 在jupter中可以执行 from __future__ import (absolute_import, division, print_function,unicode_literals)import backtrader as bt import backtrader.feeds as btfeeds import backtrader.indicators as btind import backtrader.utils.flushfile%matplotlib inlineclass St(bt.Strategy):params dict(multiTrue)def __init__(self):self.pp pp btind.PivotPoint(self.data1)pp.plotinfo.plot False # deactivate plottingif self.p.multi:pp1 pp() # couple the entire indicatorsself.sellsignal self.data0.close pp1.s1else:self.sellsignal self.data0.close pp.s1()def next(self):txt ,.join([%04d % len(self),%04d % len(self.data0),%04d % len(self.data1),self.data.datetime.date(0).isoformat(),%.2f % self.data0.close[0],%.2f % self.pp.s1[0],%.2f % self.sellsignal[0]])#print(txt)def runstrat(args_plot):#cerebro bt.Cerebro()#data btfeeds.BacktraderCSVData(datanameargs.data)cerebro bt.Cerebro()stock_hfq_df get_code(000858) start_date datetime.datetime(2020, 1, 1) # 回测开始时间end_date datetime.datetime(2020, 12, 31) # 回测结束时间data bt.feeds.PandasData(datanamestock_hfq_df, fromdatestart_date, todateend_date) # 加载数据# Add the Data Feed to Cerebrocerebro.adddata(data)cerebro.resampledata(data, timeframebt.TimeFrame.Weeks)cerebro.resampledata(data, timeframebt.TimeFrame.Months)#cerebro.addstrategy(St, multiargs.multi)cerebro.addstrategy(St, multiTrue)cerebro.run(stdstatsFalse, runonceFalse)if args_plot:cerebro.plot(iplotFalse,stylebar)if __name__ __main__:args_plot Truerunstrat(args_plot)执行效果 4.Indicator Reference Indicator 参考说明参数方法太多了随用随学吧。
http://www.hkea.cn/news/14571495/

相关文章:

  • 途牛网站建设网络广告投放流程的第一步要做
  • 个人网站怎么做视频培训h5网页设计
  • 深圳做手机网站设计修改wordpress的登陆地址
  • 织梦cms网站迁移电销公司排名前十
  • 专业的网站制作正规公司北太平庄网站建设
  • 兴宁网站建设wordpress4.8中文版
  • dede装修网站模板制作图片的app免费
  • 璧山集团网站建设加工企业网站这么做
  • 常用来做网站首页的文件名快速排名方案
  • 上海网站开发门户网站建设系统
  • 要加强网站内容建设有没有免费的微网站
  • 建设银行平潭招聘网站网站建设的机构
  • 石家庄网站设计工作室招聘网站建设的目的
  • 做黄图网站接广告好赚吗海外推广营销
  • 网站项目开发案国外免费logo设计网站
  • wordpress网站如何播放视频如何查询网站是不是asp做的
  • 惠州网站建设学校建设部网站燃气管理部门
  • 安微省建设厅田网站wordpress首页文章带图
  • 建设行业的门户网站常州建设局下属网站
  • 媒体135网站湖北省建设银行网站6
  • 南山网站建设哪家好做贷款网站犯法
  • 一个公司备案两个网站网址大全2345色综合导航
  • 做网站来钱快微信营销平台
  • 东莞关键词优化代理德州网站优化
  • 如何做棋牌网站有没有做英语题的网站
  • 安徽网站建设外贸丽水专业网站建设价格
  • 国内男女直接做的视频网站wordpress和apache
  • 免费企业信息查询网站wordpress阅读主题
  • 要怎么做网站安顺做网站的公司
  • 房建设计图网站如何为wordpress加评论