Overall Statistics |
Total Trades 352 Average Win 0.38% Average Loss -0.29% Compounding Annual Return -0.284% Drawdown 7.200% Expectancy -0.012 Net Profit -0.805% Sharpe Ratio -0.038 Loss Rate 57% Win Rate 43% Profit-Loss Ratio 1.29 Alpha 0.012 Beta -0.947 Annual Standard Deviation 0.035 Annual Variance 0.001 Information Ratio -0.429 Tracking Error 0.035 Treynor Ratio 0.001 Total Fees $14.08 |
from NodaTime import DateTimeZone from datetime import datetime import decimal as d import pandas as pd class ForexVolumeAlgorithm(QCAlgorithm): def Initialize(self): self.SetCash(2000) self.SetStartDate(2015,1,01) self.SetEndDate(2017,11,01) self.syl = self.AddForex("EURUSD", Resolution.Hour, Market.FXCM).Symbol self.Securities[self.syl].FeeModel = FxcmTransactionModel() self.SetTimeZone(DateTimeZone.Utc) self.vol_syl = self.AddData[FxcmVolume]("EURUSD_Vol", Resolution.Hour).Symbol self.macd = self.MACD(self.syl, 12, 26, 9, MovingAverageType.Exponential, Resolution.Hour) self.vol_bb = self.BB(self.vol_syl, 30, 2, MovingAverageType.Exponential, Resolution.Hour) def OnData(self, data): if self.macd.IsReady and self.vol_bb.IsReady: if not self.vol_syl in data: return volume = data[self.vol_syl].Volume if not self.Portfolio.Invested: if self.macd.Current.Value > self.macd.Signal.Current.Value and volume > self.vol_bb.UpperBand.Current.Value: self.Buy(self.syl, 1000) if self.Portfolio.Invested: if self.macd.Current.Value < self.macd.Signal.Current.Value and volume > self.vol_bb.UpperBand.Current.Value: self.Liquidate()