betcode-org / flumine

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

Simulation not allowing for NaN as BSP #716

Closed foxwoody closed 1 year ago

foxwoody commented 1 year ago

In simulated order.py:_process_sp() there can be occasions when actual_spis in 'None','NaN','Infinity' (last 2 are as per BF docs - think I've found Nonebefore since have something in my code testing that). Currently my backtest logs show an exception thrown File "C:\\...\\flumine\\simulation\\simulatedorder.py", line 391, in _process_sp\n size = round(remaining_risk / (actual_sp - 1.0), 2)\nTypeError: unsupported operand type(s) for -: 'str' and 'float'" Have a sample recorded file with 'Nan' if would help ? Suggest fix could be

    def _process_sp(self, publish_time: int, runner: RunnerBook) -> None:
        # calculate matched on BSP reconciliation
        actual_sp = runner.sp.actual_sp
        if actual_sp not in ['None','NaN','Infinity',0.0] :
            ......