betcode-org / flumine

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

AttributeError: 'NoneType' object has no attribute 'event_id' in framework.run() #744

Closed Bruno-TT closed 6 months ago

Bruno-TT commented 6 months ago
  line 1473, in <module>
    framework.run()
  File "/home/bruno/miniconda3/envs/betfair_pytorch2/lib/python3.9/site-packages/flumine/flumine.py", line 33, in run
    self._process_market_books(event)
  File "/home/bruno/miniconda3/envs/betfair_pytorch2/lib/python3.9/site-packages/flumine/baseflumine.py", line 151, in _process_market_books
    market = self._add_market(market_id, market_book)
  File "/home/bruno/miniconda3/envs/betfair_pytorch2/lib/python3.9/site-packages/flumine/baseflumine.py", line 214, in _add_market
    self.markets.add_market(market_id, market)
  File "/home/bruno/miniconda3/envs/betfair_pytorch2/lib/python3.9/site-packages/flumine/markets/markets.py", line 21, in add_market
    if market.event_id:
  File "/home/bruno/miniconda3/envs/betfair_pytorch2/lib/python3.9/site-packages/flumine/markets/market.py", line 136, in event_id
    return self.market_book.market_definition.event_id
AttributeError: 'NoneType' object has no attribute 'event_id'
liampauling commented 6 months ago

Anymore context to this? Code used etc.

Bruno-TT commented 6 months ago

it's happening like 3/4 of the time I run flumine, my strategy doesn't touch event_id or anything internal to flumine, this happens right at the start when framework.run() is called

Bruno-TT commented 6 months ago

removing streaming_timeout seems to fix it

liampauling commented 6 months ago

Which markets? / What is your market and data filter?

Bruno-TT commented 6 months ago
    filter=streaming_market_filter(
            event_type_ids=["7"],
            market_types=["WIN"],
            # country_codes=["GB"]
        )

    strategy = PlaceSomeBets(market_filter=filter,
                            #  streaming_timeout=.5,
                             conflate_ms=400
                             )

    framework.add_strategy(strategy)
    framework.run()

uncomment the streaming timeout and play around with the values you should be able to recreate the error

liampauling commented 6 months ago

Ok, I can replicate, looks like a race condition due to the conflation and a snap which is sending out data with no data

liampauling commented 6 months ago

Fixed in this bflw commit