44
55use GuzzleHttp \Exception \GuzzleException ;
66use MarketDataApp \Client ;
7+ use MarketDataApp \Endpoints \Requests \Parameters ;
78use MarketDataApp \Endpoints \Responses \Indices \Candles ;
89use MarketDataApp \Endpoints \Responses \Indices \Quote ;
910use MarketDataApp \Endpoints \Responses \Indices \Quotes ;
1011use MarketDataApp \Exceptions \ApiException ;
12+ use MarketDataApp \Traits \UniversalParameters ;
1113
1214class Indices
1315{
1416
17+ use UniversalParameters;
18+
1519 private Client $ client ;
1620 public const BASE_URL = "v1/indices/ " ;
1721
@@ -28,32 +32,40 @@ public function __construct($client)
2832 *
2933 * @param bool $fifty_two_week Enable the output of 52-week high and 52-week low data in the quote output.
3034 *
35+ * @param Parameters|null $parameters Universal parameters for all methods (such as format).
36+ *
3137 * @throws GuzzleException|ApiException
3238 */
33- public function quote (string $ symbol , bool $ fifty_two_week = false ): Quote
34- {
35- return new Quote ($ this ->client ->execute (self ::BASE_URL . "quotes/ $ symbol " , ['52week ' => $ fifty_two_week ]));
39+ public function quote (
40+ string $ symbol ,
41+ bool $ fifty_two_week = false ,
42+ ?Parameters $ parameters = null
43+ ): Quote {
44+ return new Quote ($ this ->execute ("quotes/ $ symbol " , ['52week ' => $ fifty_two_week ], $ parameters ));
3645 }
3746
3847
39-
4048 /**
4149 * Get a real-time price quote for a multiple indices by doing parallel requests.
4250 *
4351 * @param array $symbols The ticker symbols to return in the response.
4452 * @param bool $fifty_two_week Enable the output of 52-week high and 52-week low data in the quote output.
53+ * @param Parameters|null $parameters Universal parameters for all methods (such as format).
4554 *
4655 * @throws \Throwable
4756 */
48- public function quotes (array $ symbols , bool $ fifty_two_week = false ): Quotes
49- {
57+ public function quotes (
58+ array $ symbols ,
59+ bool $ fifty_two_week = false ,
60+ ?Parameters $ parameters = null
61+ ): Quotes {
5062 // Execute standard quotes in parallel
5163 $ calls = [];
5264 foreach ($ symbols as $ symbol ) {
53- $ calls [] = [self :: BASE_URL . "quotes/ $ symbol " , ['52week ' => $ fifty_two_week ]];
65+ $ calls [] = ["quotes/ $ symbol " , ['52week ' => $ fifty_two_week ]];
5466 }
5567
56- return new Quotes ($ this ->client -> executeInParallel ($ calls ));
68+ return new Quotes ($ this ->execute_in_parallel ($ calls, $ parameters ));
5769 }
5870
5971 /**
@@ -78,17 +90,19 @@ public function quotes(array $symbols, bool $fifty_two_week = false): Quotes
7890 * @param int|null $countback Will fetch a number of candles before (to the left of) to. If you use from, countback
7991 * is not required.
8092 *
93+ * @param Parameters|null $parameters Universal parameters for all methods (such as format).
94+ *
8195 * @throws ApiException|GuzzleException
8296 */
8397 public function candles (
8498 string $ symbol ,
8599 string $ from ,
86100 string $ to = null ,
87101 string $ resolution = 'D ' ,
88- int $ countback = null
102+ int $ countback = null ,
103+ ?Parameters $ parameters = null
89104 ): Candles {
90- return new Candles ($ this ->client ->execute (self ::BASE_URL . "candles/ {$ resolution }/ {$ symbol }/ " ,
91- compact ('from ' , 'to ' , 'countback ' )
92- ));
105+ return new Candles ($ this ->execute ("candles/ {$ resolution }/ {$ symbol }/ " , compact ('from ' , 'to ' , 'countback ' ),
106+ $ parameters ));
93107 }
94108}
0 commit comments