Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 39.375% Drawdown 0% Expectancy 0 Net Profit 0.091% Sharpe Ratio 11.225 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 16.618 Annual Standard Deviation 0.01 Annual Variance 0 Information Ratio 11.225 Tracking Error 0.01 Treynor Ratio 0.007 Total Fees $0.00 |
import tensorflow as tf from keras.models import Sequential from keras.layers import LSTM from keras.layers.core import Dense, Dropout # from keras import optimizers from sklearn.preprocessing import MinMaxScaler from sklearn.metrics import mean_squared_error import numpy as np import pandas as pd class Algorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 3, 28) self.SetEndDate(2018, 3, 28) self.SetCash(100000) self.order = None self.instruments = ['SPY'] for instrument in self.instruments: self.AddEquity(instrument, Resolution.Daily) self.Securities[instrument].FeeModel = ConstantFeeTransactionModel(0) self.Schedule.On(self.DateRules.EveryDay('SPY'), self.TimeRules.AfterMarketOpen('SPY', -30), Action(self.PreMarketOpen)) self.Schedule.On(self.DateRules.EveryDay('SPY'), self.TimeRules.BeforeMarketClose('SPY', 16), Action(self.PreMarketClose)) def OnData(self, data): pass def PreMarketOpen(self): result = self.MarketOnOpenOrder('SPY', -100) self.Log(str(self.Time) + ' | SPY sell market order: '+ str(result)) def PreMarketClose(self): for instrument in self.instruments: if self.Portfolio[instrument].Invested: self.Log(str(self.Time) + ' | market on close: ' + instrument + ' ' + str(-self.Portfolio[instrument].Quantity)) self.order = self.MarketOnCloseOrder(instrument, -self.Portfolio[instrument].Quantity) def OnOrderEvent(self, fill): order = self.Transactions.GetOrderById(fill.OrderId) self.Log("{0} | {1}:: {2}".format(self.Time, order.Type, fill))