Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order status set wrong on bets matched immediately on placing #743

Open
foxwoody opened this issue Feb 29, 2024 · 1 comment
Open

order status set wrong on bets matched immediately on placing #743

foxwoody opened this issue Feb 29, 2024 · 1 comment

Comments

@foxwoody
Copy link

foxwoody commented Feb 29, 2024

Bug with order status when placing bets - happens live when replacing orders and suspect same might happen when initially placing an order if the price is outside current best price (eg back at 1.01 just takes current best price). The 3 log entries below show what happens with a replace bet that has its price changed to one that will be automatically matched with best execution - ends up as EXECUTABLE although fully matched.

  1. an existing EXECUTABLE bet that has it's price changed to a price outside the current prices using market.replace_order() is matched immediately (due to best price execution) and the returned status is EXECUTION_COMPLETE.

{"asctime": "2024-02-28 19:31:30,382", "levelname": "INFO", "message": "execute_replace", "trading_function": "replace", "elapsed_time": 0.31018781661987305, "response": {"customerRef": "99c1a3806bc14d62920763d3587774ea", "status": "SUCCESS", "marketId": "1.225432455", "instructionReports": [{"status": "SUCCESS", "cancelInstructionReport": {"status": "SUCCESS", "instruction": {"betId": "339845419341"}, "sizeCancelled": 0.01, "cancelledDate": "2024-02-28T19:31:30.000Z"}, "placeInstructionReport": {"status": "SUCCESS", "instruction": {"selectionId": 47705983, "limitOrder": {"size": 0.01, "price": 16.5, "persistenceType": "LAPSE"}, "orderType": "LIMIT", "side": "LAY"}, "betId": "339845613475", "placedDate": "2024-02-28T19:31:30.000Z", "averagePriceMatched": 14.0, "sizeMatched": 0.01, "orderStatus": "EXECUTION_COMPLETE"}}]}, "order_package": {"id": "99c1a380-6bc1-4d62-9207-63d3587774ea", "client": "<flumine.clients.betfairclient.BetfairClient object at 0x0000028F7B014CA0>", "market_id": "1.225432455", "orders": ["139284414004067119"], "order_count": 1, "package_type": "Replace", "customer_strategy_ref": "livestrat", "bet_delay": 0, "market_version": null, "retry": true, "retry_count": 0, "async": false}}

  1. flumine raises a Pending state for this bet 8ms later

{"asctime": "2024-02-28 19:31:30,390", "levelname": "INFO", "message": "Order status update: Pending", "market_id": "1.225432455", "selection_id": 47705983, "handicap": 0, "id": "139284414903893751", "customer_order_ref": "stratXXxxxxxx-139284414903893751", "bet_id": "339845613475", "date_time_created": "2024-02-28 19:31:30.072237", "publish_time": "2024-02-28 19:31:30.362000", "market_version": null, "async": false, "trade": {"id": "7b0ef6b5-a29b-40a7-8855-9de1be2ccb8f", "strategy": "stratXX", "place_reset_seconds": 0.0, "reset_seconds": 0.0, "orders": ["139284413990493287", "139284414004067119", "139284414903893751"], "offset_orders": [], "notes": "", "market_notes": "12,12.5,12.5", "status": "Pending", "status_log": "Pending, Live, Pending, Live, Pending, Live, Pending"}, "order_type": {"order_type": "Limit", "price": 16.5, "size": 0.01, "persistence_type": "LAPSE", "time_in_force": null, "min_fill_size": null, "bet_target_type": null, "bet_target_size": null, "price_ladder_definition": "CLASSIC"}, "info": {"side": "LAY", "size_matched": 0.01, "size_remaining": 0.0, "size_cancelled": 0.0, "size_lapsed": 0.0, "size_voided": 0.0, "average_price_matched": 14.0}, "responses": {"date_time_placed": "2024-02-28 19:31:30.390370", "elapsed_seconds_executable": null}, "runner_status": null, "line_range_result": null, "status": "Pending", "status_log": "Pending", "violation_msg": null, "simulated": {"profit": 0.0, "piq": 0.0, "matched": []}, "notes": "5,12.483517615336229,11.5,10.912637127536383,0.0,0.0,0.92", "market_notes": null, "client": "CLIENTCODE"}

  1. 2ms later things are going wrong somewhere and the order status is changed back to EXECUTABLE

{"asctime": "2024-02-28 19:31:30,392", "levelname": "INFO", "message": "Order status update: Executable", "market_id": "1.225432455", "selection_id": 47705983, "handicap": 0, "id": "139284414903893751", "customer_order_ref": "stratXXxxxxxx-139284414903893751", "bet_id": "339845613475", "date_time_created": "2024-02-28 19:31:30.072237", "publish_time": "2024-02-28 19:31:30.362000", "market_version": null, "async": false, "trade": {"id": "7b0ef6b5-a29b-40a7-8855-9de1be2ccb8f", "strategy": "stratXX", "place_reset_seconds": 0.0, "reset_seconds": 0.0, "orders": ["139284413990493287", "139284414004067119", "139284414903893751"], "offset_orders": [], "notes": "", "market_notes": "12,12.5,12.5", "status": "Pending", "status_log": "Pending, Live, Pending, Live, Pending, Live, Pending"}, "order_type": {"order_type": "Limit", "price": 16.5, "size": 0.01, "persistence_type": "LAPSE", "time_in_force": null, "min_fill_size": null, "bet_target_type": null, "bet_target_size": null, "price_ladder_definition": "CLASSIC"}, "info": {"side": "LAY", "size_matched": 0.01, "size_remaining": 0.0, "size_cancelled": 0.0, "size_lapsed": 0.0, "size_voided": 0.0, "average_price_matched": 14.0}, "responses": {"date_time_placed": "2024-02-28 19:31:30.390370", "elapsed_seconds_executable": null}, "runner_status": null, "line_range_result": null, "status": "Executable", "status_log": "Pending, Executable", "violation_msg": null, "simulated": {"profit": 0.0, "piq": 0.0, "matched": []}, "notes": "5,12.483517615336229,11.5,10.912637127536383,0.0,0.0,0.92", "market_notes": "13.5,14,14", "client": "CLIENTCODE"}

@foxwoody foxwoody changed the title order status set wrong on synchronous (blocking) bets matched immediately on placing order status set wrong on bets matched immediately on placing Feb 29, 2024
@foxwoody
Copy link
Author

Initial post assumed issue was down to sync socket mode. Testing live reveals the same issue in async mode having set the active flumine lib config.py with async_place_orders = True Presuming that the config file entry dictates the mode means that the issue is not down to just sync/async as initially thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant