Official Python client for the Lubit Energy Prediction Market API
Project description
python-lubit
Official Python client for the Lubit Energy Prediction Market API.
Trade on European electricity price movements with a parimutuel prediction market. Predict whether Day-Ahead prices will be higher, lower, or flat compared to Imbalance prices across 17 bidding zones.
Installation
pip install lubit
Or install from source:
git clone https://github.com/lubit-com/python-lubit.git
cd python-lubit
pip install -e .
Quick Start
from lubit import LubitClient
# Initialize client with your API credentials
client = LubitClient(
api_key="lbt_pk_your_key",
api_secret="lbt_sk_your_secret"
)
# Get your balance
balance = client.get_balance()
print(f"EUR Balance: {balance['eur_balance']}")
print(f"vEUR Balance: {balance['veur_balance']}")
# Get active markets for Denmark
markets = client.get_markets(zone="DK1", status="active")
for market in markets[:5]:
print(f"{market['market_id']}: {market['total_volume']} EUR")
# Place a position
result = client.place_position(
market_id="DK1_2025-12-23_14:00-15:00_H",
side="up",
amount=25,
currency="EUR"
)
print(f"Position placed! Potential return: {result['potential_return']} EUR")
API Overview
Authentication
Get your API credentials from lubit.com/account under the API Keys section.
client = LubitClient(
api_key="lbt_pk_xxx",
api_secret="lbt_sk_xxx"
)
Markets
# List markets with filters
markets = client.get_markets(
zone="DK1", # Bidding zone
country="DK", # Country code
date="2025-12-23", # Date (YYYY-MM-DD)
status="active" # active, closed, settled
)
# Get specific market details
market = client.get_market("DK1_2025-12-23_14:00-15:00_H")
print(f"UP odds: {market['up_odds']}x")
print(f"DOWN odds: {market['down_odds']}x")
print(f"FLAT odds: {market['flat_odds']}x")
# Get market trading history
history = client.get_market_history("DK1_2025-12-23_14:00-15:00_H")
Trading
# Place a single position
result = client.place_position(
market_id="DK1_2025-12-23_14:00-15:00_H",
side="up", # up, down, or flat
amount=25, # Minimum 1
currency="EUR" # EUR or vEUR
)
# Place multiple positions (atomic - all or none)
positions = [
{"market_id": "DK1_2025-12-23_00:00-01:00_H", "side": "up", "amount": 10},
{"market_id": "DK1_2025-12-23_01:00-02:00_H", "side": "down", "amount": 15},
{"market_id": "DK1_2025-12-23_02:00-03:00_H", "side": "flat", "amount": 20},
]
result = client.place_bulk_positions(positions, currency="EUR")
print(f"Total: {result['total_amount']} EUR")
Account
# Get balance
balance = client.get_balance()
print(f"EUR: {balance['eur_balance']}")
print(f"vEUR: {balance['veur_balance']}")
print(f"Open positions: {balance['open_positions']}")
# Get transactions
transactions = client.get_transactions(currency="EUR")
for t in transactions:
print(f"{t['created_at']}: {t['amount']} {t['currency']}")
Helper Functions
from lubit import get_hourly_market_ids, get_quarter_market_ids
# Generate all 24 hourly market IDs for a zone/date
hourly_ids = get_hourly_market_ids("DK1", "2025-12-23")
# ["DK1_2025-12-23_00:00-01:00_H", "DK1_2025-12-23_01:00-02:00_H", ...]
# Generate all 96 quarter-hour market IDs
quarter_ids = get_quarter_market_ids("DK1", "2025-12-23")
# ["DK1_2025-12-23_00:00-00:15_Q", "DK1_2025-12-23_00:15-00:30_Q", ...]
Market ID Format
Market IDs follow this format: {ZONE}_{DATE}_{TIME}_{TYPE}
- ZONE: Bidding zone (DK1, DK2, NO1-NO5, SE1-SE4, FI, DE-LU, AT, NL, BE)
- DATE: YYYY-MM-DD format
- TIME: HH:MM-HH:MM time slot
- TYPE: H (hourly) or Q (quarter-hour)
Examples:
DK1_2025-12-23_14:00-15:00_H- Hourly marketDK1_2025-12-23_14:00-14:15_Q- Quarter-hour market
Error Handling
from lubit import LubitClient, LubitAPIError
client = LubitClient(api_key="...", api_secret="...")
try:
result = client.place_position(
market_id="DK1_2025-12-23_14:00-15:00_H",
side="up",
amount=25
)
except LubitAPIError as e:
print(f"API Error: {e.message}")
print(f"Status code: {e.status_code}")
except ValueError as e:
print(f"Validation error: {e}")
Bidding Zones
| Country | Zones |
|---|---|
| Denmark | DK1, DK2 |
| Norway | NO1, NO2, NO3, NO4, NO5 |
| Sweden | SE1, SE2, SE3, SE4 |
| Finland | FI |
| Germany/Luxembourg | DE-LU |
| Austria | AT |
| Netherlands | NL |
| Belgium | BE |
Virtual Currency (vEUR)
New users receive 10,000 vEUR (virtual EUR) for risk-free practice trading. Use currency="vEUR" when placing positions to trade with virtual currency.
# Practice with virtual currency
result = client.place_position(
market_id="DK1_2025-12-23_14:00-15:00_H",
side="up",
amount=100,
currency="vEUR" # Uses virtual balance
)
Requirements
- Python 3.7+
- requests
License
MIT License - see LICENSE for details.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lubit-0.1.0.tar.gz.
File metadata
- Download URL: lubit-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9780347da688bb24a02803e2c944df7fe4090bbecd29a0b8e49c10c1c53cc2d
|
|
| MD5 |
c7084c844317aeaf90a0caaa521a4fb4
|
|
| BLAKE2b-256 |
bdfb35d7f81ad72d2ad701b7d159ef56ac5982681a0a437a6ec787becb965179
|
File details
Details for the file lubit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lubit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
893ec3165de46040ef160508b082c909df87540085c24eb3f1b400fdc87f91f3
|
|
| MD5 |
6cf5315bf6b9766bdaa5948c4cbab112
|
|
| BLAKE2b-256 |
4c08af50cda0435120c542c11118bd3918e15ad757452d0fcb64dd72f3d35491
|