Skip to content

Instantly share code, notes, and snippets.

import bz2
import os
import fileinput
from betfairlightweight import APIClient
from betfairlightweight.streaming import StreamListener, MarketStream
import csv
import pandas
class HistoricalStream(MarketStream):
def __init__(self, listener):
from __future__ import absolute_import , unicode_literals
import requests
import django
from betfairlightweight.endpoints import Betting
django.setup()
import datetime
import logging
import re
update_bf.py
from trader.tasks import BFCommand
import sys
class Command(BFCommand):
help = 'Refreshes betfair NI data'
def handle(self, *args, **options):
self.betfair_get(False,0)
sys.exit()
[
{
"TIMESTAMP": "2018-09-05 22:59:44.398534",
"id": 900652866170042,
"name": "C Suarez Navarro vs M Keys",
"sport-id": 9,
"start": "2018-09-05T23:10:00.000Z",
"in-running-flag": false,
"allow-live-betting": true,
"category-id": [
This file has been truncated, but you can view the full file.
[
{
"TIMESTAMP": "2018-09-17 00:09:21.499540",
"id": 910569150160041,
"name": "A Rus vs V Flink",
"sport-id": 9,
"start": "2018-09-17T02:00:00.000Z",
"in-running-flag": false,
"allow-live-betting": true,
"category-id": [
from __future__ import absolute_import, unicode_literals
from django.core.management.base import BaseCommand, CommandError
from backend.models import MBEvent, MBMarkets, MBRun, MBPrice
import requests
from matchbook.endpoints.betting import Betting
from matchbook.enums import Side, Status, AggregationType
from django.conf import settings
from django.utils import timezone
from backend.client import get_mb_client
from matchbook.endpoints.marketdata import MarketData
[{"TIMESTAMP": "2019-01-17 12:10:23.801283", "id": 1015917799320016, "name": "Alexander Zverev vs Jeremy Chardy", "sport-id": 9, "start": "2019-01-17T09:29:00.000Z", "in-running-flag": true, "allow-live-betting": true, "category-id": [9, 319515298390018, 380069543210027, 410468520880009, 647093922800012, 690300107130014, 1005847502570016], "status": "open", "volume": 54528.13359, "event-participants": [{"id": 1015917799610016, "event-id": 1015917799320016, "participant-name": "Jeremy Chardy", "number": 2}, {"id": 1015917799760015, "event-id": 1015917799320016, "participant-name": "Alexander Zverev", "number": 1}], "markets": [{"live": true, "event-id": 1015917799320016, "id": 1015917800140015, "name": "Moneyline", "runners": [{"withdrawn": false, "prices": [{"available-amount": 1038.04204, "currency": "EUR", "odds-type": "DECIMAL", "odds": 1.10638, "decimal-odds": 1.10638, "side": "back", "exchange-type": "back-lay"}, {"available-amount": 923.42189, "currency": "EUR", "odds-type": "DECIMAL", "odds": 1.10526,
{"count":1,"next":null,"previous":null,"results":[{"balance":10.0,"exposure":7.0,"free_funds":5.0}]}
{"count":1,"next":null,"previous":null,"results":[{"balance":10.0,"exposure":7.0,"free_funds":5.0}]}
IndexError Traceback (most recent call last)
<ipython-input-68-525af8799900> in <module>
5 return e_push_count.loc[e_push_count['mini_e'] < row['push_count']].iloc[-1]['percent_e']
6
----> 7 df2['push_count_score'] = df.apply(add_push_count, axis=1)
8
9
c:\Users\Thomas Callaghan\PycharmProjects\SFDCAPI\venv\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, broadcast, raw, reduce, result_type, args, **kwds)
6485 args=args,