betcode-org / flumine

flūmine - Betting trading framework
MIT License
177 stars 60 forks source link

markerecorder not updating catalogue for market definition version change #674

Closed foxwoody closed 1 year ago

foxwoody commented 1 year ago

As discussed on Slack for greyhound (or similar) markets where alternative selection's are used and the name is not being added to the market catalogue. For live usage the market_book has a __call__()function to force update of the catalogue on every new market definition version update but there is no market_book used when recording markets.

Since the market recorder is just a variant of a strategy I can't see a way of building this in to base classes just for recording and maybe every user has their own variant that they will have to patch. It could possibly be added to BaseStrategy.process_raw_data() provided that code always called the parent class of which it is the base provided it first checks if there was a function there to call.

My sledgehammer fix for my patched up class makes dirty assumptions about base structure but should work. Add the following code to MarketRecorder.process_raw_data() at the end of the code block after the with block that writes the packet

        if data.get("marketDefinition") is not None :
            self.streams[0].flumine.markets.markets[market_id].update_market_catalogue = True
liampauling commented 1 year ago

I think a cleaner fix would be to add it to Flumine._process_raw_data with your logic

if data.get("marketDefinition") is not None :
    market.update_market_catalogue = True
foxwoody commented 1 year ago

Definitely ! Only did that to avoid meddling with core stuff. Yes would slot in there just before the strategies are fed and the market object is available. Patch worked live btw.

Edit: looks like code there uses if "marketDefinition" in datum as it's style instead ofdict.get()

liampauling commented 1 year ago

FYI I think in is faster than get when you don't need the data