Hi,
I bought a kindle book that teaches how to make a betfair bot. I'm half way through and really unimpressed at all the spelling mistakes and code errors, but nevertheless I'd like to get it working if I can.
It uses Windows Powershell and I'm running into two errors when trying to place a bet.
1. The [0] index in
returns the 2nd result, [1] returns the 1st result and [2] returns the 3rd result.
2. When I run $bet I get error
I can post more code if it's needed.
Any idea where I'm going wrong?
I bought a kindle book that teaches how to make a betfair bot. I'm half way through and really unimpressed at all the spelling mistakes and code errors, but nevertheless I'd like to get it working if I can.
It uses Windows Powershell and I'm running into two errors when trying to place a bet.
1. The [0] index in
Code:
$selectionId = $getmarketbook.result.runners[0].selectionId
2. When I run $bet I get error
Code:
jsonrpc error ------- ----- 2.0 @{code=-32602; message=DSC-0018}
Code:
############################# #Places a Back Bet we pass the function to the following variables $selectionId,$Odds,$marketID,$stake ############################# Function placebet { $method = "SportsAPING/v1.0/placeOrders" $postdata = [ORDERED]@{"jsonrpc" = "2.0"; "method" = $method "params" = @{"marketIds" = @($marketID);"instructions"=[object[]][ORDERED]@{"selectionId" = [int]$selectionId;"side" = "BACK";"orderType" = "LIMIT"; "limitOrder" = [ORDERED]@{"size"=$stake;"price"=$Odds;"persistenceType"="LAPSE";} }} } $postdata = $postdata | ConvertTo-Json -depth 7 $bet = invoke-webrequest -uri https://api.betfair.com/exchange/betting/json-rpc/v1 -Method Post -Headers @{"X-Application"="XXXXXXX";"X-Authentication"=$sessiontoken} -ContentType "application/json" -body $postdata $bet | convertfrom-json } ############################# #MAIN CODE SECTION ############################# $cert = get-cert $RET = login $cert $sessiontoken = $RET.sessiontoken $stake = get-account $races = get-marketcatalogue $UKracearray = @() foreach($race in $races.result) {If ($race.event.countrycode -eq "GB") {$UKracearray += $race} } $marketID = $UKracearray[0].marketID $getmarketbook = get-marketbook $marketID $getmarketbook.result.runners | sort lastPriceTraded $selectionId = $getmarketbook.result.runners[0].selectionId $Odds = $getmarketbook.result.runners[0].lastPriceTraded $bet = placebet $selectionId,$Odds,$marketID,$stake
I can post more code if it's needed.
Any idea where I'm going wrong?
Comment