Forums

We want to share an important update with our Betfair Community users.

Over the coming months, the Betfair Community platform will be winding down. The final active day for the platform will be December 21st. From December 22nd, users will no longer be able to access the platform.

Your discussions, insights, engagement, and, most importantly, feedback have helped shape the platform and guided innovation. Your feedback continues to be important to us, and we will continue to listen via our dedicated feedback channels, as well as through product testing and innovations.

To share your feedback and experience, visit: https://support.betfair.com/app/home

Developers

Welcome to Live View – Take the tour to learn more
Start Tour
There is currently 1 person viewing this thread.
soccer121.com
20 May 18 14:51
Joined:
Date Joined: 10 Aug 04
| Topic/replies: 3 | Blogger: soccer121.com's blog
I am currently trying to learn Python and the Betfair API. I can place bets OK using the following code....

def doWager(marketId, horseId, backOrLay, stake, price, persistence, appKey, sessionToken):
    bet_place_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": {"marketId": "' +marketId+ '","instructions": [{"selectionId": "' +horseId+ '", "handicap": "0", "side": "' +backOrLay+ '", "orderType": "LIMIT", "limitOrder": { "size": "' +stake+ '", "price": "' +price+ '", "persistenceType": "' +persistence+ '" } } ] }, "id": 1 }'
    bet_place_resp = callAping(bet_place_req, appKey, sessionToken)
    decodeBetResp = json.loads(bet_place_resp)
    return decodeBetResp['result']

Can anyone tell me how I can cancel a single bet using the BetId?

thanks,

Ross.
Pause • Switch to Standard View Python - cancel bet help required
Show More
Loading...
Report StefanBelo. • May 25, 2018 7:32 PM BST
let placeBet (marketId, selectionId) side size price = async {
        let! result = betfairServiceProvider.BettingOperations.PlaceOrder(marketId, selectionId, side, size, price)

        if result.IsSuccessResult
        then
            let placeExecutionReport = result.SuccessResult

            printfn "Bet ID: %s" placeExecutionReport.instructionReports.[0].betId
        else
            printfn "%s" result.FailureMessage
    }

    let cancelBet marketId betId = async {
        let instructions = [|
            { betId = betId; sizeReduction = Nullable() }
        |]

        let! result = betfairServiceProvider.BettingOperations.CancelOrders(marketId, instructions)

        if result.IsSuccessResult
        then
            result.SuccessResult.instructionReports
            |> Seq.iter (fun instructionReport -> printfn "Cancelled Bet ID: %s" instructionReport.instruction.betId)
        else
            printfn "%s" result.FailureMessage
    }
Post Your Reply
<CTRL+Enter> to submit
Please login to post a reply.

Wonder

Instance ID: 13539
www.betfair.com