abstract class Openclerk\Currencies \ SimpleExchange

All implemented interfaces:
Exchange, ExchangeInformation
All known direct subclasses:
Anxpro,BTCChina,BTCe,Bit2c,BitNZ,Bitcurex,BitmarketPl,Bitstamp,Bittrex,Bter,CEXio,Coinbase,CoinsE,CryptoTrade,Cryptsy,ItBit,Kraken,MintPal,MtGox,Poloniex,TheMoneyConverter,VaultOfSatoshi,Vircurex,VirtEx

Implements some basic implementations of an Exchange. Assumes there is a single API call that can be used to list all exchanges and get all rates - #fetchAllRates.

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. (from Exchange)


Method Summary

Name Description
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). Some fields may not be present for a given exchange. volume is the last 24h volume. May also return additional fields.
throttle(Logger $logger) This allows all exchanges to optionally throttle multiple repeated requests based on a runtime configuration value. The throttle time is selected from either the exchanges_NAME_throttle or exchanges_throttle config values, or three seconds; which is the time in seconds to wait between repeated requests.

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). Some fields may not be present for a given exchange. volume is the last 24h volume. May also return additional fields.

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 (from fetchRates)

Returns:
A list of rates for the currency pair
Throws:
ExchangeRateException - if there are no rates for the given pair

public function throttle(Logger $logger)

This allows all exchanges to optionally throttle multiple repeated requests based on a runtime configuration value. The throttle time is selected from either the exchanges_NAME_throttle or exchanges_throttle config values, or three seconds; which is the time in seconds to wait between repeated requests.