Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We provide a Swagger schema to allow specification browsing & code generation for various languages; please use:

Swagge DocumentationSwagger: http://editor.swagger.io/#/

...

Swagger Definition: https://

...

github.

...

com/betfair/stream-api-sample-code/blob/master/ESASwaggerSchema.json

 

Info
Note: Any fields representing time and having a long type will represent the UNIX Timestamps (See https://currentmillis.com/ for conversions) 
Tip
titleJson Deserializers

Please expect fields & enums to be added to json responses as and when the need arises; your deserialization code should be tolerant of such additive changes

 

To generate a client for the programming language of your choice:

  1. Navigate to http://editor.swagger.io/#/
  2. Download schema file from ESASwaggerSchema.json and  and save this to your computer. 
  3. Selection File > Import File
  4. Choose the "ESASwaggerSchema.json" file > Generate Client > Select your required language to generate a language binding.

Info
Note: Any fields representing time and having a long type will represent the UNIX Timestamps (See https://currentmillis.com/ for conversions) 
Tip
titleJson Deserializers

Please expect fields & enums to be added to json responses as and when the need arises; your deserialization code should be tolerant of such additive chang

Info
titleA few points to note with Swagger:
  • It's cross platform and we can't control how it works / behaves - but it does save a lot of error prone typing.
  • Enums and Inheritance are a little flaky:
    • Enums for error codes / filters etc. are defined but are treated as strings in c# (so you will need to copy definitions from the swagger spec until this is fixed by swagger).
    • Inheritance is defined but not generated correctly - you will have to manually manipulate the op=<type> field
      • In c# JsonCreationConverter is the typical way to model inheritance
      • In java look at JsonSubTypes
  • We are not a REST service - so only the swagger generated model package is relevant

...

  • orderFilter (optional)

OrderFilter

This optional filter already filters by your account; but additional data shaping is supported

...

  • <as for ChangeMessage>
  • oc / OrderAccountChange - the modifications to account's orders (will be null on a heartbeat)
    • closed - indicates when the market is closed
    • id / Market Id - the id of the market the order is on
    • orc / Order Changes - a list of changes to orders on a runner
      • id / Selection Id - the id of the runner (selection) 
      • uo / Unmatched Orders - orders on this runner that are unmatched
        • Every order change is sent in full; the transient on a change to EXECUTION_COMPLETE is sent (but it would not be sent on initial image)
        • id / Bet Id - the id of the order  
        • p / Price - the original placed price of the order
        • s / Size - the original placed size of the order
        • bsp / BSP Liability - the BSP liability of the order (null if the order is not a BSP order)
        • side / Side - the side of the order
        • status / Status - the status of the order (E = EXECUTABLE, EC = EXECUTION_COMPLETE)
        • pt / Persistence Type - whether the order will persist at in play or not (L = LAPSE, P = PERSIST, MOC = Market On Close)
        • ot / Order Type - the type of the order (L = LIMIT, MOC = MARKET_ON_CLOSE, LOC = LIMIT_ON_CLOSE)
        • pd / Placed Date - the date the order was placed
        • md / Matched Date - the date the order was matched (null if the order is not matched)
        • ld / Lapsed Date - the date the order was lapsed (null if the order is not lapsed)
        • avp / Average Price Matched - the average price the order was matched at (null if the order is not matched
        • sm / Size Matched - the amount of the order that has been matched
        • sr / Size Remaining - the amount of the order that is remaining unmatched
        • sl / Size Lapsed - the amount of the order that has been lapsed
        • sc / Size Cancelled - the amount of the order that has been cancelled
        • sv / Size Voided - the amount of the order that has been voided
        • rac / Regulator Auth Code - the auth code returned by the regulator
        • rc / Regulator Code - the regulator of the order
        • rfo / Reference Order - the customer supplied order reference
        • rfs / Reference Strategy - the customer supplied strategy reference used to group orders together - default is ""
      • Price point / full depth Ladders (price, size - tuples - keyed by price) of matches:
        • mb / Matched Backs - matched amounts by distinct matched price on the Back side for this runner
        • ml / Matched Lays - matched amounts by distinct matched price on the Lay side for this runner

...

For these matched bets, you will receive on the Order Stream both a uo for the affected bet and the relevant updates to mb or ml (reducing the matched volume at the original matched price and adding volume at the new reduced price).

 

Initial bet placement at price 12

...

See the avp in the uo record showing the new price of 9.47 and see the two entries in mb, one to remove the previously added size of 2 at price point 12 and one to add the size of 2 into the new price point of size 9.47.

Bets placed on the actual removed runner will be voided/lapsed (for matched/unmatched bets respectively) and these  will also be sent through on the Order Stream. 

Line Markets

Line markets being sent on the Market Stream can be identified by the bettingType field of MarketDefinition (with value of "LINE").

The MarketDefinition of Line markets provide some additional fields that will be null for all other types,

  • lineMaxUnit - maximum value for the outcome, in market units for this market (eg 100 runs).
  • lineMinUnit - minimum value for the outcome, in market units for this market (eg 0 runs).
  • lineInterval - the odds ladder on this market will be between the range of lineMinUnit and lineMaxUnit, in increments of the interval value.e.g. If lineMinUnit=10 runs, lineMaxUnit=20 runs, lineInterval=0.5 runs, then valid odds include 10, 10.5, 11, 11.5 up to 20 runs.

 

For updates for Orders on Line markets received on the Order Stream be aware of how the following properties behave,

  • price - line markets operate at even-money odds of 2.0. However, price for these markets refers to the line positions available as defined by the markets min-max range and interval steps.
  • side - for Line markets a 'B' bet refers to a SELL line and an 'L' bet refers to a BUY line.
  • averagePriceMatched - this value is not meaningful for activity on Line markets and is not guaranteed to be returned or maintained for these markets.

Sample Applications - C# & Java

...