Bet Angel
×
Full Guide

Betting component

 

Purpose

 
To place and manage bets on the markets currently loaded into Bet Angel.
 
Currently via the API you can:
 
Note: As the betting operations require Bet Angel to communicate with the betfair API to place/modify/cancel bets on the exchange, there will be a delay between request and response while that communication takes place. If you wish the Bet Angel API to respond without delay you can set the 'async' field to true. When working in this asynchronous mode, Bet Angel will return a pendingResultId that can be used at a later time to get the actual result of the call. Each operation that supports 'async' is paired with another operation that is used to get the pending result.
 

Endpoint

 
http://localhost:<port>/api/betting/v1.0/<operationName>
 
e.g. http://localhost:9000/api/betting/v1.0/placeBets
 

Operations

 
 placeBets
 
PlaceBetsResponse placeBets( PlaceBetsInstruction instruction )
 
Places one or more bets into a market. The details of each bet to be placed (selection Id, price, stake, back/lay) is provided by populating the betsToPlace field with PlaceBetInfo objects.
 
If the globalSettings field is populated, those settings will apply to each of the bets. The normal global settings that are available on the Bet Angel trading screen as also available to this API. e.g. Offsetting (with or without greening), Stop loss, Batches, Fill or Kill.
 
Note: This operation can also be used to place BSP (betfair SP) bets, in which case the stake field specifies the required SP liability and the price field sets a price limit when that option is chosen as the bspBetType.
 
The result in the operation's response contains a list of PlaceBetResultInfo objects, one for each bet that was requested to be placed.
 
The status in each of those objects will indicates whether the bet was placed:
  •  OK - the bet was placed and the betRef, stakeMatched fields will be populated. If any of the bet was matched, then priceMatched will also be populated.
  •  FAILED - the bet was not placed and the error field will populated to provide further details
  •  PENDING - the instruction had the async field set true and the API is awaiting the results of the bet placement. The pendingResultId field in the response will have been populated for use in a getPendingPlaceBetsResult call.
 
The response itself also has a status to indicate the success of the operation as a whole.
 
 
 getPendingPlaceBetsResult
 
PlaceBetsResponse getPendingPlaceBetsResult( GetPendingResultInstruction instruction )
 
Following an asynchronous call to placeBets, this operation gets the results of the bet placement request (as described in placeBets)
 
Provide the marketId used when originally placing the bets and the pendingResultId that was returned in that response and Bet Angel will lookup the results.
 
If any of the results are still PENDING then the status in this response will also be PENDING.
 
 
 modifyBets
 
ModifyBetsResponse modifyBets( ModifyBetsInstruction instruction )
 
Modifies one or more unmatched bets in a market. The details of each modification required is provided by populating the betsToModify field with ModifyBetInfo objects. In each of those objects, the bet reference must be provided; then you can optionally provide a new price, a new stake, and/or a new At In-play option. Although the betfair API only allows one of those changes to be made at a time, with the Bet Angel API you can change any of those values at the same time; Bet Angel will make multiple calls to betfair as required.
 
The result in the operation's response contains a list of ModifyBetResultInfo objects, one for each bet that was requested to be modified.
 
The status in each of those objects will indicates whether the bet was modified:
  •  OK - the bet was modified and the ModifyBetResultInfo object will contain details about the amount matched, cancelled, or new bet references that were created to satisfy the request.
  •  FAILED - at least one aspect of the bet modification failed and the error field will populated to provide further details
  •  PENDING - the instruction had the async field set true and the API is awaiting the results of the bet modification. The pendingResultId field in the response will have been populated for use in a getPendingModifyBetsResult call.
 
The response itself also has a status to indicate the success of the operation as a whole.
 
 
 getPendingModifyBetsResult
 
ModifyBetsResponse getPendingModifyBetsResult( GetPendingResultInstruction instruction )
 
Following an asynchronous call to modifyBets, this operation gets the results of the bet modification request (as described in modifyBets)
 
Provide the marketId used when originally modifying the bets and the pendingResultId that was returned in that response and Bet Angel will lookup the results.
 
If any of the results are still PENDING then the status in this response will also be PENDING.
 
 
 cancelBets
 
CancelBetsResponse cancelBets( CancelBetsInstruction instruction )
 
Cancels unmatched bets in the market specified in the instruction.
 
By using filterOption you can restrict the cancellation to:
  •  specific bet references (in which case you would need to populate the betRefs list)
  •  specific bets on specific selection Ids (in which case you would need to populate the selectionIds list).
 
By using the type field you can restrict the request to only cancel Back bets or only cancel Lay bets.
 
Note: If both filterOption and type fields are left blank then a request will be made to cancel every bet currently unmatched in Bet Angel for the market.
 
The result in the operation's response will contain a CancelBetResultInfo object for each bet that was requested to be cancelled.
 
