Hi QC community… I’m floundering over getting a custom consolidator class working, for the purpose of defining custom start and end times for daily data, so that my algorithm is fed values at my custom time rather than 00:00. The reason I’m trying to do this:

A day on the Forex markets is from 17:00 to 16:59 the next day (New York time). Since QC's included daily Forex data appears to be coded from 00:00 to 23:59, I've encountered some difficulties with daily consolidators not aligning with the true market close for the day. For example, subscribing to minute data and feeding it into a daily consolidator gives me price values sampled at 00:00 every day (which happens to be part way through the Asian session and not what I want). I have seen one person raise this on the forum and the suggested solution was to craft a custom consolidator (with an example given in C#). I’ve tried to recreate this in Python but I’m not having much luck, it seems like my custom class is being called but the logic inside it is being ignored. Below is the code I’ve come up with. Any advice is very much appreciated!

class BasicTemplateAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetBrokerageModel(BrokerageName.OandaBrokerage, AccountType.Margin)

self.currency_pair_dict = {
"EURGBP": [], "EURAUD": [], "EURNZD": [], "EURUSD": [],
"EURCAD": [], "EURCHF": [], "EURJPY": [],

"GBPAUD": [], "GBPNZD": [], "GBPUSD": [], "GBPCAD": [],
"GBPCHF": [], "GBPJPY": [],

"AUDNZD": [], "AUDUSD": [], "AUDCAD": [], "AUDCHF": [],
"AUDJPY": [],

"NZDUSD": [], "NZDCAD": [], "NZDCHF": [], "NZDJPY": [],

"USDCAD": [], "USDCHF": [], "USDJPY": [],

"CADCHF": [], "CADJPY": [],

"CHFJPY": []

self.consolidator_dict = {}

for pair in self.currency_pair_dict:
self.AddForex(pair, Resolution.Minute, Market.Oanda, 100)
thisConsolidator = CustomConsolidator(timedelta(days=1))
self.consolidator_dict[pair] = thisConsolidator
self.consolidator_dict[pair].DataConsolidated += self.OnDataConsolidated
self.SubscriptionManager.AddConsolidator(pair, self.consolidator_dict[pair])

def OnDataConsolidated(self, sender, bar):
if str(bar.Symbol) == "EURUSD":
self.Log("Bar date/time: " + bar.Time.ctime())

def OnData(self, data):

class CustomConsolidator(QuoteBarConsolidator):
def __init__(self, timespan):
self.consolidatedBar = QuoteBar()

def Update(self, data):

if (data.Time.hour == 17 and data.Time.minute == 00):
self.consolidatedBar = QuoteBar(data.Time)
self.consolidatedBar.Update(data.Close, data.Bid, data.Ask)