分析你的策略

R 的金融交易

Ilya Kipnis

Professional Quantitative Analyst and R programmer

我們的策略

  • 買進條件:
    • 50 日移動平均 > 200 日移動平均
    • 且 dvo < 20
  • 賣出條件:
    • 50 日移動平均 < 200 日移動平均
    • 或 dvo > 80
R 的金融交易

執行你的策略

套用你的策略

applyStrategy(strategy = strategy.st, 
              portfolios = portfolio.st)

更新投資組合

updatePortf(portfolio.st)
daterange <- time(getPortfolio(portfolio.st)$summary)[-1]

更新帳戶

updateAcct(account.st, daterange)
updateEndEq(account.st)
R 的金融交易
tStats  <- tradeStats(Portfolios = portfolio.st)
tStats
    Portfolio    Symbol    Num.Txns    Num.Trades    Net.Trading.PL    
LQD  firstStrat    LQD       382          156           25681.09     
     Avg.Trade.PL    Med.Trade.PL    Largest.Winner   Largest.Loser   
LQD   164.6223      363.0143         2981.424        -7012.523          
   Gross.Profits    Gross.Losses   Std.Dev.Trade.PL  Percent.Positive      
LQD   77251.33      -51570.24        1174.442          66.66667           
    Percent.Negative   Profit.Factor   Avg.Win.Trade   Med.Win.Trade  
LQD    32.69231           1.497983        742.8012         624.5683        
    Avg.Losing.Trade  Med.Losing.Trade   Avg.Daily.PL   Med.Daily.PL   
LQD     -1011.181        -660.7456          164.6223       363.0143     
     Std.Dev.Daily.PL  Ann.Sharpe   Max.Drawdown   Profit.To.Max.Draw    
LQD         1174.442        2.225141     -10625.62           2.416903           
    Avg.WinLoss.Ratio    Med.WinLoss.Ratio     Max.Equity   Min.Equity     
LQD         0.7345877            0.9452477      27567.98    -1550.332      
    End.Equity
LQD    25681.09
R 的金融交易

交易系統特性

  • 以移動平均/趨勢訊號為基礎的系統
    • 高勝負比(大於 1)
    • 低勝率(小於 50%)
  • 以震盪/均值回歸訊號為基礎的系統:
    • 高勝率(大於 50%)
    • 低勝負比(小於 1)
R 的金融交易

一起來練習吧!

R 的金融交易

Preparing Video For Download...