22
33namespace MarketDataApp \Endpoints ;
44
5+ use Carbon \Carbon ;
6+ use GuzzleHttp \Exception \GuzzleException ;
57use MarketDataApp \Client ;
68use MarketDataApp \Endpoints \Responses \MutualFunds \Candles ;
9+ use MarketDataApp \Exceptions \ApiException ;
710
811class MutualFunds
912{
@@ -16,9 +19,34 @@ public function __construct($client)
1619 $ this ->client = $ client ;
1720 }
1821
19- public function candles (): Candles
20- {
21- // Stub
22- return new Candles ();
22+ /**
23+ * Get historical price candles for a mutual fund.
24+ *
25+ * @param string $symbol The mutual fund's ticker symbol.
26+ * @param Carbon $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
27+ * @param Carbon|null $to The rightmost candle on a chart (inclusive).
28+ * @param string $resolution The duration of each candle.
29+ * Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...) Hourly Resolutions: (hourly, H, 1H, 2H, ...)
30+ * Daily Resolutions: (daily, D, 1D, 2D, ...)
31+ * Weekly Resolutions: (weekly, W, 1W, 2W, ...)
32+ * Monthly Resolutions: (monthly, M, 1M, 2M, ...)
33+ * Yearly Resolutions:(yearly, Y, 1Y, 2Y, ...)
34+ *
35+ * @param int|null $countback Will fetch a number of candles before (to the left of) to. If you use from, countback
36+ * is not required.
37+ *
38+ * @return Candles
39+ * @throws GuzzleException|ApiException
40+ */
41+ public function candles (
42+ string $ symbol ,
43+ Carbon $ from ,
44+ Carbon $ to = null ,
45+ string $ resolution = 'D ' ,
46+ int $ countback = null ,
47+ ): Candles {
48+ return new Candles ($ this ->client ->execute (self ::BASE_URL . "candles/ {$ resolution }/ {$ symbol }/ " ,
49+ compact ('from ' , 'to ' , 'countback ' )
50+ ));
2351 }
2452}
0 commit comments