| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 2.008 Tracking Error 0.168 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
# region imports
from AlgorithmImports import *
import pandas as pd
import numpy as np
from datetime import time, datetime, timedelta
# endregion
class CombinedAlgorithm(QCAlgorithm):
def Initialize(self):
# INITIALIZE
self.SetStartDate(2022, 1, 1) # Set Start Date
self.SetEndDate(2022, 3, 1)
self.SetCash(10000) # Set Strategy Cash
self.spy = self.AddEquity('SPY', Resolution.Minute)
self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
self.trigger_week_high = 0
self.trigger_week_low = 0
weeklyConsolidator = TradeBarConsolidator(Calendar.Weekly)
weeklyConsolidator.DataConsolidated += self.OnTwoWeekBar
self.SubscriptionManager.AddConsolidator("SPY", weeklyConsolidator)
self.weekBarWindow = RollingWindow[TradeBar](1) # 2
def OnData(self, data):
# VARIABLES
pass
#self.Log(f'{self.trigger_week_high} previous weeks high ORDER')
def OnTwoWeekBar(self, sender, bar):
self.Log("OnDataConsolidated called on " + str(self.Time))
self.Log(str(bar.High))
self.weekBarWindow.Add(bar)
if not self.weekBarWindow.IsReady:
return
trigger_week = self.weekBarWindow[0]
self.trigger_week_high = trigger_week.High
self.trigger_week_low = trigger_week.Low
#self.Log(f'{self.trigger_week_high} previous weeks high')