Btcc

This file implements functions for reading informations from Btcc-spot public REST endpoints.

ccs.btcc.public.orderbook(market='btccny', limit=None)

This function provide lists of orders for sell and buy.

Parameters:
  • market (String) – Market is currency pair.
  • limit (Integer) – It define maximum number of asks and bids. This argument is optional.
Returns:

The function return payload of http response. It is string which contains json object. Official description of keys is in the table.

Key Value Description
asks array  
bids array  
date number last update timestamp

Each item in arrays for asks and bids describe one order. Official description of array position is in the table.

Position Description
0 price
1 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.btcc.public.orderbook("btccny")
>>> print(response)
{
    "asks":
            [
                [5721.48,0.8],
                [5721.4,0.71],
                ...
            ],
    "bids":
            [
                [5721,0.6097],
                [5720.67,0.1],
                ...
            ],
    "date":1484398991
}
>>>
>>> # Other examples of using
>>> ccs.btcc.public.trades("ltccny")
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BTCC]["trades"]
ccs.btcc.public.ticker(market='btccny')

This function provide detailed data of give market. This informations offer high level overview of the current states on the market. It is actual price, best bids and asks etc.

Parameters:

market (String) – Market is currency pair.

Returns:

The function return payload of http response. It is string which contains json object. Official description of keys is in the table.

Key Value Description
high string highest price in last 24h
low string lowest price in last 24h
buy string latest bid price
sell string latest ask price
last string last successful trade price
vol string total BTC volume in last 24h
date number last update timestamp
vwap number 24 hour average filled price
prev_close number yesterday’s closed price
open number today’s opening price

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.btcc.public.ticker("btccny")
>>> print(response)
{
    "ticker":
            {
                "high":"5720.00",
                "low":"5325.01",
                "buy":"5646.33",
                "sell":"5647.18",
                "last":"5646.33",
                "vol":"886404.27650000",
                "date":1484389306,
                "vwap":"5654",
                "prev_close":"5625.78",
                "open":"5625.98"
            }
}
>>>
>>> # Other examples of using
>>> ccs.btcc.public.ticker("ltccny")
>>> ccs.btcc.public.ticker("all")
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BTCC]["ticker"]
ccs.btcc.public.tradeHistory(market='btccny', limit=100, since=None, sincetype=None)

This function provide history of trades.

Parameters:
  • market (String) – Market is currency pair.
  • limit (Integer) – It define maximum number of trades. This argument must be greater or equal to 1. This argument is optional. Default value is 100. Maximum is 5000.
  • since (Integer) – Setting this argument cause showing trades at or after the timestamp or tid. This argument is optional.
  • sincetype (Integer) – Available values for this argument are “id” or “time”. It specifies on which data the “since” parameter works. The default value is “id”.
Returns:

The function return payload of http response. It is string which contains json object. Official description of keys is in the table.

Key Value Description
date string unix time in seconds since 1 January 1970
price string price for 1 BTC
amount string amount of BTC traded
tid string trade id
type string indicate ‘buy’ or ‘sell’ trade

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.btcc.public.tradeHistory("btccny")
>>> print(response)
[
    {
        "date":"1484395859",
        "price":5679.94,
        "amount":0.064,
        "tid":"121327921",
        "type":"buy"
    },
    {
        "date":"1484395859",
        "price":5680.67,
        "amount":0.025,
        "tid":"121327922",
        "type":"buy"
    },
    ...
]
>>>
>>> # Other examples of using
>>> ccs.btcc.public.tradeHistory("ltccny", limit=10)
>>> ccs.btcc.public.tradeHistory("ltccny", since=7000)
>>> ccs.btcc.public.tradeHistory("ltccny", since=1484396000, sincetype="time")
>>> ccs.btcc.public.tradeHistory("ltccny", 10, 1484396000, "time")
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BTCC]["tradeHistory"]
ccs.btcc.public.trades(market='btccny')

This function provide list of trades processed within the last 24h, but maximal number of trades returned is 10000.

Parameters:

market (String) – Market is currency pair.

Returns:

The function return payload of http response. It is string which contains json object. Official description of keys is in the table.

Key Value Description
date string unix time in seconds since 1 January 1970
price string price for 1 BTC
amount string amount of BTC traded
tid string trade id

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.btcc.public.trades("btccny")
>>> print(response)
[
    {
        "date":"1484372797",
        "price":5615.41,
        "amount":0.029,
        "tid":"121266656"
    },
    {
        "date":"1484372797",
        "price":5615.53,
        "amount":0.371,
        "tid":"121266657"
    },
    ...
]
>>>
>>> # Other examples of using
>>> ccs.btcc.public.trades("ltccny")
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BTCC]["trades"]

Note

This function use REST endpoint which is described on Btcc-spot Trades documentation.

Example of GET request: