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.SetCash(100000)
self.SetStartDate(2021, 6, 1)
self.SetTimeZone('America/New_York')

#CAD Futureshttps://www.quantconnect.com/project/8692527#
self.symbol = self.AddData(Difference, "Difference", Resolution.Minute).Symbol

self.SetBrokerageModel(BrokerageName.OandaBrokerage)

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


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

#Entry
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)
else:
pass


#Exit
if self.Portfolio["USDCAD"].IsLong and difference.Value <= 0:
self.Liquidate()
elif self.Portfolio["USDCAD"].IsShort and difference.Value >= 0:
self.Liquidate()
else:
pass


class Difference(PythonData):

def GetSource(self, config, date, isLive):
source = "https://raw.githubusercontent.com/LeonidNID/test/master/Difference_MINUTES_SHORTENED.csv?token=ALPEJH5MWEXBOP4PF6JDAM3A3XO2O"
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 main.py:line 23 TypeError : Cannot get managed object)

 

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