这两个文件用处都不大,而且源码写的都比较简单,一看就懂。
version.py 提供 backtrader 的版本号
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# backtrader 版本号
__version__ = '1.9.76.123'
# backtrader 版本号,元组格式
__btversion__ = tuple(int(x) for x in __version__.split('.')) errors.py 定义了一些错误类型
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# 从 from error import * 的时候,只导入下面两个类 BacktraderError 和 StrategySkipError
__all__ = ['BacktraderError', 'StrategySkipError']
# BacktraderError 类
class BacktraderError(Exception):
'''Base exception for all other exceptions'''
pass
# StrategySkipError,只有这个类在 cerebro 中用到了
class StrategySkipError(BacktraderError):
'''Requests the platform to skip this strategy for backtesting. To be
raised during the initialization (``__init__``) phase of the instance'''
pass
# ModuleImportError 类
class ModuleImportError(BacktraderError):
'''Raised if a class requests a module to be present to work and it cannot
be imported'''
def __init__(self, message, *args):
super(ModuleImportError, self).__init__(message)
self.args = args
# FromModuleImportError 类
class FromModuleImportError(ModuleImportError):
'''Raised if a class requests a module to be present to work and it cannot
be imported'''
def __init__(self, message, *args):
super(FromModuleImportError, self).__init__(message, *args)