abstract class Openclerk\Currencies \ SimpleSecurityExchange

All implemented interfaces:
SecurityExchange, ExchangeInformation

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


Method Summary

Name Description
fetchAsk($security, Logger $logger) Get the lowest price that a seller is willing to accept for trading the given security (also known as the buy price), or null if there is none.
fetchBid($security, Logger $logger) Get the highest price that a buyer is willing to accept for trading the given security (also known as the sell price), or null if there is none.
fetchLastTrade($security, Logger $logger) Get the last traded value for the given security, or null if there is none.
fetchName($security, Logger $logger) Get the name of the given security, or null if there is none.
fetchRates($security, Logger $logger) Fetch all rates for a given security, returns an array of (last_trade, bid, ask, volume, available, security, currency, name, units).
fetchSecurities(Logger $logger) Fetch all securities that this security exchange currently supports. Currency codes are 3-character codes and must be globally unique. Security codes are any length and are unique only to a certain SecurityExchange.
fetchSecurityCurrency($security, Logger $logger) Get the 3-character code of the currency this security code is traded in.
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 security_exchanges_NAME_throttle or security_exchanges_throttle config values, or three seconds; which is the time in seconds to wait between repeated requests.

public function fetchAsk($security, Logger $logger)

Get the lowest price that a seller is willing to accept for trading the given security (also known as the buy price), or null if there is none.


public function fetchBid($security, Logger $logger)

Get the highest price that a buyer is willing to accept for trading the given security (also known as the sell price), or null if there is none.


public function fetchLastTrade($security, Logger $logger)

Get the last traded value for the given security, or null if there is none.


public function fetchName($security, Logger $logger)

Get the name of the given security, or null if there is none.


public function fetchRates($security, Logger $logger)

Fetch all rates for a given security, returns an array of (last_trade, bid, ask, volume, available, security, currency, name, units).

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:
SecurityExchangeRateException - if there are no rates for the given pair

public function fetchSecurities(Logger $logger)

Fetch all securities that this security exchange currently supports. Currency codes are 3-character codes and must be globally unique. Security codes are any length and are unique only to a certain SecurityExchange.

Returns:
an array of (security, currency)

public function fetchSecurityCurrency($security, Logger $logger)

Get the 3-character code of the currency this security code is traded in.

Throws:
SecurityExchangeRateException - if this isn't a valid security code for this exchange

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 security_exchanges_NAME_throttle or security_exchanges_throttle config values, or three seconds; which is the time in seconds to wait between repeated requests.