Overall Statistics Total Trades1Average Win0%Average Loss0%Compounding Annual Return-13.528%Drawdown2.700%Expectancy0Net Profit0%Sharpe Ratio-1.466Loss Rate0%Win Rate0%Profit-Loss Ratio0Alpha-0.008Beta0.999Annual Standard Deviation0.09Annual Variance0.008Information Ratio-3.373Tracking Error0.002Treynor Ratio-0.131Total Fees\$2.02
```#
#   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 pandas as pd
import numpy as np
import talib

class BasicTemplateAlgorithm(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2017,8,1)

self.stocks = ["SPY","TQQQ"]
for s in self.stocks:

# History request using list of tickers
hist = self.History(self.stocks, 1000, Resolution.Minute)
self.Log(str(hist.index))
self.Log(str(hist.columns))

# Check if returns an empty list. It should not.
if hist.empty:
self.Log(str(self.Time) + " empty hist")
return

# Select the closing prices
prices = hist.close

# The History method returns a multi-index pandas.DataFrame, where the
# symbols are index 0 and date/time is index 1.
# These lines are used to create a pandas.DataFrame where the symbols
# are in the columns, instead of index 0.
spy = prices.loc['SPY']
tqqq = prices.loc['TQQQ']
prices = pd.concat([spy,tqqq],axis = 1)
prices.columns = self.stocks

# Then we can .as_matrix normally
ret = prices.pct_change()[1:].as_matrix(self.stocks)
ret_mean = prices.pct_change().mean()
ret_std = prices.pct_change().std()
ret_norm = ret_mean / ret_std
ret_norm = ret_norm.as_matrix(self.stocks)

self.Log("ret_norm" + str(ret_norm))

def OnData(self, data):
if not self.Portfolio.Invested:
self.SetHoldings("SPY", 1)```