Overall Statistics
Total Trades
63
Average Win
0.03%
Average Loss
-0.02%
Compounding Annual Return
0.004%
Drawdown
2.200%
Expectancy
0.639
Net Profit
0.001%
Sharpe Ratio
0.021
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
1.46
Alpha
0.218
Beta
-11.345
Annual Standard Deviation
0.04
Annual Variance
0.002
Information Ratio
-0.453
Tracking Error
0.04
Treynor Ratio
0
Total Fees
$63.00
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")

from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Python import PythonQuandl

import math
import pandas as pd
import numpy as np
from decimal import *


class DailyAlgorithm(QCAlgorithm):

    def Initialize(self):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

        # Context
        self.stock = 'SPY'
        self.SetStartDate(2018,4,1)  #Set Start Date
        self.SetEndDate(2018,7,1)    #Set End Date
        self.SetCash(10000)          #Set Strategy Cash
        self.AddEquity('SPY', Resolution.Daily)


    def OnData(self, slice):
        self.close_price = self.Securities[self.stock].Price
        self.open_price = self.Securities[self.stock].Open
        self.high_price = self.Securities[self.stock].High
        self.low_price = self.Securities[self.stock].Low
        
        daily_perf = (self.close_price - self.open_price) / self.open_price
        if daily_perf < 0.003:
            self.MarketOrder(self.stock, 1)
        elif daily_perf > 0.003:
            self.MarketOrder(self.stock, -1)

        self.Plot('Stock Plot', 'close', self.close_price)
        self.Plot('Stock Plot', 'open', self.open_price)
        self.Plot('Stock Plot', 'high', self.high_price)
        self.Plot('Stock Plot', 'low', self.low_price)