backtesting.py:Python中的回测交易策略 源码
回测 使用Python回测交易策略。 安装 $ pip install backtesting 用法 from backtesting import Backtest , Strategy from backtesting . lib import crossover from backtesting . test import SMA , GOOG class SmaCross ( Strategy ): def init ( self ): price = self . data . Close self . ma1 = self . I ( SMA , price , 10 ) self . ma2 = self . I ( SMA , price , 20 ) def next ( self ): if crossover ( self . ma1 , self . ma2 ): self . buy () elif crossover ( self . m
用户评论