Partially matched bet on immediate_or_cancel

Hi,
i’ve made a request of type “immediate_or_cancel” and i was expecting the order to be fully matched.

My post request to the https://api.smarkets.com/v3/orders/ :
{ contract_id=43814467, label=test_strategy, market_id=12679435, minimum_accepted_quantity=509, price=9804, quantity=509, side=buy, type=immediate_or_cancel }

Immediately after placing the bet, i am requesting the state of the bet https://api.smarkets.com/v3/orders/ and i get:
{
“average_price_matched”: 9804,
“contract_id”: “43814467”,
“created_datetime”: “2021-02-03T15:26:05.776563Z”,
“id”: “202881998707818499”,
“label”: “test_strategy”,
“last_modified_datetime”: “2021-02-03T15:26:05.776563”,
“market_id”: “12679435”,
“original_order_id”: null,
“outcome”: null,
“price”: 9804,
“quantity”: 448,
“quantity_filled”: 448,
“quantity_filled_pending”: 448,
“quantity_filled_pending_user_currency”: 508,
“quantity_filled_user_currency”: 508,
“quantity_unfilled”: 0,
“quantity_unfilled_user_currency”: 0,
“quantity_user_currency”: 509,
“sequence_number”: 1000256,
“side”: “buy”,
“state”: “filled”,
“type”: “immediate_or_cancel”
}

and after the bet has settled i get:
{
“average_price_matched”: 9804,
“contract_id”: “43814467”,
“created_datetime”: “2021-02-03T15:26:05.776563Z”,
“id”: “202881998707818499”,
“label”: “test_strategy”,
“last_modified_datetime”: “2021-02-03T15:26:19.777499Z”,
“market_id”: “12679435”,
“original_order_id”: null,
“outcome”: null,
“price”: 9804,
“quantity”: 448,
“quantity_filled”: 448,
“quantity_filled_pending”: 0,
“quantity_filled_pending_user_currency”: 0,
“quantity_filled_user_currency”: 508,
“quantity_unfilled”: 0,
“quantity_unfilled_user_currency”: 0,
“quantity_user_currency”: 509,
“sequence_number”: 1000259,
“side”: “buy”,
“state”: “settled”,
“type”: “immediate_or_cancel”
}

  1. As you can see quantity_filled_user_currency does not match the minimum_accepted_quantity from the request. Can i consider this bet fully matched?
    It is also strange the output in the ui, which is both fully matched and partially matched.
  2. There is no outcome even though the order is settled. I was expecting to get an outcome if the order is settled, otherwise how can i find what happened to the bet? It would be nice to have an outcome on settled orders, in order to calculate P&L.
  3. How can i find if a pending bet was cancelled?

Thanks.

Hey Martin,

Thanks for flagging this. We’ve looked into it further now and can confirm that the settlement was broken. In this particular case, your in-play bet only got confirmed at 15:26:19 UTC - when the match was already over. As such the order response does not contain the outcome which you would normally use to verify the settlement. The bet, however, was fully matched so, as per your screenshot, it looks like there is another issue with notifications too.

We’ll make sure to fix both them. Sorry for the trouble and once again thanks for bringing this to our attention.

1 Like

On point 3 martin makes, I’m also wondering the same thing. What is the best way to check that:

  1. a bet is pending / still pending
  2. the pending bet has been cancelled

You’d need to check the quantity_filled_pending field in the orders route to confirm if a bet is pending.

In regards to cancelled bets, you can get a confirmation by checking the source in account activity.

So in the orders route ‘outcome’ = ‘void’ wouldn’t do it?

What happens to quantity_filled_pending value if the order is void?

In account activity what is the source I’m after, is it order.execute.void/order.void?

Thanks

Sorry, I thought you were referring to an unmatched bet being cancelled. My bad.

You’d need to look for "source":"order.execute.void" since pending matched bets are voided rather than cancelled.

Here is an example response of a pending bet that got matched:

