Overall Statistics
Total Trades
8
Average Win
4.60%
Average Loss
-5.36%
Compounding Annual Return
221.679%
Drawdown
8.900%
Expectancy
0.240
Net Profit
7.296%
Sharpe Ratio
2.232
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
0.86
Alpha
1.493
Beta
0.494
Annual Standard Deviation
0.439
Annual Variance
0.192
Information Ratio
4.593
Tracking Error
0.44
Treynor Ratio
1.98
Total Fees
$63.82
#
#   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(2001,3,9)	#Friday
		self.SetEndDate(2001,4,1)
		
		# Add assets you'd like to see
		self.csco = self.AddEquity("CSCO", Resolution.Daily).Symbol
		self.intc = self.AddEquity("INTC", Resolution.Daily).Symbol
		self.cien = self.AddEquity("CIEN", Resolution.Daily).Symbol
		self.sunw = self.AddEquity("SUNW", Resolution.Daily).Symbol
		self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol
		self.qcom = self.AddEquity("QCOM", Resolution.Daily).Symbol
		
		self.count = 1
		

	def OnData(self, slice):
		if self.count == 1:
			self.SetHoldings(self.csco, 0.5)
			self.SetHoldings(self.intc, -0.5)
		elif self.count == 6:
			self.Liquidate(self.csco)
			self.Liquidate(self.intc)
			self.SetHoldings(self.cien, 0.5)
			self.SetHoldings(self.sunw, -0.5)
		elif self.count == 11:
			self.Liquidate(self.cien)
			self.Liquidate(self.sunw)
			self.SetHoldings(self.spy, 0.5)
			self.SetHoldings(self.qcom, -0.5)
		self.count+=1