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

深圳做网站企业女教师遭网课入侵视频大全

深圳做网站企业,女教师遭网课入侵视频大全,百度网页入口,物业管理Backtrader 文档学习-Platform Concepts 1.开始之前 导入backtrader #xff0c;以及backtrader 的指示器、数据反馈的模块 。 import backtrader as bt import backtrader.indicators as btind import backtrader.feeds as btfeeds看看btind模块下有什么方法和属性#x…Backtrader 文档学习-Platform Concepts 1.开始之前 导入backtrader 以及backtrader 的指示器、数据反馈的模块 。 import backtrader as bt import backtrader.indicators as btind import backtrader.feeds as btfeeds看看btind模块下有什么方法和属性 obj_str for i in dir(btind):if i[:1] ! _ :obj_str i , print(obj_str)指示器中的指标函数很多方法属性如下 ADX,ADXR,AO,APO,ATR,AbsPriceOsc,AbsolutePriceOscillator,AccDeOsc,AccelerationDecelerationOscillator,Accum,AdaptiveMovingAverage,AdaptiveMovingAverageEnvelope,AdaptiveMovingAverageOsc,AdaptiveMovingAverageOscillator,All,AllN,And,Any,AnyN,ApplyN,ArithmeticMean,AroonDown,AroonIndicator,AroonOsc,AroonOscillator,AroonUp,AroonUpDown,AroonUpDownOsc,AroonUpDownOscillator,Average,AverageDirectionalMovementIndex,AverageDirectionalMovementIndexRating,AverageTrueRange,AverageWeighted,AwesomeOsc,AwesomeOscillator,BBands,BaseApplyN,BollingerBands,BollingerBandsPct,CCI,Cmp,CmpEx,CointN,CommodityChannelIndex,CrossDown,CrossOver,CrossUp,CumSum,CumulativeSum,DEMA,DEMAEnvelope,DEMAOsc,DEMAOscillator,DI,DM,DMA,DMAEnvelope,DMAOsc,DMAOscillator,DMI,DPO,DV2,DemarkPivotPoint,DetrendedPriceOscillator,DicksonMA,DicksonMAEnvelope,DicksonMAOsc,DicksonMAOscillator,DicksonMovingAverage,DicksonMovingAverageEnvelope,DicksonMovingAverageOsc,DicksonMovingAverageOscillator,DirectionalIndicator,DirectionalMovement,DirectionalMovementIndex,DivByZero,DivZeroByZero,DoubleExponentialMovingAverage,DoubleExponentialMovingAverageEnvelope,DoubleExponentialMovingAverageOsc,DoubleExponentialMovingAverageOscillator,DownDay,DownDayBool,DownMove,EC,ECEnvelope,ECOsc,ECOscillator,EMA,EMAEnvelope,EMAOsc,EMAOscillator,Envelope,EnvelopeMixIn,ErrorCorrecting,ErrorCorrectingEnvelope,ErrorCorrectingOsc,ErrorCorrectingOscillator,ExpSmoothing,ExpSmoothingDynamic,ExponentialMovingAverage,ExponentialMovingAverageEnvelope,ExponentialMovingAverageOsc,ExponentialMovingAverageOscillator,ExponentialSmoothing,ExponentialSmoothingDynamic,FibonacciPivotPoint,FindFirstIndex,FindFirstIndexHighest,FindFirstIndexLowest,FindLastIndex,FindLastIndexHighest,FindLastIndexLowest,HMA,HMAEnvelope,HMAOsc,HMAOscillator,HeikinAshi,Highest,HullMA,HullMAEnvelope,HullMAOsc,HullMAOscillator,HullMovingAverage,HullMovingAverageEnvelope,HullMovingAverageOsc,HullMovingAverageOscillator,Hurst,HurstExponent,Ichimoku,If,Indicator,KAMA,KAMAEnvelope,KAMAOsc,KAMAOscillator,KST,KnowSureThing,LAGF,LRSI,LaguerreFilter,LaguerreRSI,LineActions,List,Logic,Lowest,MACD,MACDHisto,MACDHistogram,MAXINT,Max,MaxN,Mean,MeanDev,MeanDeviation,MetaMovAvBase,Min,MinN,MinusDI,MinusDirectionalIndicator,ModifiedMovingAverage,ModifiedMovingAverageEnvelope,ModifiedMovingAverageOsc,ModifiedMovingAverageOscillator,Momentum,MomentumOsc,MomentumOscillator,MovAv,MovingAverage,MovingAverageAdaptive,MovingAverageAdaptiveEnvelope,MovingAverageAdaptiveOsc,MovingAverageAdaptiveOscillator,MovingAverageBase,MovingAverageDoubleExponential,MovingAverageDoubleExponentialEnvelope,MovingAverageDoubleExponentialOsc,MovingAverageDoubleExponentialOscillator,MovingAverageExponential,MovingAverageExponentialEnvelope,MovingAverageExponentialOsc,MovingAverageExponentialOscillator,MovingAverageSimple,MovingAverageSimpleEnvelope,MovingAverageSimpleOsc,MovingAverageSimpleOscillator,MovingAverageSmoothed,MovingAverageSmoothedEnvelope,MovingAverageSmoothedOsc,MovingAverageSmoothedOscillator,MovingAverageTripleExponential,MovingAverageTripleExponentialEnvelope,MovingAverageTripleExponentialOsc,MovingAverageTripleExponentialOscillator,MovingAverageWeighted,MovingAverageWeightedEnvelope,MovingAverageWeightedOsc,MovingAverageWeightedOscillator,MovingAverageWilder,MovingAverageWilderEnvelope,MovingAverageWilderOsc,MovingAverageWilderOscillator,MultiLogic,MultiLogicReduce,NZD,NonZeroDifference,OLS_BetaN,OLS_Slope_InterceptN,OLS_TransformationN,OperationN,Or,Oscillator,OscillatorMixIn,PGO,PPO,PPOShort,PSAR,ParabolicSAR,PctChange,PctRank,PercPriceOsc,PercPriceOscShort,PercentChange,PercentRank,PercentagePriceOscillator,PercentagePriceOscillatorShort,PeriodN,PivotPoint,PlusDI,PlusDirectionalIndicator,PrettyGoodOsc,PrettyGoodOscillator,PriceOsc,PriceOscillator,RMI,ROC,ROC100,RSI,RSI_Cutler,RSI_EMA,RSI_SMA,RSI_SMMA,RSI_Safe,RSI_Wilder,RateOfChange,RateOfChange100,Reduce,ReduceN,RelativeMomentumIndex,RelativeStrengthIndex,SMA,SMAEnvelope,SMAOsc,SMAOscillator,SMMA,SMMAEnvelope,SMMAOsc,SMMAOscillator,SimpleMovingAverage,SimpleMovingAverageEnvelope,SimpleMovingAverageOsc,SimpleMovingAverageOscillator,SmoothedMovingAverage,SmoothedMovingAverageEnvelope,SmoothedMovingAverageOsc,SmoothedMovingAverageOscillator,StandardDeviation,StdDev,Stochastic,StochasticFast,StochasticFull,StochasticSlow,Sum,SumN,TEMA,TEMAEnvelope,TEMAOsc,TEMAOscillator,TR,TRIX,TSI,TripleExponentialMovingAverage,TripleExponentialMovingAverageEnvelope,TripleExponentialMovingAverageOsc,TripleExponentialMovingAverageOscillator,Trix,TrixSignal,TrueHigh,TrueLow,TrueRange,TrueStrengthIndicator,UltimateOscillator,UpDay,UpDayBool,UpMove,Vortex,WMA,WMAEnvelope,WMAOsc,WMAOscillator,WeightedAverage,WeightedMovingAverage,WeightedMovingAverageEnvelope,WeightedMovingAverageOsc,WeightedMovingAverageOscillator,WilderMA,WilderMAEnvelope,WilderMAOsc,WilderMAOscillator,WilliamsAD,WilliamsR,ZLEMA,ZLEMAEnvelope,ZLEMAOsc,ZLEMAOscillator,ZLInd,ZLIndEnvelope,ZLIndOsc,ZLIndOscillator,ZLIndicator,ZLIndicatorEnvelope,ZLIndicatorOsc,ZLIndicatorOscillator,ZeroLagEma,ZeroLagEmaEnvelope,ZeroLagEmaOsc,ZeroLagEmaOscillator,ZeroLagExponentialMovingAverage,ZeroLagExponentialMovingAverageEnvelope,ZeroLagExponentialMovingAverageOsc,ZeroLagExponentialMovingAverageOscillator,ZeroLagIndicator,ZeroLagIndicatorEnvelope,ZeroLagIndicatorOsc,ZeroLagIndicatorOscillator,absolute_import,accdecoscillator,alias,aroon,atr,awesomeoscillator,basicops,bollinger,bt,cci,cmp,contrib,crossover,dema,deviation,directionalmove,division,dma,dpo,dv2,ema,envelope,functools,haD,haDelta,hadelta,heikinashi,hma,hurst,ichimoku,kama,kst,linename,lrsi,mabase,macd,map,math,module,momentum,movav,movname,newaliases,newcls,newclsdct,newclsdoc,newclsname,ols,operator,oscillator,percentchange,percentrank,pivotpoint,prettygoodoscillator,priceoscillator,print_function,psar,range,rmi,rsi,sma,smma,stochastic,suffix,sys,trix,tsi,ultimateoscillator,unicode_literals,williams,with_metaclass,wma,zlema,zlind,也可以直接通过bt导入下面的模块feeds indicators import backtrader as bt thefeed bt.feeds.OneOfTheFeeds(...) theind bt.indicators.SimpleMovingAverage(...)2.数据读入-无处不在 所有的策略都基于数据平台端用户不用考虑如何接收数据。 Data Feeds are automagically provided member variables to the strategy in the form of an array and shortcuts to the array positions 数据源是以数组的形式或者对数组位置快捷访问的方式提供给strategy策略作为成员变量使用的。 这句话需要好好理解。 数组的形式 self.datas[0].close 数组位置快捷访问self.data0.close class MyStrategy(bt.Strategy):params dict(period20)def __init__(self):sma btind.SimpleMovingAverage(self.datas[0], periodself.params.period)print(sma)# Keep a reference to the close line in the data[0] dataseriesself.dataclose self.datas[0].closeself.dataclosetest self.data0.closeprint(-* 20,close,- * 20 )print(self.dataclose[0])print(self.dataclosetest[0]) 执行结果 sma 的数据类型backtrader.indicators.sma.SimpleMovingAverage backtrader.indicators.sma.SimpleMovingAverage object at 0x7f616bd7c820 -------------------- close -------------------- 133.01 133.01 Data Feeds get added to the platform and they will show up inside the strategy in the sequential order in which they were added to the system. SQL语句按日期排序不论是正序还是逆序desc 到BackTrader中都是按时间倒序排列[0]是最后的日期。 3.快捷访问数据 self.datas数组项可以通过自动成员变量直接访问 self.data targets self.datas[0] self.dataX targets self.datas[X]下面好好测试一下BackTrader的数据访问数据之间的关系。 #class backtrader.linebuffer.LineBuffer print(type(cerebro.datas[0].close))#class backtrader.feeds.pandafeed.PandasData print(type(cerebro.datas[0]))#class list print(type(cerebro.datas))# (close, low, high, open, volume, openinterest, datetime) print(cerebro.datas[0].getlinealiases())结果如下 class backtrader.linebuffer.LineBuffer class backtrader.feeds.pandafeed.PandasData class list (close, low, high, open, volume, openinterest, datetime)说明 1、cerebro.datas数据集的类型是 class ‘list’ 对应载入cerebro的股票数据可以是多个股票就是股票的集合。2、cerebro.datas[0]是class ‘backtrader.feeds.pandafeed.PandasData’其实与dataframe类似包括以下列(‘close’, ‘low’, ‘high’, ‘open’, ‘volume’, ‘openinterest’, ‘datetime’)的集合。 -3、cerebro.datas[0].close就是dataframe的一列数据BackTrader称之为Line class ‘backtrader.linebuffer.LineBuffer’ 。4、cerebro.datas[0].close[0] 就是访问到数据的元素实际数据值。5、cerebro.datas[0]都是按时间顺序逆序的第一个元素index是0 下一个是-1 以此类推。6、时间序列必须用内置方法处理 print(cerebro.datas[0].datetime[0]) print(pd.to_datetime(cerebro.datas[0].datetime[0],units)) print(bt.num2date(cerebro.datas[0].datetime[0]))结果如下 737424.0 1970-01-09 12:50:24 2019-12-31 00:00:00直接访问datetime列 是浮点数。 开始用pd.to_datetime 函数转换的时间是1970年迷惑很长时间。 重要必须用自带的函数转换时间 bt.num2date 4.默认数据载入 class MyStrategy(bt.Strategy):params dict(period20)def __init__(self):sma btind.SimpleMovingAverage(periodself.params.period)...self.data has been completely removed from the invocation of SimpleMovingAverage. If this is done, the indicator (in this case the SimpleMovingAverage) receives the first data of the object in which is being created (the Strategy), which is self.data (aka self.data0 or self.datas[0]) 默认使用的self是什么 如果只有一个数据源cerebro只载入一个股票数据不用显式指定系统会缺省使用self.datas[0]self.dataself.data0self.datas[0] 也就是第一个加入的数据源 。所以说self.data 就没有显式出现在调用SMA指示器 。 如果有多个载入数据还是注明好清晰可读。 5. 一切都是数据载入 class MyStrategy(bt.Strategy):#定义策略全局参数params dict(period120, period225, period310, period4)def __init__(self):# 使用SMA指示器载入datas[0]使用参数1sma1 btind.SimpleMovingAverage(self.datas[0], periodself.p.period1)# This 2nd Moving Average operates using sma1 as data# 使用第一个SMA指示器数据再次作为SMA的数据载入使用参数2sma2 btind.SimpleMovingAverage(sma1, periodself.p.period2)# New data created via arithmetic operation# 随意的计算 something sma2 - sma1 self.data.close# This 3rd Moving Average operates using something as data# 随意计算的结果作为第三次SMA数据载入使用参数3sma3 btind.SimpleMovingAverage(something, periodself.p.period3)# Comparison operators work too ...# 比较后取大值 有点疑问 greater sma3 sma1# Pointless Moving Average of True/False values but valid# This 4th Moving Average operates using greater as data# 比较后结果第四次载入SMA指示器使用参数4sma3 btind.SimpleMovingAverage(greater, periodself.p.period4)...总而言之所有的数据转换变化后都可以作为数据载入再次进行运算。 6. 参数 在backtrader中所有的类都按照如下方法来使用参数 1、声明一个带有缺省值的参数作为类的一个属性元组或者字典结构。 2、关键字类型参数kwargs会扫描匹配的参数将值赋值给对应的参数完成后从kwargs删除。 3、这些参数都可以在类实例中通过访问成员变量self.params可以简写为self.p来使用。 使用元组 tuple class MyStrategy(bt.Strategy):params ((period, 20),)def __init__(self):sma btind.SimpleMovingAverage(self.data, periodself.p.period)使用字典dict class MyStrategy(bt.Strategy):params dict(period20)def __init__(self):sma btind.SimpleMovingAverage(self.data, periodself.p.period)7.Lines 关键的概念 从使用用户通常是strategy的角度来说就是包括一个或多个line这些line是一系列的数据在图中可以形成一条线line。line是数组不是pd.series 没有index 。 class MyStrategy(bt.Strategy):params dict(period20)def __init__(self):self.movav btind.SimpleMovingAverage(self.data, periodself.p.period)def next(self):if self.movav.lines.sma[0] self.data.lines.close[0]:print(round(self.movav.lines.sma[0],2),self.data.lines.close[0],Simple Moving Average is greater than the closing price) 执行结果 83.34 74.4 Simple Moving Average is greater than the closing price 83.16 75.1 Simple Moving Average is greater than the closing price 83.01 76.6 Simple Moving Average is greater than the closing price 82.92 80.1 Simple Moving Average is greater than the closing price 82.82 79.64 Simple Moving Average is greater than the closing price 82.69 78.52 Simple Moving Average is greater than the closing price 82.36 76.1 Simple Moving Average is greater than the closing price 81.87 74.28 Simple Moving Average is greater than the closing price ... ... self.movav:这个是一个SimpleMovingAverage的指标indicator本身就包含一个具有lines属性的sma。这里特殊注意一下计算SimpleMovingAverage使用的self.data没有指定具体Line的话,缺省用的是close价进行计算。 简单的方法访问lines xxx.lines 可以简化为 xxx.l xxx.lines.name可以简化为xxx.lines_name 一些复杂的对象也可以通过如下方法访问 self.data_name 等于 self.data.lines.name 如果有多个变量的话也可以self.data1_name 替代self.data1.lines.name 此外Line的名字也可以通过如下方式访问 self.data.close and self.movav.sma class MyStrategy(bt.Strategy):params dict(period20)def __init__(self):self.movav btind.SimpleMovingAverage(self.data, periodself.p.period)def next(self):# 数据集0 收盘价在110和120if (self.datas[0].close[0] 110.0) (self.datas[0].close[0] 120.0):print(bt.num2date(self.datas[0].datetime[0]),self.datas[0].close[0] 110.0)# 数据集1 收盘价在110和120 if self.datas[1].close[0] 9.0:print(bt.num2date(self.datas[1].datetime[0]),self.datas[1].close[0] 9.0)# 数据集SMA 收盘价在88和90if (self.movav.lines.sma[0] 88) (self.movav.sma[0] 90) :print(round(self.movav.lines.sma[0],2),self.movav.lines.sma[0] 88)print(self.movav.getlinealiases())#print(cerebro.datas[0].getlinealiases())结果如下 2018-04-18 00:00:00 self.datas[1].close[0] 9.0 2018-04-24 00:00:00 self.datas[1].close[0] 9.0 2018-04-25 00:00:00 self.datas[1].close[0] 9.0 2018-04-26 00:00:00 self.datas[1].close[0] 9.0 2019-04-09 00:00:00 self.datas[0].close[0] 110.0 88.78 self.movav.lines.sma[0] 88 (sma,) 89.64 self.movav.lines.sma[0] 88 (sma,) 2019-06-20 00:00:00 self.datas[0].close[0] 110.0 2019-06-21 00:00:00 self.datas[0].close[0] 110.0 2019-06-24 00:00:00 self.datas[0].close[0] 110.0 2019-06-25 00:00:00 self.datas[0].close[0] 110.0 2019-06-26 00:00:00 self.datas[0].close[0] 110.0 2019-06-27 00:00:00 self.datas[0].close[0] 110.0 2019-06-28 00:00:00 self.datas[0].close[0] 110.0 2019-07-24 00:00:00 self.datas[0].close[0] 110.0 2019-08-01 00:00:00 self.datas[0].close[0] 110.0 2019-08-02 00:00:00 self.datas[0].close[0] 110.0 2019-08-05 00:00:00 self.datas[0].close[0] 110.0 2019-08-07 00:00:00 self.datas[0].close[0] 110.0 2019-08-09 00:00:00 self.datas[0].close[0] 110.0需要好好说明一下 简写示例 if (self.movav.lines.sma[0] 88) (self.movav.sma[0] 90) : 多数据源 两种方式引用 self.movav.lines.sma[0] self.movav.sma[0] cerebro载入两个股票数据。 特别注意调用datas 有s self.datas[0].close[0] self.datas[0].close[0] self.datas[0].close[0] SMA指示器调用后是数组没有日期字段 开始也想增加打印日期 print(bt.num2date(self.movav.datetime[0]) 无日期 只有一列 print(self.movav.getlinealiases()) (sma,)未完待续
http://www.yutouwan.com/news/103220/