{"account_activity": [{"amount": "-0.05", "bonus_change": null, "commission": null, "contract_id": "44300268", "event_id": "42076123", "exposure": "-209.55", "extra": "in_play", "label": "web-desktop", "market_id": "12845268", "money": "221.78", "money_change": null, "order_id": "202887346423369766", "price": 6803, "quantity": 0, "quantity_change": 0, "quantity_user_currency": 0, "quantity_user_currency_change": 0, "seq": 1094380, "side": "buy", "source": "order.execute.confirm", "subseq": 0, "timestamp": "2021-02-18T18:06:08.395805"}, {"amount": "-0.05", "bonus_change": null, "commission": null, "contract_id": "44300268", "event_id": "42076123", "exposure": "-209.55", "extra": "pending", "label": "web-desktop", "market_id": "12845268", "money": "221.78", "money_change": null, "order_id": "202887346423369766", "price": 6803, "quantity": 0, "quantity_change": -724, "quantity_user_currency": 0, "quantity_user_currency_change": -724, "seq": 1094379, "side": "buy", "source": "order.execute", "subseq": 0, "timestamp": "2021-02-18T18:06:00.393913"}, {"amount": "-0.05", "bonus_change": null, "commission": null, "contract_id": "44300268", "event_id": "42076123", "exposure": "-209.55", "extra": "good_till_cancelled", "label": "web-desktop", "market_id": "12845268", "money": "221.78", "money_change": null, "order_id": "202887346423369766", "price": 6897, "quantity": 724, "quantity_change": 0, "quantity_user_currency": 724, "quantity_user_currency_change": 0, "seq": 1094378, "side": "buy", "source": "order.book.accept", "subseq": 0, "timestamp": "2021-02-18T18:06:00.393913"}, {"amount": "-0.05", "bonus_change": null, "commission": null, "contract_id": "44300268", "event_id": "42076123", "exposure": "-209.55", "extra": "good_till_cancelled", "label": "web-desktop", "market_id": "12845268", "money": "221.78", "money_change": null, "order_id": "202887346423369766", "price": 6897, "quantity": 724, "quantity_change": 0, "quantity_user_currency": 724, "quantity_user_currency_change": 0, "seq": 1094377, "side": "buy", "source": "order.create", "subseq": 0, "timestamp": "2021-02-18T18:06:00.393913"}], "pagination": {"next_page": null}}

And another one for a pending bet that was voided:

{"account_activity": [{"amount": "0.49", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-58.08", "extra": "Confirmed material event", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 0, "quantity_change": 0, "quantity_user_currency": 0, "quantity_user_currency_change": 0, "seq": 86472, "side": "buy", "source": "order.execute.void", "subseq": 0, "timestamp": "2020-03-11T20:43:36.587424"}, {"amount": "0.51", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-58.57", "extra": "Confirmed material event", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 0, "quantity_change": 0, "quantity_user_currency": 0, "quantity_user_currency_change": 0, "seq": 86471, "side": "buy", "source": "order.execute.void", "subseq": 0, "timestamp": "2020-03-11T20:43:36.587424"}, {"amount": "0.00", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "Confirmed material event", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 0, "quantity_change": 0, "quantity_user_currency": 0, "quantity_user_currency_change": 0, "seq": 86470, "side": "buy", "source": "order.execute.void", "subseq": 0, "timestamp": "2020-03-11T20:43:36.587424"}, {"amount": "0.00", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "Confirmed material event", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 0, "quantity_change": 0, "quantity_user_currency": 0, "quantity_user_currency_change": 0, "seq": 86469, "side": "buy", "source": "order.execute.void", "subseq": 0, "timestamp": "2020-03-11T20:43:36.587424"}, {"amount": "-0.49", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "pending", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 0, "quantity_change": -1475581, "quantity_user_currency": 0, "quantity_user_currency_change": -1475581, "seq": 86468, "side": "buy", "source": "order.execute", "subseq": 0, "timestamp": "2020-03-11T20:42:39.371730"}, {"amount": "-0.51", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "pending", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 1475581, "quantity_change": -1544958, "quantity_user_currency": 1475581, "quantity_user_currency_change": -1544958, "seq": 86467, "side": "buy", "source": "order.execute", "subseq": 0, "timestamp": "2020-03-11T20:42:39.371730"}, {"amount": "-0.00", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "pending", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 3020539, "quantity_change": -2711, "quantity_user_currency": 3020539, "quantity_user_currency_change": -2711, "seq": 86466, "side": "buy", "source": "order.execute", "subseq": 0, "timestamp": "2020-03-11T20:42:39.371730"}, {"amount": "-0.00", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "pending", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 3023250, "quantity_change": -7053, "quantity_user_currency": 3023250, "quantity_user_currency_change": -7053, "seq": 86465, "side": "buy", "source": "order.execute", "subseq": 0, "timestamp": "2020-03-11T20:42:39.371730"}, {"amount": "-1.00", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "good_till_cancelled", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 3030303, "quantity_change": 0, "quantity_user_currency": 3030303, "quantity_user_currency_change": 0, "seq": 86464, "side": "buy", "source": "order.book.accept", "subseq": 0, "timestamp": "2020-03-11T20:42:39.371730"}, {"amount": "-1.00", "bonus_change": null, "commission": null, "contract_id": "33893198", "event_id": "41607143", "exposure": "-59.08", "extra": "good_till_cancelled", "label": "app-android", "market_id": "9725523", "money": "218.59", "money_change": null, "order_id": "202765645247983630", "price": 33, "quantity": 3030303, "quantity_change": 0, "quantity_user_currency": 3030303, "quantity_user_currency_change": 0, "seq": 86463, "side": "buy", "source": "order.create", "subseq": 0, "timestamp": "2020-03-11T20:42:39.371730"}], "pagination": {"next_page": null}}

Note the "extra" field includes the value "pending" for pending matched orders which you might also find useful.