# flūmine
[![Build Status](https://travis-ci.org/liampauling/flumine.svg?branch=master)](https://travis-ci.org/liampauling/flumine) [![Coverage Status](https://coveralls.io/repos/github/liampauling/flumine/badge.svg?branch=master)](https://coveralls.io/github/liampauling/flumine?branch=master) [![PyPI version](https://badge.fury.io/py/flumine.svg)](https://pypi.python.org/pypi/flumine)
Betfair trading framework with a focus on:
- simplicity
- modular
- pythonic
- rock-solid
- safe
Support for market and custom streaming data (order, score and custom polling data in development)
[docs](https://liampauling.github.io/flumine/)
[join slack group](https://betfairlightweight.herokuapp.com)
Currently tested on Python 3.6, 3.7 and 3.8.
## installation
```
$ pip install flumine
```
flumine requires Python 3.6+
## setup
Get started...
```python
import betfairlightweight
from flumine import Flumine, clients
trading = betfairlightweight.APIClient("username")
client = clients.BetfairClient(trading)
framework = Flumine(
client=client,
)
```
Example strategy:
```python
from flumine import BaseStrategy
from flumine.order.trade import Trade
from flumine.order.order import LimitOrder, OrderStatus
from flumine.markets.market import Market
from betfairlightweight.filters import streaming_market_filter
from betfairlightweight.resources import MarketBook
class ExampleStrategy(BaseStrategy):
def start(self) -> 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)
)
self.place_order(market, 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:
self.cancel_order(market, order, 0.02) # reduce size to 1.98
if order.order_type.persistence_type == 'LAPSE':
self.update_order(market, order, 'PERSIST')
if order.size_remaining > 0:
self.replace_order(market, order, 1.02) # move
strategy = ExampleStrategy(
market_filter=streaming_market_filter(
event_type_ids=["7"],
country_codes=["GB"],
market_types=["WIN"],
)
)
framework.add_strategy(strategy)
```
Run framework:
```python
framework.run()
```
## Features
- Streaming
- Multiple strategies
- Order execution
- Paper trading
- Back testing
- Analytics (in development)
- Middleware and background workers to enable Scores / RaceCard / InPlayService
## Dependencies
flumine relies on these libraries:
* `betfairlightweight` - Betfair API support
* `tenacity` - Used for connection retrying (streaming)
* `python-json-logger` - JSON logging
* `requests` - HTTP support
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
flumine-1.11.1.tar.gz (86个子文件)
flumine-1.11.1
PKG-INFO 530B
tests
test_worker.py 9KB
test_streams.py 22KB
test_utils.py 8KB
test_clients.py 8KB
test_simulated.py 23KB
test_middleware.py 11KB
test_baseflumine.py 16KB
test_trade.py 7KB
test_strategy.py 9KB
test_orderpackage.py 6KB
test_fluminebacktest.py 10KB
test_clientcontrols.py 6KB
test_integration.py 4KB
test_backtest_utils.py 772B
test_events.py 895B
__init__.py 0B
test_execution.py 49KB
test_responses.py 1KB
test_flumine.py 3KB
test_loggingcontrols.py 6KB
test_tradingcontrols.py 14KB
test_blotter.py 6KB
test_runnercontext.py 2KB
test_ordertype.py 4KB
test_markets.py 10KB
test_order.py 18KB
setup.cfg 38B
flumine
patching.py 1KB
controls
loggingcontrols.py 4KB
__init__.py 739B
clientcontrols.py 4KB
tradingcontrols.py 6KB
utils.py 6KB
execution
simulatedexecution.py 5KB
__init__.py 0B
betfairexecution.py 10KB
baseexecution.py 5KB
backtest
simulated.py 11KB
utils.py 1KB
backtest.py 6KB
__init__.py 0B
__init__.py 560B
baseflumine.py 13KB
flumine.py 3KB
strategy
strategy.py 7KB
__init__.py 0B
runnercontext.py 1KB
streams
datastream.py 4KB
historicalstream.py 4KB
streams.py 6KB
__init__.py 0B
simulatedorderstream.py 1KB
basestream.py 2KB
marketstream.py 2KB
orderstream.py 2KB
markets
market.py 4KB
blotter.py 4KB
markets.py 2KB
middleware.py 7KB
__init__.py 0B
config.py 383B
worker.py 7KB
events
events.py 3KB
__init__.py 0B
clients
backtestclient.py 1KB
clients.py 102B
baseclient.py 3KB
__init__.py 153B
betfairclient.py 4KB
__version__.py 190B
order
order.py 13KB
trade.py 6KB
responses.py 804B
__init__.py 0B
orderpackage.py 4KB
ordertype.py 3KB
process.py 3KB
exceptions.py 963B
setup.py 1KB
README.md 4KB
flumine.egg-info
PKG-INFO 530B
requires.txt 78B
SOURCES.txt 2KB
top_level.txt 14B
dependency_links.txt 1B
共 86 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功