Market Endpoints

class allcoin.client.Client(api_key, api_secret, requests_params=None)[source]
get_klines(symbol, kline_type, size=None, since=None)[source]

Get klines for a symbol

Parameters:
  • symbol (str) – required
  • kline_type (str) – type of candlestick (1min, 3min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 12hour, 1day, 3day, 1week)
  • size (int) – number of klines to return
  • since (int) – timestamp in ms to return from
# default
klines = client.get_klines('eth_btc', '1min')

# optional params
klines = client.get_klines('eth_btc', '1hour', size=20, since=1417449600000)
Returns:API response
[
    [
        1417449600000,  # timestamp
        2339.11,        # open
        2383.15,        # high
        2322,           # low
        2369.85,        # close
        83850.06        # volume
    ],
    [
        1417536000000,
        2370.16,
        2380,
        2352,
        2367.37,
        17259.83
    ]
]
Raises:AllcoinResponseException, BinanceAPIException
get_order_book(symbol, size=None, merge=None)[source]

Get the Order Book for the market

Parameters:
  • symbol (str) – required
  • size (int) – Default 100; max 100
  • merge (int) – merge depth Default 1; max 100
# default
book = client.get_order_book('eth_btc')

# optional params
book = client.get_order_book('eth_btc', size=5, merge=5)
Returns:API response
{
    "asks": [
        [792, 5],
        [789.68, 0.018],
        [788.99, 0.042],
        [788.43, 0.036],
        [787.27, 0.02]
    ],
    "bids": [
        [787.1, 0.35],
        [787, 12.071],
        [786.5, 0.014],
        [786.2, 0.38],
        [786, 3.217],
        [785.3, 5.322],
        [785.04, 5.04]
    ]
}
Raises:AllcoinResponseException, BinanceAPIException
get_ticker(symbol)[source]

Get the Ticker for the market

Parameters:symbol (str) – required
ticker = client.get_ticker('eth_btc')
Returns:API response
{
    "date":"1410431279",
    "ticker":{
        "buy":"33.15",
        "high":"34.15",
        "last":"33.15",
        "low":"32.05",
        "sell":"33.16",
        "vol":"10532696.39199642"
    }
}
Raises:AllcoinResponseException, BinanceAPIException
get_trades(symbol, since=None)[source]

Get the last 600 trades with optional since transaction id parameter

Parameters:
  • symbol (str) – required
  • since (int) – Transaction id (inclusive)
# default
trades = client.get_trades('eth_btc')

# default
trades = client.get_trades('eth_btc', since=230433)
Returns:API response
[
    {
        "date": "1367130137",
        "date_ms": "1367130137000",
        "price": 787.71,
        "amount": 0.003,
        "tid": "230433",
        "type": "sell"
    },
    {
        "date": "1367130137",
        "date_ms": "1367130137000",
        "price": 787.65,
        "amount": 0.001,
        "tid": "230434",
        "type": "sell"
    },
    {
        "date": "1367130137",
        "date_ms": "1367130137000",
        "price": 787.5,
        "amount": 0.091,
        "tid": "230435",
        "type": "sell"
    }
]
Raises:AllcoinResponseException, BinanceAPIException