|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | +/** |
| 4 | + * @link https://github.com/codenix-sv/bitfinex-api |
| 5 | + * @copyright Copyright (c) 2018 codenix-sv |
| 6 | + * @license https://github.com/codenix-sv/bitfinex-api/blob/master/LICENSE |
| 7 | + */ |
| 8 | + |
| 9 | +namespace codenixsv\Bitfinex\Clients; |
| 10 | + |
| 11 | +use codenixsv\Bitfinex\Http\HttpClient; |
| 12 | +use codenixsv\Bitfinex\Requests\Managers\RequestManager; |
| 13 | + |
| 14 | +/** |
| 15 | + * Class BitfinexClient |
| 16 | + * @package codenixsv\Bitfinex\Clients |
| 17 | + */ |
| 18 | +class BitfinexClient extends Client |
| 19 | +{ |
| 20 | + /** |
| 21 | + * @var RequestManager |
| 22 | + */ |
| 23 | + private $publicRequestManager; |
| 24 | + |
| 25 | + /** |
| 26 | + * BitfinexClient constructor. |
| 27 | + * @param HttpClient $httpClient |
| 28 | + * @param RequestManager $publicRequestManager |
| 29 | + */ |
| 30 | + public function __construct( |
| 31 | + HttpClient $httpClient, |
| 32 | + RequestManager $publicRequestManager |
| 33 | + ) { |
| 34 | + parent::__construct($httpClient); |
| 35 | + |
| 36 | + $this->publicRequestManager = $publicRequestManager; |
| 37 | + } |
| 38 | + |
| 39 | + /* |
| 40 | + *************************** Public API ************************** |
| 41 | + */ |
| 42 | + |
| 43 | + /** |
| 44 | + * @param string $symbol |
| 45 | + * @return mixed |
| 46 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-ticker |
| 47 | + */ |
| 48 | + public function getTicker(string $symbol) |
| 49 | + { |
| 50 | + $request = $this->publicRequestManager->createGetRequest('/pubticker/' . $symbol); |
| 51 | + |
| 52 | + return $this->get($request); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Various statistics about the requested pair. |
| 57 | + * @param string $symbol |
| 58 | + * @return mixed |
| 59 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-stats |
| 60 | + */ |
| 61 | + public function getStats(string $symbol) |
| 62 | + { |
| 63 | + $request = $this->publicRequestManager->createGetRequest('/stats/' . $symbol); |
| 64 | + |
| 65 | + return $this->get($request); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Get the full margin funding book |
| 70 | + * @param string $currency |
| 71 | + * @return mixed |
| 72 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-fundingbook |
| 73 | + */ |
| 74 | + public function getFundingBook(string $currency) |
| 75 | + { |
| 76 | + $request = $this->publicRequestManager->createGetRequest('/lendbook/' . $currency); |
| 77 | + |
| 78 | + return $this->get($request); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Get the full order book |
| 83 | + * @param string $symbol |
| 84 | + * @return mixed |
| 85 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-orderbook |
| 86 | + */ |
| 87 | + public function getOrderBook(string $symbol) |
| 88 | + { |
| 89 | + $request = $this->publicRequestManager->createGetRequest('/book/' . $symbol); |
| 90 | + |
| 91 | + return $this->get($request); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Get a list of the most recent trades for the given symbol. |
| 96 | + * @param string $symbol |
| 97 | + * @return mixed |
| 98 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-trades |
| 99 | + */ |
| 100 | + public function getTrades(string $symbol) |
| 101 | + { |
| 102 | + $request = $this->publicRequestManager->createGetRequest('/trades/' . $symbol); |
| 103 | + |
| 104 | + return $this->get($request); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Get a list of the most recent funding data for the given currency: total amount provided and |
| 109 | + * Flash Return Rate (in % by 365 days) over time. |
| 110 | + * @param string $currency |
| 111 | + * @return mixed |
| 112 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-lends |
| 113 | + */ |
| 114 | + public function getLends(string $currency) |
| 115 | + { |
| 116 | + $request = $this->publicRequestManager->createGetRequest('/lends/' . $currency); |
| 117 | + |
| 118 | + return $this->get($request); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * A list of symbol names. |
| 123 | + * @return mixed |
| 124 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-symbols |
| 125 | + */ |
| 126 | + public function getSymbols() |
| 127 | + { |
| 128 | + $request = $this->publicRequestManager->createGetRequest('/symbols'); |
| 129 | + |
| 130 | + return $this->get($request); |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Get a list of valid symbol IDs and the pair details. |
| 135 | + * @return mixed |
| 136 | + * @see https://bitfinex.readme.io/v1/reference#rest-public-symbol-details |
| 137 | + */ |
| 138 | + public function getSymbolsDetails() |
| 139 | + { |
| 140 | + $request = $this->publicRequestManager->createGetRequest('/symbols_details'); |
| 141 | + |
| 142 | + return $this->get($request); |
| 143 | + } |
| 144 | +} |
0 commit comments