Bifinex¶
This implementation is build on Bitfinex REST API version 1.1. The official documentation is available here. It is highly recommended that the user should read General_informations before using.
Fundingbook¶
-
ccs.bitfinex.public.
fundingbook
(currency, limit_bids=50, limit_asks=50)¶ The function provide information about full margin funding book.
Parameters: - currency (String) – This variable will contain values like btc, usd. For more information about symbols (currencies pairs) visit
symbols()
orsymbolsDetails()
. - limit_bids (Int) – It define maximum number of bids. This argument is optional. Default value is 50.
- limit_asks (Int) – It define maximum number of asks. This argument is optional. Default value is 50.
Returns: The function return payload of http response. It is string which particularly contains json with two lists of objects (dictionaries). Official description of object’s keys is in the table.
Bids
Key Type Description bids [array of funding bids] rate [rate in % per 365 days] amount [decimal] period [days] Minimum period for the margin funding contract timestamp [time] frr [yes/no] - Yes if the offer is at Flash Return Rate,
- No if the offer is at fixed rate
Asks
Key Type Description asks [array of funding offers] rate [rate in % per 365 days] amount [decimal] period [days] Maximum period for the funding contract timestamp [time] frr [yes/no] - Yes if the offer is at Flash Return Rate,
- No if the offer is at fixed rate
Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.fundingbook("btc") >>> print(response) { "bids":[ { "rate":"9.1287", "amount":"5000.0", "period":30, "timestamp":"1444257541.0", "frr":"No" }, ... ], "asks":[ { "rate":"8.3695", "amount":"407.5", "period":2, "timestamp":"1444260343.0", "frr":"No" }, ... ] } >>> >>> # Other examples of using >>> ccs.bitfinex.public.fundingbook("btc", limit_asks=2) >>> ccs.bitfinex.public.fundingbook("btc", limit_bids=2) >>> ccs.bitfinex.public.fundingbook("btc", limit_asks=2, limit_bids=2) >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["fundingbook"]
Note
This function use REST endpoint which is described on Bitfinex Fundingbook documentation.
Examples of GET request:
- currency (String) – This variable will contain values like btc, usd. For more information about symbols (currencies pairs) visit
Lends¶
-
ccs.bitfinex.public.
lends
(currency, timestamp=None, limit_lends=50)¶ The function provide a list of the most recent funding data for the given currency. It mean total amount provided and Flash Return Rate (in % by 365 days) over time.
Parameters: - currency (String) – This variable will contain values like btc, usd. For more information about symbols (currencies pairs) visit
symbols()
orsymbolsDetails()
. - timestamp (Number) – Setting this argument cause showing lends at or after the timestamp. This argument is optional.
- limit_lends (Int) – It define maximum number of lends. This argument is optional. Default value is 50.
Returns: The function return payload of http response. It is string which particularly contains json list of objects (dictionaries). Official description of object’s keys is in the table.
Key Type Description rate [decimal, % by 365 days] Average rate of total funding received at fixedrates, ie past Flash Return Rate annualizedamount_lent [decimal] Total amount of open margin funding inthe given currencyamount_used [decimal] Total amount of open margin funding used ina margin position in the given currencytimestamp [time] Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.lends("btc") >>> print(response) [ { "rate":"35.6443", "amount_lent":"15060.11291405", "amount_used":"14766.30959039", "timestamp":1482168852 } ... ] >>> >>> # Other examples of using >>> ccs.bitfinex.public.lends("ltc", timestamp=1482168852) >>> ccs.bitfinex.public.lends("etc", limit_lends=2) >>> ccs.bitfinex.public.lends("btc", timestamp=1482168852, limit_lends=2) >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["lends"]
Note
This function use REST endpoint which is described on Bitfinex Fundingbook documentation.
Examples of GET request:
- currency (String) – This variable will contain values like btc, usd. For more information about symbols (currencies pairs) visit
Orderbook¶
-
ccs.bitfinex.public.
orderbook
(symbol, group=1, limit_bids=50, limit_asks=50)¶ This function provide actual lists of orders for sell and buy.
Parameters: - symbol (String) – Symbol is currency pair. For more information about symbols visit
symbols()
orsymbolsDetails()
. - group (Int) –
If value is set on 1, orders are grouped by price in the orderbook.
If value is set on 0, orders are not grouped and sorted individually.
This argument is optional. Default value is 1.
- limit_bids (Int) – It define maximum number of bids. This argument is optional. Default value is 50.
- limit_asks (Int) – It define maximum number of asks. This argument is optional. Default value is 50.
Returns: The function return payload of http response. It is string which particularly contains json with two lists of objects (dictionaries). Official description of object’s keys is in the table.
Key Type price [price] amount [decimal] timestamp [time] Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.orderbook("btcusd") >>> print(response) { "bids": [ { "price":"791.3", "amount":"11.86528138", "timestamp":"1482168501.0" }, ... ], "asks": [ { "price":"791.31", "amount":"11.76087989", "timestamp":"1482166207.0" }, ... ] } >>> >>> # Other examples of using >>> ccs.bitfinex.public.orderbook("ltcusd", group=0) >>> ccs.bitfinex.public.orderbook("ltcusd", limit_asks=2) >>> ccs.bitfinex.public.orderbook("ltcusd", limit_bids=2) >>> ccs.bitfinex.public.orderbook("ltcusd", limit_asks=2, limit_bids=2) >>> ccs.bitfinex.public.orderbook("ltcusd", group=0, limit_asks=2, limit_bids=2) >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["orderbook"]
Note
This function use REST endpoint which is described on Bitfinex Orderbook documentation.
Examples of GET request:
- https://api.bitfinex.com/v1/book/btcusd
- https://api.bitfinex.com/v1/book/btcusd?limit_asks=2
- https://api.bitfinex.com/v1/book/btcusd?limit_bids=2
- https://api.bitfinex.com/v1/book/btcusd?limit_asks=2&limit_bids=2
- https://api.bitfinex.com/v1/book/btcusd?group=0
- https://api.bitfinex.com/v1/book/btcusd?limit_asks=2&limit_bids=2&group=0
- symbol (String) – Symbol is currency pair. For more information about symbols visit
Stats¶
-
ccs.bitfinex.public.
stats
(symbol)¶ The function provide statistics about symbol.
Parameters: symbol (String) – Symbol is currency pair. For more information about symbols visit
symbols()
orsymbolsDetails()
.Returns: The function return payload of http response. It is string which contains json list of objects (dictionaries). One object (dictionary) represents statistic for period. Official description of object’s keys is in the table.
Key Type Description period [integer] Period covered in days volume [price] Volume Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.stats("btcusd") >>> print(response) [ { "period":1, "volume":"1814.47582303" }, { "period":7, "volume":"28021.46283327" }, { "period":30, "volume":"183014.34833507" } ] >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["stats"]
Note
This function use REST endpoint which is described on Bitfinex Stats documentation.
Examples of GET request:
Symbols¶
-
ccs.bitfinex.public.
symbols
()¶ The fucntion returns list of tradable currency pairs.
Returns: The function return payload of http response. It is string which contains json list of available symbols.
Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.symbols() >>> print(response) [ "btcusd", "ltcusd", "ltcbtc", "ethusd", "ethbtc", "etcbtc", "etcusd", "bfxusd", "bfxbtc", "rrtusd", "rrtbtc", "zecusd", "zecbtc", "xmrusd", "xmrbtc" ] >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["symbols"]
Note
This function use REST endpoint which is described on Bitfinex Symbols documentation.
Examples of GET request:
Symbols details¶
-
ccs.bitfinex.public.
symbolsDetails
()¶ The function returns information about traidable pairs.
Returns: The function return payload of http response. It is string which particularly contains json list of objects (dictionaries). Official description of object’s keys is in the table.
Key Type Description pair [string] The pair code price_precision [integer] Maximum number of significant digits for price in this pair initial_margin [decimal] Initial margin required to open a position in this pair minimum_margin [decimal] Minimal margin to maintain (in %) maximum_order_size [decimal] Maximum order size of the pair expiration [string] Expiration date for limited contracts/pairs Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.symbolsDetails() >>> print(response) [ { "pair":"btcusd", "price_precision":5, "initial_margin":"30.0", "minimum_margin":"15.0", "maximum_order_size":"2000.0", "minimum_order_size":"0.01", "expiration":"NA" } ... ] >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["symbolsDetails"]
Note
This function use REST endpoint which is described on Bitfinex Fundingbook documentation.
Examples of GET request:
Ticker¶
-
ccs.bitfinex.public.
ticker
(symbol)¶ This function provide tick data. This informations offer high level overview of the current states on the market. It is actual price, best bids and asks etc.
Parameters: symbol (String) – Symbol is currency pair. For more information about symbols visit
symbols()
orsymbolsDetails()
.Returns: The function return payload of http response. It is string which contains json dictionary. Official description of keys is in the table.
Key Type Description mid [price] (bid + ask) / 2 bid [price] Innermost bid ask [price] Innermost ask last_price [price] The price at which the last order executed low [price] Lowest trade price of the last 24 hours high [price] Highest trade price of the last 24 hours volume [price] Trading volume of the last 24 hours timestamp [time] The timestamp at which this information was valid Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.ticker("btcusd") >>> print(response) { "mid":"790.395", "bid":"790.39", "ask":"790.4", "last_price":"790.28", "low":"785.59", "high":"792.27", "volume":"1684.46613188", "timestamp":"1482163796.189588406" } >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["ticker"]
Note
This function use REST endpoint which is described on Bitfinex Ticker documentation.
Example of GET request:
Trades¶
-
ccs.bitfinex.public.
trades
(symbol, timestamp=None, limit_trades=None)¶ This function provide history of trades.
Parameters: - symbol (String) – Symbol is currency pair. For more information about symbols visit
symbols()
orsymbolsDetails()
. - timestamp (Number) – Setting this argument cause showing trades at or after the timestamp. This argument is optional.
- limit_trades (Int) – It define maximum number of trades. This argument must be greater or equal to 1. This argument is optional. Default value is 50.
Returns: The function return payload of http response. It is string which contains json list of objects (dictionaries). One object (dictionary) represents one trade. Official description of object’s keys is in the table.
Key Type Description tid [integer] timestamp [time] price [price] amount [decimal] exchange [string] type [string] “sell” or “buy” (can be “” if undetermined) Return type: String
Exception: It can raise any exception which can occur during using
http.client.HTTPSConnection
http.client.HTTPSConnection.request()
.
Example: >>> import ccs >>> response = ccs.bitfinex.public.trades("btcusd") >>> print(response) [ { "timestamp":1482167987, "tid":25060454, "price":"790.94", "amount":"1.0", "exchange":"bitfinex", "type":"buy" }, { "timestamp":1482167919, "tid":25060449, "price":"790.89", "amount":"1.0", "exchange":"bitfinex", "type":"buy" } ... ] >>> >>> # Other examples of using >>> ccs.bitfinex.public.trades("ltcusd", timestamp=1482185015) >>> ccs.bitfinex.public.trades("ltcusd", limit_trades=20) >>> ccs.bitfinex.public.trades("ethusd", timestamp=1482185015, limit_trades=20) >>> >>> # Prepared validation schema >>> schema = ccs.cfg.schema[ccs.constants.BITFINEX]["trades"]
Note
This function use REST endpoint which is described on Bitfinex Trades documentation.
Examples of GET request:
- symbol (String) – Symbol is currency pair. For more information about symbols visit