admin管理员组文章数量:1130349
AD:(本人录制的backtrader视频课程,大家多多支持哦~ https://edu.csdn/course/detail/9040)
无意中发现了一个巨牛的人工智能教程,忍不住分享一下给大家。教程不仅是零基础,通俗易懂,而且非常风趣幽默,像看小说一样!觉得太牛了,所以分享给大家。教程链接:https://www.cbedai/qtlyx
上次我们分析了回测平台大的框架,这次着重介绍一下策略的编写。先来看一个策略的类,上次说了,一个策略其实被一个类完全描述了。
# Create a Stratey
class TestStrategy(bt.Strategy):
def log(self, txt, dt=None):
''' Logging function fot this strategy'''
dt = dt or self.datas[0].datetime.date(0)
print('%s, %s' % (dt.isoformat(), txt))
def __init__(self):
# Keep a reference to the "close" line in the data[0] dataseries
self.dataclose = self.datas[0].close
def next(self):
# Simply log the closing price of the series from the reference
self.lAD:(本人录制的backtrader视频课程,大家多多支持哦~ https://edu.csdn/course/detail/9040)
无意中发现了一个巨牛的人工智能教程,忍不住分享一下给大家。教程不仅是零基础,通俗易懂,而且非常风趣幽默,像看小说一样!觉得太牛了,所以分享给大家。教程链接:https://www.cbedai/qtlyx
上次我们分析了回测平台大的框架,这次着重介绍一下策略的编写。先来看一个策略的类,上次说了,一个策略其实被一个类完全描述了。
# Create a Stratey
class TestStrategy(bt.Strategy):
def log(self, txt, dt=None):
''' Logging function fot this strategy'''
dt = dt or self.datas[0].datetime.date(0)
print('%s, %s' % (dt.isoformat(), txt))
def __init__(self):
# Keep a reference to the "close" line in the data[0] dataseries
self.dataclose = self.datas[0].close
def next(self):
# Simply log the closing price of the series from the reference
self.l本文标签: 教程平台backtraderStrategy
版权声明:本文标题:Backtrader量化平台教程(二):Strategy类 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1754916328a2741336.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论