def run(self, username='', password='', app_key='', aus=False): # create the API object self.username = username self.api = API(aus, ssl_prefix=username) self.api.app_key = app_key self.logger = Logger(aus) self.logger.bot_version = __version__ # login to betfair api-ng self.do_login(username, password) while self.session: self.do_throttle() self.keep_alive() eventTypeId = self.selectEventType() #e.g select Sport eventId = self.selectEvent(eventTypeId) #e.g select Match eventMarkets = self.getMarkets( eventId) #all markets for selected Match #self.prettyPrint(eventMarkets) over_unders = self.selectOverUnders( eventMarkets ) #subset of eventMarkets i.e only Over/Under x.5's print('\nList of Over/Under x.5 markets: ') for market in over_unders: print(market["marketName"] ) #print list of available Over/Under x.5's illiquidChoice = input("Select arbitrage-market from list: \n") illiquidMarketId = self.selectMarkets( illiquidChoice, eventMarkets) #select appropriate x.5 market #print("IlliquidMarketId: "+ str(illiquidMarketId)) liquidMarketId = self.selectMarkets( 'Correct Score', eventMarkets) #Correct Score market, automatically selected if (liquidMarketId == []): print( "Correct Score Market not available for this event. Please select another: " ) continue marketIds = self.combineMarkets(liquidMarketId, illiquidMarketId) lockIn = True skip = False inputList = [] while lockIn: marketBooks = self.getMarketPrices(marketIds) #dict encapsulatedBook = self.encapsulatePrices( marketBooks, eventMarkets) #object if (len(inputList) == 0): encapsulatedBook.print_liquidities() encapsulatedBook.getLiquidMarket().printRunners() inputList = input( "Select runners from 'Correct-Score' market. Seperate with ',':\n" ) #skip = True encapsulatedBook.getLiquidMarket().selectRunners(inputList) #encapsulatedBook.printBooks() encapsulatedBook.callArbitrage() #lockIn = False #self.session = False if not self.session: msg = 'SESSION TIMEOUT' print(msg)
def run(self, username = '', password = '', app_key = '', aus = False): # create the API object self.username = username self.api = API(aus, ssl_prefix = username) self.api.app_key = app_key self.logger = Logger(aus) self.logger.bot_version = __version__ # login to betfair api-ng self.do_login(username, password) while self.session: self.do_throttle() self.keep_alive() eventTypeId = self.selectEventType() #e.g returns 1 for Soccer eventId = self.selectEvent(eventTypeId) #e.g return 27632951 for Lucena CF v Coria CF eventMarkets = self.getMarkets(eventId) #returns all markets for a given event #self.prettyPrint(eventMarkets) # --------------- # #At this point we need to jump directly into selecting arb-choices # --------------- # for market in eventMarkets: print(market["marketName"]) liquidChoices = input("Input liquid markets. Note: max = 2. Separate using ',' and no spaces between choices:\n") liquidMarketIds = self.selectMarkets(liquidChoices, eventMarkets) illiquidChoices = input("Input Non-liquid markets. Note: max = 2. Separate using ',' and no spaces between choices:\n") illiquidMarketIds = self.selectMarkets(illiquidChoices, eventMarkets) marketIds = self.combineMarkets(liquidMarketIds, illiquidMarketIds) print("\nAcquired choice Ids: ") for each in marketIds: print(each) lockIn = True while lockIn: marketBooks = self.getMarketPrices(marketIds) #returns array of marketbooks for each selected market #self.prettyPrint(marketBooks) #self.printPrices(marketBooks) encapsulatedBook = self.encapsulatePrices(marketBooks, eventMarkets) #encapsulatedBook.printBooks() encapsulatedBook.callArbitrage() #lockIn = False #self.session = False if not self.session: msg = 'SESSION TIMEOUT' print(msg)
def soccer_run(self, username = '', password = '', app_key = '', aus = False): self.username = username self.api = API(aus, ssl_prefix = username) self.api.app_key = app_key self.logger = Logger(aus) self.logger.bot_version = __version__ # login to betfair api-ng self.do_login(username, password) while self.session: self.do_throttle() self.keep_alive() eventTypeId = 1 #Soccer eventId = self.selectEvent(eventTypeId) eventMarkets = self.showMarkets(eventId) #returns all markets for a given event for market in eventMarkets: print(market["marketName"]) liquidMarkets = self.selectMarkets('Correct Score', eventMarkets) print("Correct Score market has been set as Liquid market. Select Choice of Over-Under:\n") illiquidChoices = input("Input Non-liquid markets. Note: max = 2. Separate using ',' and no spaces between choices:\n") illiquidMarketIds = self.selectMarkets(illiquidChoices, eventMarkets) marketIds = self.combineMarkets(liquidMarketIds, illiquidMarketIds) print("\nAcquired choice Ids: ") for each in marketIds: print(each) lockIn = True while lockIn: marketBooks = self.getMarketPrices(marketIds) #returns array of marketbooks for each selected market #self.prettyPrint(marketBooks) #self.printPrices(marketBooks) encapsulatedBook = self.encapsulatePrices(marketBooks, eventMarkets) #encapsulatedBook.printBooks() encapsulatedBook.callArbitrage() #lockIn = False #self.session = False if not self.session: msg = 'SESSION TIMEOUT' print(msg)
# Retrieve live mode status from the environment (defaults to False) LIVE_MODE = 'LIVE_MODE' in os.environ and os.environ['LIVE_MODE'] == 'true' if not USERNAME: logger.error('BETFAIR_USERNAME is not set, exiting.') exit() if not PASSWORD: logger.error('BETFAIR_PASSWORD is not set, exiting.') exit() if not APP_KEY: logger.error('BETFAIR_APP_KEY is not set, exiting.') exit() api = API(False, ssl_prefix=USERNAME) session_manager = threads.SessionManager(api, USERNAME, PASSWORD, APP_KEY) session_manager.start() sleep(5) # Allow the session manager time to log in. market_manager = threads.MarketManager(api) market_book_manager = threads.MarketBookManager(api) statistics_manager = threads.StatisticsManager(api) account_manager = threads.AccountManager(api) order_manager = threads.OrderManager(api) report_manager = threads.ReportManager(api) strategy_manager = threads.StrategyManager(api, LIVE_MODE) result_scraper = threads.ResultScraper() market_manager.start() market_book_manager.start()
def run(self, username='', password='', app_key='', aus=False): # create the API object self.username = username self.api = API(aus, ssl_prefix=username) self.api.app_key = app_key self.logger = Logger(aus) self.logger.bot_version = __version__ # login to betfair api-ng self.do_login(username, password) while self.session: self.do_throttle() self.keep_alive() #Get and display all events eventsList = self.api.get_event_types() ###user interaction #print(json.dumps(eventsList,sort_keys=True,indent=4,separators=(',',': '))) print('Here are the list of available events: ') for event in eventsList: eventName = event['eventType']['name'] print(eventName) #eg: Soccer eventChoice = input('Please input an option from the above list: ') ###Get Id of selected event eventId = None for event in eventsList: eventName = event['eventType']['name'] eventId = None if (eventName == eventChoice): eventId = event['eventType']['id'] else: continue break ###Display all markets for selected event eventMarkets = self.api.get_market_types( {'eventTypeIds': [eventId]}) for market in eventMarkets: print(market["marketType"]) #eg: OVER_UNDER_15 marketChoice = input( "Please select from the list of available Markets below: ") print("You selected " + marketChoice) ###Get market-catalogue for user selected event marketCatalogue = self.getMarketCatalogue(eventId, marketChoice) print("This is the list of runners to bet on in the " + marketChoice + " market:") for runner in marketCatalogue[0]["runners"]: print(runner["runnerName"]) #eg: Under 1.5 goals ###Get market and selection (i.e runner) ids #self.prettyPrint(marketCatalogue) market_id = self.getMarketId(marketCatalogue) print("Market " + marketChoice + " has id: " + market_id) selection_id = self.getSelectionId(marketCatalogue) print("selction_id: " + str(selection_id)) ###Get Market Book - best offers only marketBook = self.getMarketBookBestOffers(market_id) self.printPrices(marketBook) #sign_out? self.session = False if not self.session: msg = 'SESSION TIMEOUT' print(msg)