Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 13.114% Drawdown 2.900% Expectancy 0 Net Profit 0% Sharpe Ratio 1.686 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.024 Beta 0.771 Annual Standard Deviation 0.052 Annual Variance 0.003 Information Ratio -2.113 Tracking Error 0.027 Treynor Ratio 0.113 Total Fees $1.00 |
# # QuantConnect Basic Template: # Fundamentals to using a QuantConnect algorithm. # # You can view the QCAlgorithm base class on Github: # https://github.com/QuantConnect/Lean/tree/master/Algorithm # import numpy as np class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): # Set the cash we'd like to use for our backtest # This is ignored in live trading self.SetCash(5000) # Start and end dates for the backtest. # These are ignored in live trading. self.SetStartDate(2017,1,1) self.SetEndDate(2017,6,1) # Add assets you'd like to see self.AddForex("EURUSD", Resolution.Minute), self.AddForex("GBPUSD", Resolution.Minute), self.AddForex("EURGBP", Resolution.Minute) self.slow = self.EMA('EURUSD', 6, Resolution.Daily) self.fast = self.EMA('EURUSD', 15, Resolution.Daily) stockPlot = Chart('Trade Plot') # On the Trade Plotter Chart we want 3 series: trades and price: stockPlot.AddSeries(Series('EURUSD', SeriesType.Line, 0)) self.AddChart(stockPlot) def OnData(self, data): holdings = self.Portfolio["EURUSD"].Quantity if holdings <= 0: if self.fast.Current.Value > self.slow.Current.Value: # The Securities property is a dictionary of Security objects. # Each asset (equity, forex pair etc) in your algorithm has a security object. # All the models for a security live on these objects: e.g. Securities["IBM"]. # FeeModel or Securities["IBM"].Price. # Portfolio is a dictionary of SecurityHolding classes. # These classes track the individual portfolio items profit and # losses, fees and quantity held. e.g. Portfolio["IBM"].LastTradeProfit. self.Log("BUY >> {0}".format(self.Securities["EURUSD"].Price)) self.SetHoldings("SPY", 1.0)