cointrader.exchanges package

Submodules

cointrader.exchanges.poloniex module

class cointrader.exchanges.poloniex.Api(config)[source]

Bases: object

Docstring for Api.

balance()[source]
book(currency)[source]
buy(market, amount, price, option=None)[source]

Places a limit buy order in a given market. Required POST parameters are “currencyPair”, “rate”, and “amount”. If successful, the method will return the order number. Sample output:

{"orderNumber":31226040,"resultingTrades":[{"amount":"338.8732","date":"2014-10-18
23:03:21","rate":"0.00000173","total":"0.00058625","tradeID":"16164","type":"buy"}]}

‘total’ is the amount of btc after applying the fee of the order. This is the amount of BTC you actually used in the the order.

You may optionally set “fillOrKill”, “immediateOrCancel”, “postOnly” to 1. A fill-or-kill order will either fill in its entirety or be completely aborted. An immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be canceled rather than left on the order book. A post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the order that fills.

Market:Currency pair like BTC_DASH.
Amount:How many coins do you want to buy
Price:For which price do you want to buy?
Option:See docsstring for more details
Returns:Dict with details on order.
chart(currency, start, end, period=1800)[source]
sell(market, amount, price=None)[source]

Places a limit sell order in a given market. Required POST parameters are “currencyPair”, “rate”, and “amount”. If successful, the method will return the order number. Sample output:

{"orderNumber":31226040,"resultingTrades":[{"amount":"338.8732","date":"2014-10-18
23:03:21","rate":"0.00000173","total":"0.00058625","tradeID":"16164","type":"sell"}]}

‘total’ is the amount of btc after applying the fee of the order. This is the amount of BTC you actually used in the the order.

You may optionally set “fillOrKill”, “immediateOrCancel”, “postOnly” to 1. A fill-or-kill order will either fill in its entirety or be completely aborted. An immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be canceled rather than left on the order book. A post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the order that fills.

Market:Currency pair like BTC_DASH.
Amount:How many coins do you want to buy
Price:For which price do you want to buy?
Option:See docsstring for more details
Returns:Dict with details on order.
ticker(currency=None)[source]
volume(currency=None)[source]
exception cointrader.exchanges.poloniex.ApiError[source]

Bases: exceptions.ValueError

class cointrader.exchanges.poloniex.Poloniex(config)[source]

Bases: cointrader.exchanges.poloniex.Api

MAKER_FEE = 0
TAKER_FEE = 0
balance()[source]

Returns the balance of the given currency. If not currency is given the balance of all currency are returned.

book(currency)[source]

Returns the order book for a given market, as well as a sequence number for use with the Push API and an indicator specifying whether the market is frozen. You may set currencyPair to “all” to get the order books of all markets. Sample output:

{"asks":[[0.00007600,1164],[0.00007620,1300], ... ],
 "bids":[[0.00006901,200],[0.00006900,408], ... ],
 "isFrozen": 0, "seq": 18849}
buy(market, amount, price, option)[source]

Places a limit buy order in a given market. Required POST parameters are “currencyPair”, “rate”, and “amount”. If successful, the method will return the order number. Sample output:

{"orderNumber":31226040,"resultingTrades":[{"amount":"338.8732","date":"2014-10-18
23:03:21","rate":"0.00000173","total":"0.00058625","tradeID":"16164","type":"buy"}]}

‘total’ is the amount of btc after applying the fee of the order. This is the amount of BTC you actually used in the the order.

You may optionally set “fillOrKill”, “immediateOrCancel”, “postOnly” to 1. A fill-or-kill order will either fill in its entirety or be completely aborted. An immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be canceled rather than left on the order book. A post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the order that fills.

Market:Currency pair like BTC_DASH.
Amount:How many coins do you want to buy
Price:For which price do you want to buy?
Option:See docsstring for more details
Returns:Dict with details on order.
chart(currency, start, end, period=1800)[source]

Returns candlestick chart data. Required GET parameters are “currencyPair”, “period” (candlestick period in seconds; valid values are 300, 900, 1800, 7200, 14400, and 86400), “start”, and “end”. “Start” and “end” are given in UNIX timestamp format and used to specify the date range for the data returned.

On the default the chart for the last day with a period of 30 minutes is returned.

Sample output:

[{"date":1405699200,
  "high":0.0045388,
  "low":0.00403001,
  "open":0.00404545,
  "close":0.00427592,
  "volume":44.11655644,
  "quoteVolume":10259.29079097,
  "weightedAverage":0.00430015},
  ...]

https://poloniex.com/public?command=returnChartData&currencyPair=BTC_XMR&start=1405699200&end=9999999999&period=14400

sell(market, amount, price, option=None)[source]

Places a limit sell order in a given market. Required POST parameters are “currencyPair”, “rate”, and “amount”. If successful, the method will return the order number. Sample output:

{"orderNumber":31226040,"resultingTrades":[{"amount":"338.8732","date":"2014-10-18
23:03:21","rate":"0.00000173","total":"0.00058625","tradeID":"16164","type":"sell"}]}

‘total’ is the amount of btc after applying the fee of the order. This is the amount of BTC you actually used in the the order.

You may optionally set “fillOrKill”, “immediateOrCancel”, “postOnly” to 1. A fill-or-kill order will either fill in its entirety or be completely aborted. An immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be canceled rather than left on the order book. A post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the order that fills.

Market:Currency pair like BTC_DASH.
Amount:How many coins do you want to buy
Price:For which price do you want to buy?
Option:See docsstring for more details
Returns:Dict with details on order.
ticker(currency=None)[source]

Returns the ticker of the given currency pair. If no pair is given the volume of all markets are returned.

Example output:

{
    "BTC_LTC":{"last":"0.0251",
               "lowestAsk":"0.02589999",
               "highestBid":"0.0251",
               "percentChange":"0.02390438",
               "baseVolume":"6.16485315",
               "quoteVolume":"245.82513926"},
    ...
}
volume(currency=None)[source]

Returns the volume of the given currency. If not currency is given the volume of all currency are returned.

Example output:

{"BTC_LTC":{"BTC":"2.23248854",
            "LTC":"87.10381314"},
 "BTC_NXT":{"BTC":"0.981616","NXT":"14145"},
 ...}
cointrader.exchanges.poloniex.totimestamp(dt)[source]

Module contents