Ejemplo n.º 1
0
def pastPlay(betfairClient, exchangeId, marketId, timeId):
    """Clean up the race (delete betstore and datastore for that race)
    If timeId > 500 or timeId > 200 and no horses have been selected.
    Before deleting cancel any unmatched bets
    Executes clean_up
    """
    if ((timeId > 500 and collectData.Datastore[marketId]['inPlayDelay'] == 0) or
        (timeId > 200 and len(collectData.Datastore[marketId]['selectedRunnerIds']) == 0)):
        qwertybet.cancelBetsInMarket(betfairClient, marketId, timeId)
        cleanUp.clean_up(betfairClient, marketId)
        raise InPlayClause(1)
Ejemplo n.º 2
0
def inPlay(betfairClient, exchangeId, marketId, timeId):
    """
    This method handles the event when a market goes into play
    It monitors the event for 30 seconds before executing the clean up.
    """
    logger.debug('In Play Delay: %s', collectData.Datastore[marketId]['inPlayDelay'])
    if collectData.Datastore[marketId]['inPlayDelay'] > 0:
        #start counter for 30 seconds
        if 'initialInPlayTime' not in collectData.Datastore[marketId].keys():
            logger.info("~~~~~~~~~~~~~Market race has started!~~~~~~~~~~~~~")
            collectData.Datastore[marketId]['initialInPlayTime'] = collectData.Datastore[marketId]['timeDelta']
        logger.debug('Current time in play: %s',
                    (collectData.Datastore[marketId]['timeDelta'] -
                    collectData.Datastore[marketId]['initialInPlayTime']))
        if collectData.Datastore[marketId]['timeDelta'] - collectData.Datastore[marketId]['initialInPlayTime'] >= 30:
            qwertybet.cancelBetsInMarket(betfairClient, marketId, timeId)
            cleanUp.clean_up(betfairClient, marketId)
            raise InPlayClause(1)