Bitstamp

This implementation is build on Bitstamp REST API version 2. The official documentation is available here. It is highly recommended that the user should read General_informations before using.

EUR USD conversion rate

ccs.bitstamp.public.eurUsdConversionRate()

This function provide conversion rate between EUR and USD.

Parameters:

symbol (String) – Symbol is currency pair.

Returns:

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

Key Description
sell price USD -> EUR
buy price EUR -> USDaa

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.bitstamp.public.eurUsdConversionRate()
>>> print(response)
{
    "sell": "1.0548",
    "buy": "1.0624"
}
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BITSTAMP]["eurUsdConversionRate"]

Note

This function use REST endpoint which is described on Bitstamp documentation.

Example of GET request:

Hourly ticker

ccs.bitstamp.public.hourlyTicker(symbol)

This function provide same data as ticker(), but values are being calculated from within an hour.

Parameters:

symbol (String) – Symbol is currency pair.

Returns:

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

Key Description
last last BTC price
high last hour price high
low last hour price low
vwap last hour volume weighted average price
volume last hour volume
bid highest buy order in actual hour
ask lowest sell order in actual hour
timestamp unix timestamp date and time
open first price of the hour

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.bitstamp.public.hourlyTicker("btcusd")
>>> print(response)
{
    "high": "906.00",
    "last": "890.02",
    "timestamp": "1483813890",
    "bid": "890.02",
    "vwap": "866.95",
    "volume": "23326.63588417",
    "low": "812.28",
    "ask": "890.84",
    "open": "904.95"
}
>>>
>>> # Other examples of using
>>> ccs.bitstamp.public.hourlyTicker("btceur")
>>> ccs.bitstamp.public.hourlyTicker("eurusd")
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BITSTAMP]["hourlyTicker"]

Orderbook

ccs.bitstamp.public.orderbook(symbol)

This function provide actual lists of orders for sell and buy.

Parameters:

symbol (String) – Symbol is currency pair.

Returns:

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

Key Description
timestamp unix timestamp
asks list of sell orders
bids list of buy orders

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.bitstamp.public.orderbook("btcusd")
>>> print(response)
{
    "timestamp": "1483817361",
     "bids":
        [
            ["898.01", "7.55654329"],
            ["898.00", "2.24298440"],
            ...
        ],
    "asks":
        [
            ["898.51", "59.81171580"],
            ["898.52", "0.19552560"],
            ...
        ]
}
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BITSTAMP]["orderbook"]

Ticker

ccs.bitstamp.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.

Returns:

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

Key Description
last last BTC price
high last 24 hours price high
low last 24 hours price low
vwap last 24 hours volume weighted average price
volume last 24 hours volume
bid highest buy order
ask lowest sell order
timestamp unix timestamp date and time
open first price of the day

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.bitstamp.public.ticker("btcusd")
>>> print(response)
{
    "high": "906.00",
    "last": "891.32",
    "timestamp": "1483813425",
    "bid": "889.33",
    "vwap": "867.24",
    "volume": "23430.28938458",
    "low": "812.28",
    "ask": "891.25",
    "open": "894.02"
}
>>>
>>> # Other examples of using
>>> ccs.bitstamp.public.ticker("btceur")
>>> ccs.bitstamp.public.ticker("eurusd")
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BITSTAMP]["ticker"]

Transactions

ccs.bitstamp.public.transactions(symbol, time=None)

This function provide history of trades.

Parameters:
  • symbol (String) – Symbol is currency pair.
  • time (Integer) – It is Unix timestamp. Setting this argument cause showing trades at or after the time. This argument is optional.
Returns:

The function return payload of http response. It is string which contains json array of objects. One object (dictionary) represents one trade. Official description of keys is in the table.

Key Description
date Unix timestamp date and time
tid transaction ID
price price
type 0 (buy) or 1 (sell)

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.bitstamp.public.transactions("btcusd")
>>> print(response)
[
    {
        "date": "1483816802",
        "tid": "12911918",
        "price": "898.01",
        "type": "1",
        "amount": "1.36000000"
    },
    {
        "date": "1483816801",
        "tid": "12911917",
        "price": "898.03",
        "type": "1",
        "amount": "0.15000000"
    },
    ...
]
>>>
>>> # Other examples of using
>>> ccs.bitstamp.public.transactions("btceur", time=1483813890)
>>>
>>> # Prepared validation schema
>>> schema = ccs.cfg.schema[ccs.constants.BITSTAMP]["transactions"]