天道酬勤,学无止境

backtrader

Backtrader 错误:“DataFrame”对象没有“setenvironment”属性(Backtrader error: 'DataFrame' object has no attribute 'setenvironment')

问题 我是 backtrader 的新手,我有一个大问题。 我想开始我的策略(只是一个简单的 GoldenCross 策略)。 这个 GoldenCross.py 脚本如下所示: import math import backtrader as bt class GoldenCross(bt.Strategy): params = (("fast", 50), ("slow", 200), ("order percentage", 0.95), ("ticker", "AAPL")) def __init__(self): self.fast_moving_average = self.bt.indicators.SmoothedMovingAverage( self.data.close, period=self.p.fast, plotname="50 day moving average") self.slow_moving_average = self.bt.indicators.SmoothedMovingAverage( self.data.close, period=self.p.slow, plotname="200 day moving average") self.crossover = self.bt.indicators.crossover(self

2021-10-29 23:43:49    分类:技术分享    python   feed   backtrader

Backtrader error: 'DataFrame' object has no attribute 'setenvironment'

I am new to backtrader, and I have a big problem. I want to start my strategy (just a simple GoldenCross strategy). This GoldenCross.py Script looks like this: import math import backtrader as bt class GoldenCross(bt.Strategy): params = (("fast", 50), ("slow", 200), ("order percentage", 0.95), ("ticker", "AAPL")) def __init__(self): self.fast_moving_average = self.bt.indicators.SmoothedMovingAverage( self.data.close, period=self.p.fast, plotname="50 day moving average") self.slow_moving_average = self.bt.indicators.SmoothedMovingAverage( self.data.close, period=self.p.slow, plotname="200 day

2021-10-24 04:18:36    分类:问答    python   feed   backtrader