Exemplo n.º 1
0
def main():
    print('Collecting data')
    scoreboards, box_scores = collectData(leagueID, seasonID, weeks, swid, espn_s2)

    print('Updating players')
    players = getPlayers(scoreboards, box_scores, league_size)
    players = getPoints(scoreboards, box_scores, players, weeks)
    players = updatePlayers(players)

    print('Creating graphs')
    graphPlayers(players)
    graphWeeks(players, weeks, league_size)
Exemplo n.º 2
0
def search(driver):
    cheapest = []

    # Used to find flights only during the university summer
    summerStart = datetime.date(2018, 5, 5)
    summerEnd = datetime.date(2018, 8, 15)

    # List of destinations
    searches = helpers.openCSV(paths.destinationsFile)
    destinations = helpers.destListToObject(searches)

    for dest in destinations:
        cheapFlight = collectData.collectData(driver=driver,
                                              departing='CVG',
                                              destination=dest.dest,
                                              tripLen=dest.tripLen,
                                              lowBound=summerStart,
                                              highBound=summerEnd)
        cheapest.append(cheapFlight)
    return cheapest
Exemplo n.º 3
0
import requests
import logging
import json
import csv
import time
from collections import defaultdict
from io import StringIO
import numpy as np
import pandas as pd
from collectData import collectData

cd = collectData()
res = cd.get_last_Games(40, 10)
cd.stat_by_f_id(res)
stat = cd.depart_statics()

with open('stat4010.json', 'w+') as f:
    json.dump(stat, f)

####################################  V  0.0 ################################
        rawdata[0][ii - 1] = raw[ii * 2 - 2] * 256 + raw[ii * 2 - 1]

        if rawdata[0][ii - 1] > (2**15 - 1):
            rawdata[0][ii - 1] = rawdata[0][ii - 1] - 2**16

    print('rawdata is completed')

    #a=readRawdata(ser, test_card-1)
    x, y = signal.welch(rawdata, 180e6)

# 	plt.figure()
# 	plt.plot(x,y.transpose())
# 	plt.title(test_card)

# plt.show()

actdet = np.zeros((1, 20))
actdet[0][10] = 1

# C=collectData.collectData(ser,1,[0],actdet,90)
C = collectData.collectData(ser, 1, [1], actdet, 90)

# plt.figure()
# plt.plot(np.abs(A[0][0][10][0][:]))

