Load data from external source and place it on context as is

Hi,

I have an algorithms that is supposed to receive a configuration file from an external overnight process. The configuration file is not raw data to be streamed together with the pricing information of securities, so the ideal scenario is to load the data somehow and place it inside the context for later consumption when the handle_data function requires to look into the configuration information.

Is there a way to achieve this? what I am asking is, is it possible to use fetcher but avoiding it trying to align data into a particular symbol?

Thanks,
Napoleon

2 responses

you could do this by assigning a prefunc to the fetcher that populates a global variable. in BeforeTradingStarts you can move this global data into context and do your thing. Dont keep it into a global as this will not be saved/restored if the servers crash, the context will be restored.

I think you can capture context in a closure, then pass that as an argument to the pre_func. I haven't tried this, but it should work:

def initialize(context):
...
fetch_csv(...
pre_func=lambda df: actual_pre_func(df, context)
...)