Skip to main content

Python wrapper for Bitfinex API v1 and v2

Project description

pyfinex
======
Python wrapper for Bitfinex API.

Dependencies
======
Requests library is required.

Usage
======

Include the pyfinex module and use it as a toolbox. For trading, a key and a secret key must be provided.

import pyfinex

API_KEY = 'insert key'
API_SECRET = 'insert secret'

resp = pyfinex.v1.positions.active(key=API_KEY, secret_key=API_SECRET)
resp = pyfinex.v1.public.ticker(symbol='btcusd')

Function names are organized for better coding

**Function names are referred in part to the api doc's html, which you can see [Bitfinex API web page](http://docs.bitfinex.com/).**
**Required params to build the request's url are coded in the function's args, other query params are to be added acording to api doc**

**BEWARE: some inputs varies from v1 to v2. Example: v1>> 'BTCUSD' v2>> 'tBTCUSD'**

All documented API calls are implemented!

Examples
======

### Get the latest BTCUSD price
resp = pyfinex.v1.public.ticker(symbol='btcusd')
### View your active orders
resp = pyfinex.v1.positions.active(API_KEY,API_SECRET)
### Get the BTCUSD order book
resp = pyfinex.v1.public.order_book(symbol='btcusd')
### Get the last BTCUSD 1m candle
resp = pyfinex.v2.public.candles(Symbol='tBTCUSD', TimeFrame='1m', Section='last')
### Submit a new order
For example, if you'd like to buy 0.001 BTC as 0.01 BTC/USD, you need to specify the parameters acording to the api doc. You may parse the response to get the order id for future use.

resp = pyfinex.v1.orders.new(symbol="BTCUSD", amount=0.001, price=0.01, side='buy', type='market')

### In case there is a new call you can do it yourself!:
pyfinex.api.request(authenticate=True,
key=API_KEY,
secret_key=API_SECRET,
version=1,
endpoint='new/api/call/here',
method='POST',
body_params={},
query_params={})

Known Issues
======
- Authenticated post requests to v2 are still buggy, presumably server-side

TODO
=====
- Debug v2 auth posts!


## Contributing

1. Create an issue and discuss.
1. Fork it.
1. Create a feature branch containing only your fix or feature.
1. Add tests, please!!
1. Create a pull request.
1. Thanks!

## References
- [https://github.com/scottjbarr/bitfinex](https://github.com/scottjbarr/bitfinex)
- [https://github.com/jimako1989/bitfinexpy](https://github.com/jimako1989/bitfinexpy)
- [Bitfinex official API wrapper for Ruby](https://github.com/bitfinexcom/bitfinex-api-rb)
- [Bitfinex v1 API doc](https://bitfinex.readme.io/v1/docs)
- [Bitfinex v2 API doc](https://bitfinex.readme.io/v2/docs)
## Licence

The MIT License (MIT)

Copyright (c) 2018 faberquisque

See [LICENSE.md](LICENSE.md)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfinex-1.0.1.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

pyfinex-1.0.1-py3-none-any.whl (23.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page