相关文章:

  • 网站备案链接地址龙岩网上通缉犯名单
  • 品牌网站建设搜搜磐石网络ui设计网站模板
  • 沧县网站制作价格什么是网络营销常见的手段有哪些
  • 苏州seo建站采集类淘宝客网站怎么做
  • 沧州哪家做网站好网站运营每天做啥工作
  • 北京高端网站设计公司网站图片优化器
  • 怎么创建免费自己的网站平台网站开发一般用哪个浏览器
  • 东坑做网站wordpress建站过时了
  • 网站适配手机怎么做网站内部建设和程序
  • 泉州模板自助建站全屏的翻页网站这么做
  • 专业的昆明网站建设微商代理0元0投入
  • 建立网站大约多少钱站长工具权重查询
  • 网站建设费用的会计分录株洲做网站多少钱
  • 厦门网站做的比较好wordpress免费英文主题
  • 网站添加微信支付桂林网站建设内容
  • 长春网站推广上海小程序开发合肥
  • 网站制作的付款方式wordpress网站地图生成
  • 桂林做手机网站软件开发平台开源
  • html 网站首页dede茶叶网站模板
  • 关于企业网站建设的请示乐辰网站建设
  • 本地常州网站建设上海市开办企业一窗网上服务
  • 网络策划就业前景wordpress哪种主页更利于seo
  • 深圳营销网站设计对于网站建设的意见和建议
  • 南京网站建设招聘怎么建立微信群
  • 我在某网站网站做代理重庆网站建设网站
  • 四川淘宝网站建设方案晋城做网站公司
  • 深圳市建设网站网站空间域名申请网站
  • 企联网站建设网站有哪些备案
  • 基于thinkphp网站制作提供手机自适应网站
  • 集运网站建设宁波seo排名优化培训