The status in each of those objects will indicates whether the bet was cancelled:
  •  OK - the bet was cancelled and the stakeCancelled field will be populated with the amount confirmed to have been cancelled by betfair.
  •  FOK_KILLED_EARLY - the bet had an active Fill or Kill timer running, this has now been truncated so that the bet is killed early.
  •  FAILED - the bet was not cancelled and the error field will populated to provide further details
  •  PENDING - the instruction had the async field set true and the API is awaiting the results of the bet cancellation. The pendingResultId field in the response will have been populated for use in a getPendingCancelBetsResult call.
 
The response itself also has a status to indicate the success of the operation as a whole.
 
 
 getPendingCancelBetsResult
 
CancelBetsResponse getPendingCancelBetsResult( GetPendingResultInstruction instruction )
 
Following an asynchronous call to cancelBets, this operation gets the results of the bet cancellation request (as described in cancelBets)
 
Provide the marketId used when originally cancelling the bets and the pendingResultId that was returned in that response and Bet Angel will lookup the results.
 
If any of the results are still PENDING then the status in this response will also be PENDING.
 
 
 greenAllSelections
 
 
Executes the Green All Selections process on the market specified in the instruction. This will look at the matched bet amounts for all selections in the market in Bet Angel, calculate the stakes required to even out the profit values and place the necessary bets.
 
By default, the Best market price for each selection is used when placing the greening bets, but by using the priceOption you can change that to use the Reverse market price if you wish to offer bets to the market.
 
Depending on the Green Up Rules in Bet Angel Settings, Green All Selections will request that the unmatched bets in the market in Bet Angel are cancelled before the new bets are placed.
 
The result in the operation's response contains a list of CancelBetResultInfo objects (one for each bet that needed to be cancelled) and a list of PlaceBetResultInfo objects (one for each bet that needed to be placed).
 
The status in each of those objects will indicates whether the bet was cancelled/placed:
  •  OK - see cancelBets and placeBets for details about how the Info objects will have been populated.
  •  FOK_KILLED_EARLY - a bet being cancelled had an active Fill or Kill timer running, this has now been truncated so that the bet is killed early.
  •  FAILED - the bet was not cancelled/placed and the error field will populated to provide further details
  •  PENDING - the instruction had the async field set true and the API is awaiting the results of the bet cancellation/placement. The pendingResultId field in the response will have been populated for use in a getPendingGreenAllSelectionsResult call.
 
The response itself also has a status to indicate the success of the operation as a whole.
 
 
 getPendingGreenAllSelectionsResult
 
GreenAllSelectionsResponse getPendingGreenAllSelectionsResult( GetPendingResultInstruction instruction )
 
Following an asynchronous call to greenAllSelections, this operation gets the results of the bet cancellation and placement requests (as described in greenAllSelections)
 
Provide the marketId used when originally calling greenAllSelections and the pendingResultId that was returned in that response and Bet Angel will lookup the results.
 
If any of the results are still PENDING then the status in this response will also be PENDING.
 
 
 closeTrade
 
CloseTradeResponse closeTrade( CloseTradeInstruction instruction )
 
Executes the Trade Closure process on the market and selection specified in the instruction. This will look at the matched bet amounts for the selection in the market in Bet Angel, calculate the stake required to close the trade (with or without greening) at the price requested and place the necessary bets.
 
By default, the Best market price is used when placing the bet, but by using the priceOption you have more control over where the bet is positioned in the market. See CloseTradeInstruction for more details.
 
Depending on the Green Up Rules in Bet Angel Settings, Close Trade will request that the unmatched bets on the selection in the market in Bet Angel are cancelled before the new bets are placed.
 
The result in the operation's response contains a list of CancelBetResultInfo objects (one for each bet that needed to be cancelled) and a PlaceBetResultInfo object (for the bet that needed to be placed to close the trade).
 
The status in each of those objects will indicates whether the bet was cancelled/placed:
  •  OK - see cancelBets and placeBets for details about how the Info objects will have been populated.
  •  FOK_KILLED_EARLY - a bet being cancelled had an active Fill or Kill timer running, this has now been truncated so that the bet is killed early.
  •  FAILED - the bet was not cancelled/placed and the error field will populated to provide further details
  •  PENDING - the instruction had the async field set true and the API is awaiting the results of the bet cancellation/placement. The pendingResultId field in the response will have been populated for use in a getPendingCloseTradeResult call.
 
The response itself also has a status to indicate the success of the operation as a whole.
 
 
 getPendingCloseTradeResult
 
CloseTradeResponse getPendingCloseTradeResult( GetPendingResultInstruction instruction )
 
Following an asynchronous call to closeTrade, this operation gets the results of the bet cancellation and placement requests (as described in closeTrade)
 
Provide the marketId used when originally calling closeTrade and the pendingResultId that was returned in that response and Bet Angel will lookup the results.
 
If any of the results are still PENDING then the status in this response will also be PENDING.