From f38879cfdaea5d3dcfd31392ae313256d5197fa7 Mon Sep 17 00:00:00 2001 From: Jacob Plaster Date: Thu, 6 Dec 2018 13:13:23 +0000 Subject: [PATCH] README: add rest interface to documentation --- README.md | 129 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 4d38965..52b5e33 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ bfx.ws.run() ``` -# Official Python `bfxapi` +# Bitfinex Trading API for Python. Bitcoin, Ether and Litecoin trading This is an official python library that is used to connect interact with the Bitfinex api. Currently it only has support for websockets but will soon have Rest functionality as well. Install dependencies @@ -62,7 +62,8 @@ bfx.ws.run() ### Submit limit order ```python -await bfx.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE LIMIT') +from bfxapi import Order +await bfx.ws.submit_order('tBTCUSD', 100, 0.01, Order.Type.EXCHANGE_MARKET) ``` ### Listen for completion @@ -74,11 +75,22 @@ async def order_completed(order, trade): ### Get wallets ```python -wallets = bfxapi.wallets.get_wallets() +wallets = bfxapi.ws.wallets.get_wallets() # [ Wallet <'exchange_BTC' balance='41.25809589' unsettled='0'>, # Wallet <'exchange_USD' balance='62761.86070104' unsettled='0'> ] ``` +### Order manipulation +All order function support onConfirm and onClose async callbacks. onConfirm is fired when we receive a signal from the websocket that the order has been confirmed. onClose is fired when we receive a signal that the order has either been filled or canceled. + +```python + +async def on_confirm(order): + await bfx.ws.update_order(order.id, price=1000) + +await bfx.ws.submit_order('tBTCUSD', 800, 0.1, onConfirm=on_confirm) +``` + ### Close all orders ```python await bfx.ws.close_all_orders() @@ -118,7 +130,7 @@ The websocket exposes a collection of events that are triggered when certain dat -# `bfxapi.ws` interface +# bfxapi ws interface #### `on(event, function)` @@ -168,35 +180,13 @@ The websocket exposes a collection of events that are triggered when certain dat Takes an array of orderIds and closes them all. -# `bfxapi.wallets` +## bfxapi.ws.wallets ### `get_wallets()` Returns an array of wallets that represent the users balance in the different currencies -# `Order obj` - -### `close()` - - Signals Bitfinex to close the order - -### `update(self, price=None, amount=None, delta=None, price_aux_limit=None, price_trailing=None, flags=None, time_in_force=None)` - - Signals Bitfinex to update the order with the given values - -### `isOpen()` - - Returns true if the order has not been closed - -### `isPending()` - - Returns true if Bitfinex has not responded to confirm the order has been received - -### `isConfirmed()` - - Returns true if Bitfinex has responded to confirm the order - -# `Subscription obj` +## `bfx.ws.Subscription obj` ### `subscribe()` @@ -210,7 +200,88 @@ The websocket exposes a collection of events that are triggered when certain dat Returns true if the subscription is open and receiving data +# bfxapi rest interface + +### `get_public_candles(symbol, start, end, section='hist', tf='1m', limit="100", sort=-1 ` + + Get All of the public candles between the given start and end period + +### `get_public_trades(symbol, start, end, limit="100", sort=-1)` + +Get all of the public trades between the start and end period + +### `get_public_books(symbol, precision="P0", length=25)` + +Get the public orderbook of a given symbol + +### `get_public_ticker(symbol)` + + Get tickers for the given symbol. Tickers shows you the current best bid and ask, + as well as the last trade price. + +### `get_public_tickers(symbols)` + + Get tickers for the given symbols. Tickers shows you the current best bid and ask, + as well as the last trade price. + +### `get_wallets()` + + Get all wallets on account associated with API_KEY - Requires authentication. + +### `get_active_orders(symbol)` + + Get all of the active orders associated with API_KEY - Requires authentication. + +### `get_order_history(symbol, start, end, limit=25, sort=-1)` + + Get all of the orders between the start and end period associated with API_KEY + - Requires authentication. + +### `get_active_positions()` + + Get all of the active position associated with API_KEY - Requires authentication. + +### `get_order_trades(symbol, order_id)` + + Get all of the trades that have been generated by the given order associated with API_KEY - Requires authentication. + +### `get_trades(symbol, start, end, limit=25)` + + Get all of the trades between the start and end period associated with API_KEY + - Requires authentication. + +### `get_funding_offers(symbol) + + Get all of the funding offers associated with API_KEY - Requires authentication. + +### `get_funding_offer_history(symbol, start, end, limit=25)` + + Get all of the funding offers between the start and end period associated with API_KEY - Requires authentication. + +### `get_funding_loans(symbol)` + + Get all of the funding loans associated with API_KEY - Requires authentication. + +### `get_funding_loan_history(symbol, start, end, limit=25)` + + Get all of the funding loans between the start and end period associated with API_KEY - Requires authentication. + +### `get_funding_credits(symbol)` + + Get all of the funding credits associated with API_KEY - Requires authentication. + +### `get_funding_credit_history(symbol, start, end, limit=25)` + + Get all of the funding credits between the start and end period associated with API_KEY - Requires authentication. # Examples -For more info on how to use this library please see the example scripts in the `bfxapi/examples` directory. +For more info on how to use this library please see the example scripts in the `bfxapi/examples` directory. Here you will find usage of all interface exposed functions for both the rest and websocket. + +## Contributing + +1. Fork it ( https://github.com/[my-github-username]/bitfinex/fork ) +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create a new Pull Request