Overall Statistics
Total Trades
29361
Average Win
0.22%
Average Loss
-0.16%
Compounding Annual Return
0.688%
Drawdown
40.100%
Expectancy
0.009
Net Profit
12.380%
Sharpe Ratio
0.099
Loss Rate
57%
Win Rate
43%
Profit-Loss Ratio
1.33
Alpha
-0.009
Beta
0.436
Annual Standard Deviation
0.12
Annual Variance
0.014
Information Ratio
-0.268
Tracking Error
0.133
Treynor Ratio
0.027
Total Fees
$56402.43
#
#   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(100000)
		
		# Start and end dates for the backtest.
		# These are ignored in live trading.
		self.SetStartDate(2000,6,1)
		self.SetEndDate(2017,6,1)
		
		# Add assets you'd like to see
		self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol
		self.gs = self.AddEquity("GS", Resolution.Daily).Symbol
		self.ms = self.AddEquity("MS", Resolution.Daily).Symbol
		self.msft = self.AddEquity("MSFT", Resolution.Daily).Symbol
		self.ibm = self.AddEquity("ibm", Resolution.Daily).Symbol
		self.gbp = self.AddForex("GBPUSD", Resolution.Daily).Symbol
		self.aud = self.AddForex("AUDUSD", Resolution.Daily).Symbol
		self.jpy = self.AddForex("USDJPY", Resolution.Daily).Symbol
		
		self.count = 1

		
	def OnData(self, slice):
		# Simple buy and hold template
		if self.count % 3 == 1:
			self.Liquidate()
			self.SetHoldings(self.spy, 0.2)
			self.SetHoldings(self.gs, 0.2)
			self.SetHoldings(self.ms, 0.2)
			self.SetHoldings(self.msft, 0.2)
			self.SetHoldings(self.ibm, 0.2)
		if self.count % 3 == 2:
			self.Liquidate()
			self.SetHoldings(self.gbp, -0.2)
			self.SetHoldings(self.aud, -0.2)
			self.SetHoldings(self.jpy, -0.2)
		if self.count % 3 == 0:
			self.Liquidate()
			self.SetHoldings(self.msft, 0.3)
			self.SetHoldings(self.ibm, 0.3)
		self.count += 1