55use Carbon \Carbon ;
66use GuzzleHttp \Exception \GuzzleException ;
77use MarketDataApp \Client ;
8+ use MarketDataApp \Endpoints \Responses \Stocks \BulkCandles ;
89use MarketDataApp \Endpoints \Responses \Stocks \BulkQuotes ;
910use MarketDataApp \Endpoints \Responses \Stocks \Candles ;
1011use MarketDataApp \Endpoints \Responses \Stocks \Quote ;
@@ -22,6 +23,49 @@ public function __construct($client)
2223 $ this ->client = $ client ;
2324 }
2425
26+ /**
27+ * Get bulk candle data for stocks. This endpoint returns bulk daily candle data for multiple stocks. Unlike the
28+ * standard candles endpoint, this endpoint returns a single daily for each symbol provided. The typical use-case
29+ * for this endpoint is to get a complete market snapshot during trading hours, though it can also be used for bulk
30+ * snapshots of historical daily candles.
31+ *
32+ * @param array $symbols The ticker symbols to return in the response, separated by commas. The symbols parameter
33+ * may be omitted if the snapshot parameter is set to true.
34+ *
35+ * @param string $resolution The duration of each candle. Only daily candles are supported at this time.
36+ * Daily Resolutions: (daily, D, 1D, 2D, ...)
37+ *
38+ * @param bool $snapshot Returns candles for all available symbols for the date indicated. The symbols parameter can
39+ * be omitted if snapshot is set to true.
40+ *
41+ * @param Carbon|null $date The date of the candles to be returned. If no date is specified, during market hours the
42+ * candles returned will be from the current session. If the market is closed the candles will be from the most
43+ * recent session.
44+ *
45+ * @param bool $adjustsplits Adjust historical data for historical splits and reverse splits. Market Data uses
46+ * the CRSP methodology for adjustment. Daily candles default: true.
47+ *
48+ * @return Candles
49+ * @throws ApiException
50+ * @throws GuzzleException
51+ */
52+ public function bulkCandles (
53+ array $ symbols = [],
54+ string $ resolution = 'D ' ,
55+ bool $ snapshot = false ,
56+ Carbon $ date = null ,
57+ bool $ adjustsplits = false ,
58+ ): BulkCandles {
59+ if (empty ($ symbols ) && !$ snapshot ) {
60+ throw new \InvalidArgumentException ('Either symbols or snapshot must be set ' );
61+ }
62+
63+ $ symbols = implode (', ' , array_map ('trim ' , $ symbols ));
64+ return new BulkCandles ($ this ->client ->execute (self ::BASE_URL . "bulkcandles/ {$ resolution }/ " ,
65+ compact ('symbols ' , 'date ' , 'snapshot ' , 'adjustsplits ' )
66+ ));
67+ }
68+
2569 /**
2670 * Get historical price candles for an index.
2771 *
@@ -34,23 +78,30 @@ public function __construct($client)
3478 * Weekly Resolutions: (weekly, W, 1W, 2W, ...)
3579 * Monthly Resolutions: (monthly, M, 1M, 2M, ...)
3680 * Yearly Resolutions:(yearly, Y, 1Y, 2Y, ...)
81+ *
3782 * @param int|null $countback Will fetch a number of candles before (to the left of) to. If you use from, countback
3883 * is not required.
84+ *
3985 * @param string|null $exchange Use to specify the exchange of the ticker. This is useful when you need to specify
4086 * a stock that quotes on several exchanges with the same symbol. You may specify the exchange using the EXCHANGE
4187 * ACRONYM, MIC CODE, or two digit YAHOO FINANCE EXCHANGE CODE. If no exchange is specified symbols will be matched
4288 * to US exchanges first.
89+ *
4390 * @param bool $extended Include extended hours trading sessions when returning intraday candles. Daily resolutions
4491 * never return extended hours candles. The default is false.
92+ *
4593 * @param string|null $country Use to specify the country of the exchange (not the country of the company) in
4694 * conjunction with the symbol argument. This argument is useful when you know the ticker symbol and the country of
4795 * the exchange, but not the exchange code. Use the two digit ISO 3166 country code. If no country is specified, US
4896 * exchanges will be assumed.
97+ *
4998 * @param bool $adjustsplits Adjust historical data for for historical splits and reverse splits. Market Data uses
5099 * the CRSP methodology for adjustment. Daily candles default: true. Intraday candles default: false.
100+ *
51101 * @param bool $adjustdividends CAUTION: Adjusted dividend data is planned for the future, but not yet implemented.
52102 * All data is currently returned unadjusted for dividends. Market Data uses the CRSP methodology for adjustment.
53103 * Daily candles default: true. Intraday candles default: false.
104+ *
54105 * @return Candles
55106 * @throws GuzzleException|ApiException
56107 */
@@ -77,7 +128,8 @@ public function candles(
77128 * @param string $symbol The company's ticker symbol.
78129 * @param bool $fifty_two_week Enable the output of 52-week high and 52-week low data in the quote output. By
79130 * default this parameter is false if omitted.
80- * @throws GuzzleException
131+ *
132+ * @throws GuzzleException|ApiException
81133 */
82134 public function quote (string $ symbol , bool $ fifty_two_week = false ): Quote
83135 {
@@ -91,6 +143,7 @@ public function quote(string $symbol, bool $fifty_two_week = false): Quote
91143 * @param array $symbols The ticker symbols to return in the response.
92144 * @param bool $fifty_two_week Enable the output of 52-week high and 52-week low data in the quote output. By
93145 * default this parameter is false if omitted.
146+ *
94147 * @throws \Throwable
95148 */
96149 public function quotes (array $ symbols , bool $ fifty_two_week = false ): Quotes |BulkQuotes
@@ -113,8 +166,10 @@ public function quotes(array $symbols, bool $fifty_two_week = false): Quotes|Bul
113166 *
114167 * @param array $symbols The ticker symbols to return in the response, separated by commas. The symbols parameter
115168 * may be omitted if the snapshot parameter is set to true.
169+ *
116170 * @param bool $snapshot Returns a full market snapshot with quotes for all symbols when set to true. The symbols
117171 * parameter may be omitted if the snapshot parameter is set.
172+ *
118173 * @throws GuzzleException
119174 * @throws \Exception
120175 */
0 commit comments