def cancelBetsInMarket(betfairClient, marketId, timeId): strategy.betsInMarket(betfairClient, marketId, timeId) for selectionId in collectData.Datastore[marketId]['selectedRunnerIds']: if marketId in strategy.Betstore.keys(): for betId in strategy.Betstore[marketId][selectionId]['Records'].keys(): for transactionId in strategy.Betstore[marketId][selectionId]['Records'][betId].keys(): if strategy.Betstore[marketId][selectionId]['Records'][betId][transactionId].betStatus != 'M': qwertybet.cancelBet(betfairClient, collectData.Datastore[marketId]['exchange'], betId)
time.sleep(10) market_price = qwertymarket.getMarketPricesCompressed(betfairClient, exchangeId, marketId) market_status = qwertymarket.marketStatus(market_price) if market_status != 'ACTIVE': cleanUp.clean_up(betfairClient, marketId) break else: continue if collectData.Datastore[marketId]['selectedRunnerIds']: logger.debug('Selected RunnerIds: %s', collectData.Datastore[marketId]['selectedRunnerIds']) if timeId >= 30: try: strategy.betsInMarket(betfairClient, marketId, timeId) logger.debug('Running strategy...') for selectionId in collectData.Datastore[marketId]['selectedRunnerIds']: strategy.RunStrategy(betfairClient, marketId, selectionId, timeId) logger.debug('strategy calculation success.') except IndexError: if handle_IndexError(betfairClient, exchangeId, marketId): continue else: break except Exception, e: logger.exception("Running strategy") raise e time.sleep(1.5) else: