55use Carbon \Carbon ;
66use GuzzleHttp \Exception \GuzzleException ;
77use MarketDataApp \Client ;
8- use MarketDataApp \Endpoints \Responses \IndicesCandles ;
9- use MarketDataApp \Endpoints \Responses \IndicesQuote ;
8+ use MarketDataApp \Endpoints \Responses \Indices \Candles ;
9+ use MarketDataApp \Endpoints \Responses \Indices \Quote ;
10+ use MarketDataApp \Exceptions \ApiException ;
1011
1112class Indices
1213{
@@ -20,41 +21,46 @@ public function __construct($client)
2021 }
2122
2223 /**
24+ * Get a real-time quote for an index.
25+ *
2326 * @param string $symbol The index symbol, without any leading or trailing index identifiers. For example, use DJI
2427 * do not use $DJI, ^DJI, .DJI, DJI.X, etc.
25- * @throws GuzzleException
28+ * @throws GuzzleException|ApiException
2629 */
27- public function quote (string $ symbol ): IndicesQuote
30+ public function quote (string $ symbol, bool $ fifty_two_week = false ): Quote
2831 {
29- return new IndicesQuote ($ this ->client ->execute (self ::BASE_URL . "quotes/ {$ symbol }" ));
32+ return new Quote ($ this ->client ->execute (self ::BASE_URL . "quotes/ {$ symbol }" , [ ' 52week ' => $ fifty_two_week ] ));
3033 }
3134
3235 /**
36+ * Get historical price candles for an index.
37+ *
3338 * @param string $symbol The index symbol, without any leading or trailing index identifiers. For example, use DJI
3439 * do not use $DJI, ^DJI, .DJI, DJI.X, etc.
40+ *
3541 * @param Carbon $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
36- * Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
37- * @param Carbon|null $to The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix,
38- * spreadsheet.
42+ * @param Carbon|null $to The rightmost candle on a chart (inclusive).
3943 * @param string $resolution The duration of each candle.
4044 * Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...) Hourly Resolutions: (hourly, H, 1H, 2H, ...)
4145 * Daily Resolutions: (daily, D, 1D, 2D, ...)
4246 * Weekly Resolutions: (weekly, W, 1W, 2W, ...)
4347 * Monthly Resolutions: (monthly, M, 1M, 2M, ...)
4448 * Yearly Resolutions:(yearly, Y, 1Y, 2Y, ...)
49+ *
4550 * @param int|null $countback Will fetch a number of candles before (to the left of) to. If you use from, countback
4651 * is not required.
47- * @return IndicesCandles
48- * @throws GuzzleException
52+ *
53+ * @return Candles
54+ * @throws GuzzleException|ApiException
4955 */
5056 public function candles (
5157 string $ symbol ,
5258 Carbon $ from ,
5359 Carbon $ to = null ,
5460 string $ resolution = 'D ' ,
5561 int $ countback = null
56- ): IndicesCandles {
57- return new IndicesCandles ($ this ->client ->execute (self ::BASE_URL . "candles/ {$ resolution }/ {$ symbol }/ " ,
62+ ): Candles {
63+ return new Candles ($ this ->client ->execute (self ::BASE_URL . "candles/ {$ resolution }/ {$ symbol }/ " ,
5864 compact ('from ' , 'to ' , 'countback ' )
5965 ));
6066 }
0 commit comments