First off I want to state that I have already read the Documentation on Importing custom data and it sadly has not helped me.

I am having trouble implementing a csv file in my algorithm that consists of the columns INDEX,DATETIME,CLOSE.

I want to Access the DATETIME on a minute basis and buy/sell an FX Pair when the CLOSE in my csv has a certain value

I have tried the AddData() method but I think since it requires a “ticker string” argument and my data is not data from a specific ticker it has not been successful.

class Futures_CSV(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2021, 6, 1)

#CAD Futures
self.symbol = self.AddData(Difference, "Difference", Resolution.Minute).Symbol


self.AddForex("USDCAD", Resolution.Minute, Market.Oanda)

def OnData(self, data):
if data.ContainsKey(self.symbol):
self.Plot("Difference", "CLOSE", data[self.symbol].Close)

if self.symbol <= -0.0015 and not self.Portfolio.Invested:
self.SetHoldings("USDCAD", -10)
elif self.symbol >= 0.0015 and not self.Portfolio.Invested:
self.SetHoldings("USDCAD", 10)

if self.Portfolio["USDCAD"].IsLong and difference.Value <= 0:
elif self.Portfolio["USDCAD"].IsShort and difference.Value >= 0:

class Difference(PythonData):

def GetSource(self, config, date, isLive):
source = ""
return SubscriptionDataSource(source, SubscriptionTransportMedium.RemoteFile);

def Reader(self, config, line, date, isLive):
# If first character is not digit, pass
if not (line.strip() and line[0].isdigit()): return None

data = line.split(',')
difference = Difference()
difference.Symbol = config.Symbol
difference.Time = datetime.strptime(data[1], '%Y-%m%-dT%h:%M:%s')
difference.Value = float(data[2])
difference["CLOSE"] = float(data[2])

return difference

This is my buggy code I have now (This throws up the error: in 23 TypeError : Cannot get managed object)


I hope one of the more experienced members can help me, thanks in advance!