I have been live testing my application and I would like to place an order just before the start of the race. The next event is found using the function supplied by Betfair. This can be seen below this text.
def getMarketCatalogueForNextGBWin(eventTypeID):
global now, market_catalouge_results, market_catalogue_req
if (eventTypeID is not None):
#print('Calling listMarketCatalouge Operation to get MarketID and selectionId')
now = datetime.datetime.now(pytz.timezone('GMT')).strfti me('%Y-%m-%dT%H:%M:%SZ')
#now = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
market_catalogue_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params": {"filter":{"eventTypeIds":["' + eventTypeID + '"],"marketCountries":["GB"],"marketTypeCodes":["WIN"],'\
'"marketStartTime":{"from":"' + now + '"}},"sort":"FIRST_TO_START","maxResults":"1","mar ketProjection":["RUNNER_METADATA"]}, "id": 1}'
"""
print market_catalogue_req
"""
market_catalogue_response = callAping(market_catalogue_req)
"""
print market_catalogue_response
"""
market_catalouge_loads = json.loads(market_catalogue_response)
try:
market_catalouge_results = market_catalouge_loads['result']
return market_catalouge_results
except:
print('Exception from API-NG' + str(market_catalouge_results['error']))
exit()
To do this I use a scheduler to run my function 1 minute before the start of the race. This sometimes gets market for the next race but often gets the market that follows the next one.
To resolve this issue I have considered running the function every second and append the market ID to a list. Then if the market ID changes to run my place order function. This should catch all the markets. The problem though with this is that I want to place my order just before the race starts and this method will not do this.
Is there any way to place an order just before a race starts?
Cheers,
Sandy
def getMarketCatalogueForNextGBWin(eventTypeID):
global now, market_catalouge_results, market_catalogue_req
if (eventTypeID is not None):
#print('Calling listMarketCatalouge Operation to get MarketID and selectionId')
now = datetime.datetime.now(pytz.timezone('GMT')).strfti me('%Y-%m-%dT%H:%M:%SZ')
#now = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
market_catalogue_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params": {"filter":{"eventTypeIds":["' + eventTypeID + '"],"marketCountries":["GB"],"marketTypeCodes":["WIN"],'\
'"marketStartTime":{"from":"' + now + '"}},"sort":"FIRST_TO_START","maxResults":"1","mar ketProjection":["RUNNER_METADATA"]}, "id": 1}'
"""
print market_catalogue_req
"""
market_catalogue_response = callAping(market_catalogue_req)
"""
print market_catalogue_response
"""
market_catalouge_loads = json.loads(market_catalogue_response)
try:
market_catalouge_results = market_catalouge_loads['result']
return market_catalouge_results
except:
print('Exception from API-NG' + str(market_catalouge_results['error']))
exit()
To do this I use a scheduler to run my function 1 minute before the start of the race. This sometimes gets market for the next race but often gets the market that follows the next one.
To resolve this issue I have considered running the function every second and append the market ID to a list. Then if the market ID changes to run my place order function. This should catch all the markets. The problem though with this is that I want to place my order just before the race starts and this method will not do this.
Is there any way to place an order just before a race starts?
Cheers,
Sandy


Comment