- Openclerk\Currencies\Exchange
interface Openclerk\Currencies \ Exchange
- All known implementing classes:
- Anxpro, BTCChina, BTCe, Bit2c, BitNZ, Bitcurex, BitmarketPl, Bitstamp, Bittrex, Bter, CEXio, Coinbase, CoinsE, CryptoTrade, Cryptsy, ItBit, Kraken, MintPal, MtGox, Poloniex, TheMoneyConverter, VaultOfSatoshi, Vircurex, VirtEx, SimpleExchange
Represents an exchange which can be used to convert one value of Currency into another value of another Currency.
An Exchange does not provide conversion functionality; this can be done naively with #getLastTrade.
This is the base interface; other interfaces will provide additional functionality as necessary.
Method Summary
Name | Description |
---|---|
fetchAllRates(Logger $logger) | Return a list of rates for each supported market, e.g. array(array('currency1' => 'usd', 'currency2' => 'btc', 'last_trade' => 1, 'bid' => 2), ...) |
fetchAsk($currency1, $currency2, Logger $logger) |
Get the lowest price that a seller is willing to accept for trading the given pair (also known as the buy price), or null if there is none. |
fetchBid($currency1, $currency2, Logger $logger) |
Get the highest price that a buyer is willing to accept for trading the given pair (also known as the sell price), or null if there is none. |
fetchLastTrade($currency1, $currency2, Logger $logger) |
Get the last traded value for the given currency pair, or null if there is none. |
fetchMarkets(Logger $logger) | Each of these pairs represents a market, e.g. ('btc', 'usd') These pairs can be in any (a, b) order, because we should (in theory) be able to swap last/bid/ask as necessary. |
fetchRates($currency1, $currency2, Logger $logger) | Fetch all rates for a given currency, returns an array of (last_trade, bid, ask, volume, currency1, currency2) as keyed by the concatenation of the two currencies together (and therefore should be six characters long). |
getCode() | |
getName() |
public function fetchAllRates(Logger $logger)
Return a list of rates for each supported market, e.g. array(array('currency1' => 'usd', 'currency2' => 'btc', 'last_trade' => 1, 'bid' => 2), ...)
- See:
public function fetchAsk($currency1, $currency2, Logger $logger)
Get the lowest price that a seller is willing to accept for trading the given pair (also known as the buy price), or
null
if there is none.
public function fetchBid($currency1, $currency2, Logger $logger)
Get the highest price that a buyer is willing to accept for trading the given pair (also known as the sell price), or
null
if there is none.
public function fetchLastTrade($currency1, $currency2, Logger $logger)
Get the last traded value for the given currency pair, or
null
if there is none.
public function fetchMarkets(Logger $logger)
Each of these pairs represents a market, e.g. ('btc', 'usd') These pairs can be in any (a, b) order, because we should (in theory) be able to swap last/bid/ask as necessary.
- Returns:
an array of (from, to) 3-character Currency codes
public function fetchRates($currency1, $currency2, Logger $logger)
Fetch all rates for a given currency, returns an array of (last_trade, bid, ask, volume, currency1, currency2) as keyed by the concatenation of the two currencies together (and therefore should be six characters long).
Some fields may not be present for a given exchange.
volume
is the last 24h volume.May also return additional fields, e.g. high/low/vwap
- Returns:
A list of rates for the currency pair- Throws:
ExchangeRateException - if there are no rates for the given pair
public function getCode()
- Returns:
a unique string representing this exchange; must be lowercase and 1-32 characters
public function getName()
- Returns:
the full name of the exchange