Forums

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.
Share |
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

New to Betfair?

You need to open an account before you can add content to the forum.

Opening an account only takes a few minutes.

register now