All Projects → liampauling → Betfair

liampauling / Betfair

Licence: mit
betfairlightweight - python wrapper for Betfair API-NG (with streaming)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Betfair

Poloniex
Poloniex python API client for humans
Stars: ✭ 71 (-71.14%)
Mutual labels:  api-wrapper, trading
Python Poloniex
Poloniex API wrapper for Python 2.7 & 3
Stars: ✭ 557 (+126.42%)
Mutual labels:  api-wrapper, trading
gemini-python
A python client for the Gemini API and Websocket
Stars: ✭ 71 (-71.14%)
Mutual labels:  trading, api-wrapper
Iexcloud api wrapper
iexcloud api wrapper written in typescript (asynchronous interface)
Stars: ✭ 80 (-67.48%)
Mutual labels:  api-wrapper, trading
Tributary
Streaming reactive and dataflow graphs in Python
Stars: ✭ 231 (-6.1%)
Mutual labels:  streaming
Deep rl trader
Trading Environment(OpenAI Gym) + DDQN (Keras-RL)
Stars: ✭ 222 (-9.76%)
Mutual labels:  trading
Ccxt Rest
Open Source Unified REST API of 100+ Crypto Exchange Sites (18k+ docker pulls) - https://ccxt-rest.io/
Stars: ✭ 210 (-14.63%)
Mutual labels:  trading
Binance Trader
Experimental trading bot for crypto currency on Binance.com
Stars: ✭ 218 (-11.38%)
Mutual labels:  trading
Data Accelerator
Data Accelerator for Apache Spark simplifies onboarding to Streaming of Big Data. It offers a rich, easy to use experience to help with creation, editing and management of Spark jobs on Azure HDInsights or Databricks while enabling the full power of the Spark engine.
Stars: ✭ 247 (+0.41%)
Mutual labels:  streaming
Xboxkeyboardmouse
Keyboard and mouse for Xbox One streaming on Windows 10
Stars: ✭ 235 (-4.47%)
Mutual labels:  streaming
Deep Rl Trading
playing idealized trading games with deep reinforcement learning
Stars: ✭ 228 (-7.32%)
Mutual labels:  trading
Nginx Rtmp Monitoring
real-time monitoring statistics dashboard for nginx rtmp module
Stars: ✭ 224 (-8.94%)
Mutual labels:  streaming
Bitcoin Price Prediction
Bayesian regression for latent source model and Bitcoin
Stars: ✭ 234 (-4.88%)
Mutual labels:  trading
Hls Vod
HTTP Live Streaming with on-the-fly encoding of any video file for Web/Apple TV/iPhone/iPad/iPod
Stars: ✭ 221 (-10.16%)
Mutual labels:  streaming
Specification
OpenMessaging Specification
Stars: ✭ 242 (-1.63%)
Mutual labels:  streaming
Philadelphia
Low-latency Financial Information Exchange (FIX) engine for the JVM
Stars: ✭ 219 (-10.98%)
Mutual labels:  trading
Cryptotrader
A cryptocurrency trader for all famous exchanges
Stars: ✭ 228 (-7.32%)
Mutual labels:  trading
Python Scrapyd Api
A Python wrapper for working with Scrapyd's API.
Stars: ✭ 235 (-4.47%)
Mutual labels:  api-wrapper
Vnpy
基于Python的开源量化交易平台开发框架
Stars: ✭ 17,054 (+6832.52%)
Mutual labels:  trading
Materialize
Materialize lets you ask questions of your live data, which it answers and then maintains for you as your data continue to change. The moment you need a refreshed answer, you can get it in milliseconds. Materialize is designed to help you interactively explore your streaming data, perform data warehousing analytics against live relational data, or just increase the freshness and reduce the load of your dashboard and monitoring tasks.
Stars: ✭ 3,341 (+1258.13%)
Mutual labels:  streaming

betfairlightweight

Build Status Coverage Status PyPI version Downloads

Lightweight, super fast (uses C and Rust libraries) pythonic wrapper for Betfair API-NG allowing all betting operations (including market and order streaming) and account operations, see examples.

docs

join slack group

Currently tested on Python 3.6, 3.7, 3.8 and 3.9.

installation

$ pip install betfairlightweight

To use C/Rust libraries install with

$ pip install betfairlightweight[speed]

setup

In order to connect to the Betfair API you will need an App Key, SSL Certificates and a username/password.

App Key

Follow these instructions to get your app key, you can either use a delayed or live key.

SSL certificates

Follow these instructions to set up your SSL certificates. Save your .ctr and .key files to a local directory. The default directory where the library is looking for the keys is '/certs' but you can specify any other directory.

Using the library

The library can then be used as follows:

import betfairlightweight

trading = betfairlightweight.APIClient('username', 'password', app_key='app_key', certs='/certs')

trading.login()

or the following for interactive login with no certs (not as secure)

import betfairlightweight

trading = betfairlightweight.APIClient('username', 'password', app_key='app_key')

trading.login_interactive()
event_types = trading.betting.list_event_types()

[<EventTypeResult>, <EventTypeResult>, ..]

Following endpoints are available:

streaming

Currently two listeners available, below will run the base listener which prints anything it receives. Stream listener is able to hold an order stream or a market stream (one per listener). The listener can hold a cache and push market_books/order_books out via a queue.

Exchange Stream API

from betfairlightweight.filters import (
    streaming_market_filter,
    streaming_market_data_filter,
)

betfair_socket = trading.streaming.create_stream()

market_filter = streaming_market_filter(
    event_type_ids=['7'],
    country_codes=['IE'],
    market_types=['WIN'],
)
market_data_filter = streaming_market_data_filter(
    fields=['EX_ALL_OFFERS', 'EX_MARKET_DEF'],
    ladder_levels=3
)

betfair_socket.subscribe_to_markets(
    market_filter=market_filter,
    market_data_filter=market_data_filter,
)

betfair_socket.start()  # blocking

historic data

The historic endpoint provides some basic abstraction for the historicdata api:

Historic Data API

trading.historic.get_my_data()

[{'plan': 'Basic Plan', 'purchaseItemId': 1343, 'sport': 'Cricket', 'forDate': '2017-06-01T00:00:00'}]

Taking advantage of the streaming code lightweight can parse/output historical data in the same way it process streaming data allowing backtesting or with a custom listener, csv creation (see examples).

Historic Data

stream = trading.streaming.create_historical_stream(
    file_path='horse-racing-pro-sample',
)

stream.start()

or use the stream generator:

stream = trading.streaming.create_historical_generator_stream(
    file_path='horse-racing-pro-sample',
)

g = stream.get_generator()

for market_books in g():
    print(market_books)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].