Beispiel #1
0
from wtpy import WtEngine,EngineType
from Strategies.DualThrust import StraDualThrust

from ConsoleIdxWriter import ConsoleIdxWriter

if __name__ == "__main__":
    #创建一个运行环境,并加入策略
    env = WtEngine(EngineType.ET_CTA)
    env.init('./common/', "config.json")
    
    straInfo = StraDualThrust(name='pydt_au', code="SHFE.au.HOT", barCnt=50, period="m5", days=30, k1=0.2, k2=0.2, isForStk=False)
    env.add_cta_strategy(straInfo)
    
    idxWriter = ConsoleIdxWriter()
    env.set_writer(idxWriter)

    env.run()

    kw = input('press any key to exit\n')
Beispiel #2
0
from wtpy import WtBtEngine,EngineType
from Strategies.DualThrust import StraDualThrust
from wtpy import WtBtAnalyst

if __name__ == "__main__":
    #创建一个运行环境,并加入策略
    engine = WtBtEngine(EngineType.ET_CTA)
    engine.init(folder='./common/', cfgfile="configbt.json", commfile="stk_comms.json", contractfile="stocks.json")
    engine.configBacktest(201901010930,201912151500)
    engine.configBTStorage(mode="csv", path="./storage/")
    engine.commitBTConfig()
    
    straInfo = StraDualThrust(name='pydt_SH600000', code="SSE.600000", barCnt=50, period="d1", days=30, k1=0.1, k2=0.1, isForStk=True)
    engine.set_cta_strategy(straInfo)

    engine.run_backtest()

    #绩效分析
    analyst = WtBtAnalyst()
    analyst.add_strategy("pydt_SH600000", folder="./outputs_bt/pydt_SH600000/", init_capital=5000, rf=0.02, annual_trading_days=240)
    analyst.run()

    kw = input('press any key to exit\n')
    engine.release_backtest()
Beispiel #3
0
from Strategies.DualThrust import StraDualThrust

# from Strategies.XIM import XIM

if __name__ == "__main__":
    #创建一个运行环境,并加入策略
    engine = WtBtEngine(EngineType.ET_CTA)
    engine.init('./common/', "configbt.json")
    engine.configBacktest(201909100930, 201912011500)
    engine.configBTStorage(mode="csv", path="./storage/")
    engine.commitBTConfig()

    straInfo = StraDualThrust(name='pydt_IF',
                              code="CFFEX.IF.HOT",
                              barCnt=50,
                              period="m5",
                              days=30,
                              k1=0.1,
                              k2=0.1,
                              isForStk=False)
    engine.set_cta_strategy(straInfo)

    engine.run_backtest()

    analyst = WtBtAnalyst()
    analyst.add_strategy("pydt_IF",
                         folder="./outputs_bt/pydt_IF/",
                         init_capital=500000,
                         rf=0.02,
                         annual_trading_days=240)
    analyst.run()
Beispiel #4
0
from wtpy import WtBtEngine,EngineType
from Strategies.DualThrust import StraDualThrust
from wtpy.apps import WtBtAnalyst

if __name__ == "__main__":
    #创建一个运行环境,并加入策略
    engine = WtBtEngine(EngineType.ET_CTA)
    engine.init(folder='./common/', cfgfile="configbt.json", commfile="stk_comms.json", contractfile="stocks.json")
    engine.configBacktest(201901010930,201912151500)
    engine.configBTStorage(mode="csv", path="./storage/")
    engine.commitBTConfig()
    
    straInfo = StraDualThrust(name='pydt_SH510300', code="SSE.510300", barCnt=50, period="m1", days=30, k1=0.1, k2=0.1, isForStk=False)
    engine.set_cta_strategy(straInfo)

    engine.run_backtest()

    #绩效分析
    analyst = WtBtAnalyst()
    analyst.add_strategy("pydt_SH510300", folder="./outputs_bt/pydt_SH510300/", init_capital=5000, rf=0.02, annual_trading_days=240)
    analyst.run()

    kw = input('press any key to exit\n')
    engine.release_backtest()