plt.show()
plt.figure()
plt.plot(abs(np.squeeze(C[0][0][10][0])))
plt.show()
Exemplo n.º 5
0
def main():
    """The brains of the bot
    Finds all the races
    """
    betfairClient = bfclient.BfClient()
    eventResponse = None
    race_list = None
    cardGenTime = 0
    login_timer = 0

    while True:
        login_rsp = auth.login(betfairClient)
        # Generate the list of available races. Limit the result to 100
        (race_list, cardGenTime) = gen_race_list(cardGenTime, race_list, betfairClient)
        # get the exchangeId, marketId for the next race and race_queue
        # refactor - turn into class, return object.
        (exchangeId, marketId, race_queue, race_list) = get_next_race(race_list)
        # determine race status, proceed if it is active.
        market_price = qwertymarket.getMarketPricesCompressed(betfairClient,
                                                            exchangeId,
                                                            marketId)
        market_status = qwertymarket.marketStatus(market_price)
        if market_status == 'CLOSED':
            logger.debug('Oops market is closed, finding the next race/market')
            time.sleep(2)
            continue
        elif market_status == 'SUSPENDED':
            logger.debug('Market is now suspended, finding the next race/market')
            time.sleep(5)
            continue
        # Great the next race is active, lets find out when it starts
        market_info = qwertymarket.getMarketInfo(betfairClient,
                                                exchangeId,
                                                marketId)
        TTL = qwertymarket.timeTillRaceStarts(market_info)
        logger.info('Time till live: %s', TTL)
        if TTL > 240: #if time till race is more than 5 minutes away
            handle_long_ttl(cardGenTime, race_list, market_info)
        elif market_price.marketPrices.delay > 0:
            logger.info("-------------Market is in-play---------------")
            time.sleep(10)
            continue
        # nested while true, why? Because we don't want it to change races if it's active.
        while True:
            try:
                collectData.collectData(betfairClient, exchangeId,
                                        marketId)
                timeId = collectData.Datastore[marketId]['timeId']
                IDgap = collectData.Datastore[marketId]['IDgap']
                if IDgap == 0:
                    time.sleep(2)
                    logger.debug('IDgap is zero')
                    continue #don't run anything else
            except IndexError:
                if handle_IndexError(betfairClient, exchangeId, marketId):
                    continue
                else:
                    break
            except ZeroDivisionError:
                logger.warning('Zero Division Exception caught.')
                break
            except bfpy.bferror.BfNetworkError:
                logger.error("Network timed out...retrying...")
                continue
            except Exception, e:
                logger.exception('Collecting data at timeId: %s', timeId)
                raise e
            try:
                play.inPlay(betfairClient, exchangeId, marketId, timeId)
                play.pastPlay(betfairClient, exchangeId, marketId, timeId)
            except play.InPlayClause as e:
                logger.debug('In Play is greater than 30 seconds, look for the next race')
                break
            except Exception as e:
                logger.exception('Running inPlay or pastPlay')
                raise e
            try:
                for fillInId in range(timeId-IDgap+1, timeId+1):
                    for selectionId in collectData.Datastore[marketId]['runnerKeys']:
                        if fillInId != timeId:
                            collectData.fillInMissingData(marketId, selectionId,
                                                        fillInId, timeId)
                        if fillInId >= 30:
                            selection.calculateTPS(marketId, selectionId, fillInId)
            except IndexError:
                if handle_IndexError(betfairClient, exchangeId, marketId):
                    continue
                else:
                    break
            except ZeroDivisionError:
                logger.warning('Zero Division Exception caught.')
                break
            except Exception, e:
                logger.exception('Filling missing data or calculating TPS at timeId: %s', timeId)
                raise e
            try:
                if timeId > 1: selection.selectionCriteria(marketId, timeId)
                for selectionId in collectData.Datastore[marketId]['selectedRunnerIds']:
                    if 'max30BP' not in collectData.Datastore[marketId][selectionId][0].keys():
                        for backCalc in range(0, timeId - IDgap+1):
                            analysis.analyse(marketId, selectionId, backCalc)
                            if backCalc == timeId - IDgap:
                                logger.info('Successful back analysis of %s to timeId %s',
                                            collectData.Datastore[marketId][selectionId]['HorseName'],
                                            backCalc)
                                collectData.Datastore[marketId][selectionId]['backCalc'] = backCalc
                    for fillInId in range(timeId-IDgap+1, timeId+1):
                        analysis.analyse(marketId, selectionId, fillInId)
            except IndexError:
                if handle_IndexError(betfairClient, exchangeId, marketId):
                    continue
                else:
                    break
            except ZeroDivisionError:
                logger.warning('Zero Division Exception caught.')
                break
            except Exception, e:
                logger.exception('Error: Running Analysis or selecting horses at timeId: %s',
                                timeId)
                logger.exception("timeId: %s", timeId)
                raise e
Exemplo n.º 6
0
 def test_collect_data(self):
     self.datastore = collectData.collectData(self.bf_client, self.exchangeId, self.marketId)
     self.assertIsNotNone(self.datastore)
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 29 12:47:13 2014

@author: Kevin Liang
This code is released under the MIT License.

main.py - Program's main. Code execution starts here.
"""
from calibrateSweepStart import calibrateSweepStart
from collectData import collectData
from createOutputFile import createOutputFile
from pins import pins

# Set up pins for trigger and detector
myPins = pins();

# Create file to record positions and time stamps
fo = createOutputFile('/media/PALMERI/',myPins)

# Wait for button press to calibrate starting arm position
# Create positionTracker object once button has been pushed
myPositionTracker = calibrateSweepStart(myPins)

# Main data collection loop
collectData(myPositionTracker,fo)

# Data Collection Finished
fo.close()