Hello,
After looking at several posts, codes, etc...I am trying to place my first order and I run to this error which seems to be easy to resolve but I'm unable. Any help out there?
To make it simple I fixed the marketid, selectionid in the scipt
________
#!/usr/bin/python
# coding:UTF-8
import urllib2
import json
import datetime
import sys
import requests
import urllib
import sqlite3
def callAping(url, request):
try:
req = urllib2.Request(url, request, headers)
response = urllib2.urlopen(req)
jsonResponse = response.read()
return jsonResponse
except urllib2.URLError:
print 'Oops there is some issue with the request'
exit()
except urllib2.HTTPError:
print 'Oops there is some issue with the request' + urllib2.HTTPError.getcode()
exit()
def placeBet(marketId, selectionId):
if( marketId is not None and selectionId is not None):
print 'Calling placeOrder for marketId :' + marketId + ' with selection id :' + str(selectionId)
place_order_Req = '{"marketId":"' + marketId + '","instructions":'\
'[{"selectionId":"' + str(
selectionId) + '","handicap":"0","side":"BACK","orderType":"LIMIT ","limitOrder":{"size":"4.00","price":"1.8","persi stenceType":"LAPSE"}}],"customerRef":"test12121212121"}'
endPoint = 'https://beta-api.betfair.com/rest/v1.0/placeOrders/'
"""
print place_order_Req
"""
place_order_Response = callAping(endPoint, place_order_Req)
place_order_load = json.loads(place_order_Response)
print 'Place order status is ' + place_order_load['status']
"""
print 'Place order error status is ' + place_order_load['errorCode']
"""
print 'Reason for Place order failure is ' + place_order_load['instructionReports'][0]['errorCode']
"""
print place_order_Response
"""
placeBet(1.122709508, 47973)
________
the error message:
./PlaceOrder.py
Traceback (most recent call last):
File "./PlaceOrder.py", line 46, in <module>
placeBet(1.122709508, 47973)
File "./PlaceOrder.py", line 27, in placeBet
print 'Calling placeOrder for marketId :' + marketId + ' with selection id :' + str(selectionId)
TypeError: cannot concatenate 'str' and 'float' objects
After looking at several posts, codes, etc...I am trying to place my first order and I run to this error which seems to be easy to resolve but I'm unable. Any help out there?
To make it simple I fixed the marketid, selectionid in the scipt
________
#!/usr/bin/python
# coding:UTF-8
import urllib2
import json
import datetime
import sys
import requests
import urllib
import sqlite3
def callAping(url, request):
try:
req = urllib2.Request(url, request, headers)
response = urllib2.urlopen(req)
jsonResponse = response.read()
return jsonResponse
except urllib2.URLError:
print 'Oops there is some issue with the request'
exit()
except urllib2.HTTPError:
print 'Oops there is some issue with the request' + urllib2.HTTPError.getcode()
exit()
def placeBet(marketId, selectionId):
if( marketId is not None and selectionId is not None):
print 'Calling placeOrder for marketId :' + marketId + ' with selection id :' + str(selectionId)
place_order_Req = '{"marketId":"' + marketId + '","instructions":'\
'[{"selectionId":"' + str(
selectionId) + '","handicap":"0","side":"BACK","orderType":"LIMIT ","limitOrder":{"size":"4.00","price":"1.8","persi stenceType":"LAPSE"}}],"customerRef":"test12121212121"}'
endPoint = 'https://beta-api.betfair.com/rest/v1.0/placeOrders/'
"""
print place_order_Req
"""
place_order_Response = callAping(endPoint, place_order_Req)
place_order_load = json.loads(place_order_Response)
print 'Place order status is ' + place_order_load['status']
"""
print 'Place order error status is ' + place_order_load['errorCode']
"""
print 'Reason for Place order failure is ' + place_order_load['instructionReports'][0]['errorCode']
"""
print place_order_Response
"""
placeBet(1.122709508, 47973)
________
the error message:
./PlaceOrder.py
Traceback (most recent call last):
File "./PlaceOrder.py", line 46, in <module>
placeBet(1.122709508, 47973)
File "./PlaceOrder.py", line 27, in placeBet
print 'Calling placeOrder for marketId :' + marketId + ' with selection id :' + str(selectionId)
TypeError: cannot concatenate 'str' and 'float' objects


Comment