More documentation

This commit is contained in:
Jacob Plaster
2018-11-16 15:15:56 +00:00
parent 37eb69be72
commit 2b48a54603
2 changed files with 34 additions and 26 deletions

View File

@@ -1,28 +1,37 @@
# Official Python `bfxapi`
This repo contains an official python library that is used to connect to the both the Bitfinex api and the Honey Frameworks data-server. The library communicates with these servers using both websocket connection and a REST interface.
This repo contains an official python library that is used to connect to the both the Bitfinex api and the Honey Frameworks data-server. The library communicates with these servers using both websockets connection and a its REST interface.
Install dependencies
```
pip3 install -r requirements.txt
```
Run the trades/candles example:
```
cd bfxapi/examples
python3 subsribe_trades_candles.py
```
## `bfxapi.LiveWebsocket`
The websocket exposes a collection of events that are triggered when certain data is received. When subscribing to an event you are able to pass either a standard function or an asyncio co-routine Here is a full list of available events:
- `all`: listen for all messages coming through
- `connected:` called when a connection is made
- `authenticated`: called when the websocket passes authentication
- `message` (string): new incoming message from the websocket
- `all` (array|json): listen for all messages coming through
- `connected:` () called when a connection is made
- `authenticated` (): called when the websocket passes authentication
- `notification` (array): incoming account notification
- `error` (string): error from the websocket
- `order_closed` (string): when an order confirmation is recieved
- `wallet_snapshot` (string): Initial wallet balances (Fired once)
- `order_snapshot` (string): Initial open orders (Fired once)
- `positions_snapshot` (string): Initial open positions (Fired once)
- `wallet_update` (string): changes to the balance of wallets
- `seed_candle` (candleArray): initial past candle to prime strategy
- `seed_trade` (tradeArray): initial past trade to prime strategy
- `funding_offer_snapshot`: opening funding offer balances
- `funding_loan_snapshot`:opening funding loan balances
- `funding_credit_snapshot`: opening funding credit balances
- `balance_update` when the state of a balance is changed
- `new_trade`: a new trade on the market has been executed
- `new_candle`: a new candle has been produced
- `error` (array): error from the websocket
- `order_closed` (Order, Trade): when an order confirmation is received
- `wallet_snapshot` (array): Initial wallet balances (Fired once)
- `order_snapshot` (array): Initial open orders (Fired once)
- `positions_snapshot` (array): Initial open positions (Fired once)
- `wallet_update` (array): changes to the balance of wallets
- `seed_candle` (json): initial past candle to prime strategy
- `seed_trade` (json): initial past trade to prime strategy
- `funding_offer_snapshot` (array): opening funding offer balances
- `funding_loan_snapshot` (array): opening funding loan balances
- `funding_credit_snapshot` (array): opening funding credit balances
- `balance_update` (array): when the state of a balance is changed
- `new_trade` (array): a new trade on the market has been executed
- `new_candle` (array): a new candle has been produced
For example. If you wanted to subscribe to all of the trades on the `tBTCUSD` market, then you can simply listen to the `new_trade` event. For Example:
@@ -48,12 +57,12 @@ NOTE: Instead of using the python decorators, you can also listen to events via
ws.on('new_trade', log_trade)
```
### Functions
### Exposed Functions
- `subscribe(channel_name, symbol, timeframe=None, **kwargs)`
Subsribes the socket to a data feed such as 'trades' or 'candles'.
Subscribes the socket to a data feed such as 'trades' or 'candles'.
- `submit_order(symbol, price, amount, market_type, hidden=False, onComplete=None, onError=None, *args, **kwargs)`
Submits an order to the bitfinex api. If the order is successful then the order_closed event will be triggered and the onComplete function will also be called if provided in the parameters.
Submits an order to the Bitfinex api. If the order is successful then the order_closed event will be triggered and the onComplete function will also be called if provided in the parameters.
- `on(event, function)`
subscribes the function to be triggered on the given event.
@@ -91,6 +100,6 @@ ws.run(then, now)
```
## Please see examples folder
There you will be able to find working scripts that submit orders, establish a connect and run backtests.
<br>
<br>
Please see the <b>bfxapi/examples</b> folder. There you will be able to find working scripts that submit orders, establish a connect and run backtests.

View File

@@ -70,7 +70,6 @@ class LiveBfxWebsocket(GenericWebsocket):
- all: listen for all messages coming through
- connected: called when a connection is made
- authenticated: called when the websocket passes authentication
- message (string): new incoming message from the websocket
- notification (array): incoming account notification
- error (string): error from the websocket
- order_closed (string): when an order confirmation is recieved