flūmine
flumine is an open-source, event-based trading framework for sports betting, designed to simplify the development and execution of betting strategies on betting venues. flumine provides efficient handling of data streams, risk management, and execution capabilities.
join betcode slack group (2.5k+ members!)
overview
- Event-based Execution: Real-time execution of trading strategies based on incoming market events
- Custom Strategy Implementation: Easily define and implement trading strategies
- Risk Management: Integrated risk management tools to monitor and limit exposure
- Modular Design: Easily extendable and customizable components
- Simulation: Simulate strategies/execution using historical data
- Paper Trading: Test strategies in a simulated environment before going live
- Data: Support for market, order and custom streaming data
- Venues: Multi venue / concurrent venue support
venues
- Betfair
- Betdaq
- Betconnect (account/execution functionality)
- Smarkets (roadmap)
- Matchbook (roadmap)
- Polymarket (roadmap)
- Kalshi (roadmap)
- BetDEX (roadmap)
- Tote (roadmap)
Tested on Python 3.10, 3.11, 3.12, 3.13 and 3.14.
installation
$ pip install flumine
flumine requires Python 3.10+
setup
Get started...
import betfairlightweight
from flumine import Flumine, BaseStrategy, clients
from flumine.streams.betfairmarketstream import BetfairMarketStream
from betfairlightweight.filters import streaming_market_filter
# Define your strategy here
class ExampleStrategy(BaseStrategy):
def check_market_book(self, market, market_book) -> bool:
# process_market_book only executed if this returns True
return True
def process_market_book(self, market, market_book):
# Your strategy logic
pass
# Initialize your client
trading = betfairlightweight.APIClient("username")
client = clients.BetfairClient(trading)
# Initialize the framework
framework = Flumine(client)
# Add your strategy to the framework with a stream
framework.add_strategy(
ExampleStrategy(
stream=BetfairMarketStream(
market_filter=streaming_market_filter(
event_type_ids=["7"],
country_codes=["GB"],
market_types=["WIN"],
),
)
)
)
# Start the trading framework
framework.run()
Example strategy with logic and order execution:
import betfairlightweight
from flumine import Flumine, BaseStrategy, clients
from flumine.order.trade import Trade
from flumine.order.order import LimitOrder, OrderStatus
from flumine.markets.market import Market
from flumine.streams.betfairmarketstream import BetfairMarketStream
from betfairlightweight.filters import streaming_market_filter
from betfairlightweight.resources import MarketBook
class ExampleStrategy(BaseStrategy):
def start(self, flumine) -> None:
print("starting strategy 'ExampleStrategy'")
def check_market_book(self, market: Market, market_book: MarketBook) -> bool:
# process_market_book only executed if this returns True
if market_book.status != "CLOSED":
return True
def process_market_book(self, market: Market, market_book: MarketBook) -> None:
# process marketBook object
for runner in market_book.runners:
if runner.status == "ACTIVE" and runner.last_price_traded < 1.5:
trade = Trade(
market_id=market_book.market_id,
selection_id=runner.selection_id,
handicap=runner.handicap,
strategy=self
)
order = trade.create_order(
side="LAY",
order_type=LimitOrder(price=1.01, size=2.00)
)
market.place_order(order)
def process_orders(self, market: Market, orders: list) -> None:
for order in orders:
if order.status == OrderStatus.EXECUTABLE:
if order.size_remaining == 2.00:
market.cancel_order(order, 0.02) # reduce size to 1.98
if order.order_type.persistence_type == "LAPSE":
market.update_order(order, "PERSIST")
if order.size_remaining > 0:
market.replace_order(order, 1.02) # move
# Initialize your client
trading = betfairlightweight.APIClient("username")
client = clients.BetfairClient(trading)
# Initialize the framework
framework = Flumine(client)
# Add your strategy to the framework with a stream
framework.add_strategy(
ExampleStrategy(
stream=BetfairMarketStream(
market_filter=streaming_market_filter(
event_type_ids=["7"],
country_codes=["GB"],
market_types=["WIN"],
),
)
)
)
# Start the trading framework
framework.run()
features
- Streaming
- Multiple strategies
- Multiple clients
- Order execution
- Paper trading
- Simulation
- Event simulation (multi market)
- Middleware and background workers to enable Scores / RaceCard / InPlayService
dependencies
flumine relies on these libraries:
betfairlightweight- Betfair API supportbetdaq-retail- BETDAQ API supportbetconnect- BetConnect API supporttenacity- Used for connection retrying (streaming)python-json-logger- JSON loggingrequests- HTTP supportsmart-open- Efficient streaming of very large files from/to storages such as S3, including (de)compression
Release files for flumine 3.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flumine-3.2.3.tar.gz | 3.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flumine-3.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.4 MB
Release files / flumine-3.2.3.tar.gz
| Download URL | flumine-3.2.3.tar.gz |
|---|---|
| Size | 3.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e945076f813c73a766a46a9f5bc7fc5e875d68712d2b58ec9fd12c08d0b27dbf
|
|
BLAKE2b-256 checksum How to use checksums |
4368d1acab66ebc14e12e8548f77857f53b16166844cb6ca59018e057594a0ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / flumine-3.2.3-py3-none-any.whl
| Download URL | flumine-3.2.3-py3-none-any.whl |
|---|---|
| Size | 91.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec7f9f28e97f752bd88ea79b262b4c6c7e0d3abd780a8e63f121279ec53a743e
|
|
BLAKE2b-256 checksum How to use checksums |
08b5b97772df9604d09805f22e9f0801a8c6e3b2bfd111bdcf002b286ac30f77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|