20170620 量化:BT回溯库

发现一个做回测的库挺方便的,记下来

http://pmorissette.github.io/bt/index.html#what-is-bt

其中比较难的地方是algos这个类,

class Algo(object):

"""
Algos are used to modularize strategy logic so that strategy logic becomes
modular, composable, more testable and less error prone. Basically, the
Algo should follow the unix philosophy - do one thing well.

In practice, algos are simply a function that receives one argument, the
Strategy (refered to as target) and are expected to return a bool.

When some state preservation is necessary between calls, the Algo
object can be used (this object). The __call___ method should be
implemented and logic defined therein to mimic a function call. A
simple function may also be used if no state preservation is neceesary.

Args:
    * name (str): Algo name

"""

def __init__(self, name=None):
    self._name = name

@property
def name(self):
    """
    Algo name.
    """
    if self._name is None:
        self._name = self.__class__.__name__
    return self._name

def __call__(self, target):
    raise NotImplementedError("%s not implemented!" % self.name)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,727评论 2 45
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,796评论 19 139
  • 目录 第一章:作诗赛崭露头角 第二章:才华横溢墨公子 第三章:藏龙卧虎一条虫 第四章:相府有女唤石柔 第五章:病秧...
    smile若一阅读 3,097评论 5 1
  • 二十五岁,感情生活一张白纸。 怎么一转眼就到了大家都在催你找男朋友的年纪了。男朋友真的有这么难找吗?我真的有这么差...
    金融界的艺术生阅读 1,690评论 0 1
  • show processlist找到死锁的进程编号KILL 这个进程的编号如果有多个死锁,请将他们全部KILL
    NowisBlank啦阅读 3,698评论 0 0