学习backtrader框架(第一回)

backtrader的设计很新颖。

两个基础

1. lines

Data Feeds, Indicators and Strategies have lines.
A line is a succession of points that when joined together form this line. When talking about the markets, a Data Feed has usually the following set of points per day:
Open, High, Low, Close, Volume, OpenInterest
The series of “Open”s along time is a Line. And therefore a Data Feed has usually 6 lines.
If we also consider “DateTime” (which is the actual reference for a single point), we could count 7 lines.

backtraders 自己创造了个“线”的概念,数据是由 Open, High, Low, Close, Volume, OpenInterest 这6个元素构成,每个元素的序列就是一条“线”

DataFeeds, Indicators, Strategies 都有“线”。

2. index 0

backtrader的索引和python不同,索引0指向当前的数值,-1是倒数第二个数值。
之所以这样做,是方便在时间序列里获取当前的数值。我认为

其他方面

  1. system clock (backtrader立时)
    无论是回测或者实盘,都需要参考、计算历史数据。
    backtrader则把bar称之为system clock。也就是bar为backtrader交易世界里的时钟。
    bar,可以是1秒,1分,5分,10分之类。

  2. self.data[0].close 返回类型
    self.data[0].close 返回的是 close的line序列。

  3. 如何判断读取了多少根bar
    backtrader 并没有提供一个变量来更新读取了多根bar,它是通过len(self)来计算的。len(self)表示对象的个数。此处我不是十分明白其意

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值