使用betfair API下达多个订单

时间:2019-03-16 16:53:56

标签: python function api for-loop betfair

我正在使用betfair API,并且希望对选择ID和大小存储在datframe中的赌注进行多次下注。

以下是我使用的数据框类型的示例:

Longitude

我想将import pandas as pd data = {'selectionId': [8567238,7450487,12787737,9541421,10162696,7208966,8826166,7256678], 'Price': [4.1,4.6,5.5,7.2,7.8,17.0,32.0,34.0], 'Win_Percentage': [0.245870,0.212396,0.178922,0.145448,0.111974,0.078501,0.045027,0.011553], 'Fit':[0.245870,0.212396,0.178922,0.145448,0.111974,0.078501,0.045027,0.011553], 'size':[2.708701,2.373962,2.039223,1.704484,1.369744,1.035005,0.700266,0.365527]} df = pd.DataFrame(data, columns=['selectionId', 'Price', 'Win_Percentage','Fit','size']) selectionId列传递给以下函数:

size

为此,我像这样调用函数:

def placeFailingBet(marketId, selectionId, size):
    if( marketId is not None and selectionId is not None):
        print ('Calling placeOrder for marketId :' + marketId + ' with selection id :' + str(selectionId))
        place_order_Req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": {"marketId":"' + marketId + '","instructions":'\
                                                                                                                              '[{"selectionId":"' + str(
            selectionId) + '","handicap":"0","side":"BACK","orderType":"LIMIT","limitOrder":{"size":' \
                      + str(size) + ',"price":"1.50","persistenceType":"LAPSE"}}],"customerRef":"test12121212121"}, "id": 1}'
        """
print(place_order_Req)
"""
        place_order_Response = callAping(place_order_Req)
        place_order_load = json.loads(place_order_Response)
        try:
            place_order_result = place_order_load['result']
            print ('Place order status is ' + place_order_result['status'])
            """
print('Place order error status is ' + place_order_result['errorCode'])
"""
            print ('Reason for Place order failure is ' + place_order_result['instructionReports'][0]['errorCode'])
        except:
            print ('Exception from API-NG' + str(place_order_result['error']))
        """
print(place_order_Response)
"""


url = "https://api.betfair.com/exchange/betting/json-rpc/v1"

"""
headers = { 'X-Application' : 'xxxxxx', 'X-Authentication' : 'xxxxx' ,'content-type' : 'application/json' }
"""

args = len(sys.argv)

if ( args < 3):
    print ('Please provide Application key and session token')
    appKey = input('Enter your application key :')
    sessionToken = input('Enter your session Token/SSOID :')
    print ('Thanks for the input provided')
else:
    appKey = sys.argv[1]
    sessionToken = sys.argv[2]

headers = {'X-Application': appKey, 'X-Authentication': sessionToken, 'content-type': 'application/json'}

eventTypesResult = getEventTypes()
horseRacingEventTypeID = getEventTypeIDForEventTypeName(eventTypesResult, 'Horse Racing')

print ('Eventype Id for Horse Racing is :' + str(horseRacingEventTypeID))

marketCatalogueResult = getMarketCatalogueForNextGBWin(horseRacingEventTypeID)
marketid = getMarketId(marketCatalogueResult)
runnerId = getSelectionId(marketCatalogueResult)
"""
print(marketid)
print(runnerId)
"""
market_book_result = getMarketBookBestOffers(marketid)

这适用于第一行,但其他所有行由于某种原因均不起作用。

0 个答案:

没有答案