Skip to content

Commit 885fd80

Browse files
authored
Merge pull request #6 from MarketDataApp/remove-carbon-requirements
Remove Carbon requirements
2 parents d3b7878 + 1f94bae commit 885fd80

12 files changed

Lines changed: 160 additions & 122 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.4.1-alpha
4+
5+
- Changed all Carbon date endpoints to receive a string rather than a Carbon instance.
6+
37
## v0.4.0-alpha
48

59
- Completed remaining endpoints:

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ $client = new MarketDataApp\Client('your_api_token');
2626
$quote = $client->indices->quote('DJI');
2727
$candles = $client->indices->candles(
2828
symbol: "DJI",
29-
from: Carbon::parse('2022-09-01'),
30-
to: Carbon::parse('2022-09-05'),
29+
from: '2022-09-01',
30+
to: '2022-09-05',
3131
resolution: 'D'
3232
);
3333

@@ -37,17 +37,17 @@ $bulk_candles = $client->stocks->bulkCandles(['AAPL, MSFT']);
3737
$quote = $client->stocks->quote('AAPL');
3838
$quotes = $client->stocks->quotes(['AAPL', 'NFLX']);
3939
$bulk_quotes = $client->stocks->bulk_quotes(['AAPL', 'NFLX']);
40-
$earnings = $client->stocks->earnings(symbol: 'AAPL', from: Carbon::parse('2023-01-01'));
41-
$news = $client->stocks->news(symbol: 'AAPL', from: Carbon::parse('2023-01-01'));
40+
$earnings = $client->stocks->earnings(symbol: 'AAPL', from: '2023-01-01');
41+
$news = $client->stocks->news(symbol: 'AAPL', from: '2023-01-01');
4242

4343
// Markets
44-
$status = $client->markets->status(date: Carbon::parse('2023-01-01'));
44+
$status = $client->markets->status(date: '2023-01-01');
4545

4646
// Mutual Funds
4747
$candles = $client->mutual_funds->candles(
4848
symbol: 'VFINX',
49-
from: Carbon::parse('2022-09-01'),
50-
to: Carbon::parse('2022-09-05'),
49+
from: '2022-09-01',
50+
to: '2022-09-05',
5151
resolution: 'D'
5252
);
5353

@@ -56,12 +56,12 @@ $expirations = $client->options->expirations('AAPL');
5656
$lookup = $client->options->lookup('AAPL 7/28/23 $200 Call');
5757
$strikes = $client->options->strikes(
5858
symbol: 'AAPL',
59-
expiration: Carbon::parse('2023-01-20'),
60-
date: Carbon::parse('2023-01-03'),
59+
expiration: '2023-01-20',
60+
date: '2023-01-03',
6161
);
6262
$option_chain = $client->options->option_chain(
6363
symbol: 'AAPL',
64-
expiration: Carbon::parse('2025-01-17'),
64+
expiration: '2025-01-17',
6565
side: Side::CALL,
6666
);
6767
$quotes = $client->options->quotes('AAPL250117C00150000');

src/Endpoints/Indices.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MarketDataApp\Endpoints;
44

5-
use Carbon\Carbon;
65
use GuzzleHttp\Exception\GuzzleException;
76
use MarketDataApp\Client;
87
use MarketDataApp\Endpoints\Responses\Indices\Candles;
@@ -38,8 +37,12 @@ public function quote(string $symbol, bool $fifty_two_week = false): Quote
3837
* @param string $symbol The index symbol, without any leading or trailing index identifiers. For example, use DJI
3938
* do not use $DJI, ^DJI, .DJI, DJI.X, etc.
4039
*
41-
* @param Carbon $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
42-
* @param Carbon|null $to The rightmost candle on a chart (inclusive).
40+
* @param string $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
41+
* Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
42+
*
43+
* @param string|null $to The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix,
44+
* spreadsheet.
45+
*
4346
* @param string $resolution The duration of each candle.
4447
* Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...) Hourly Resolutions: (hourly, H, 1H, 2H, ...)
4548
* Daily Resolutions: (daily, D, 1D, 2D, ...)
@@ -51,12 +54,13 @@ public function quote(string $symbol, bool $fifty_two_week = false): Quote
5154
* is not required.
5255
*
5356
* @return Candles
54-
* @throws GuzzleException|ApiException
57+
* @throws ApiException
58+
* @throws GuzzleException
5559
*/
5660
public function candles(
5761
string $symbol,
58-
Carbon $from,
59-
Carbon $to = null,
62+
string $from,
63+
string $to = null,
6064
string $resolution = 'D',
6165
int $countback = null
6266
): Candles {

src/Endpoints/Markets.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MarketDataApp\Endpoints;
44

5-
use Carbon\Carbon;
65
use GuzzleHttp\Exception\GuzzleException;
76
use MarketDataApp\Client;
87
use MarketDataApp\Endpoints\Responses\Markets\Statuses;
@@ -23,23 +22,28 @@ public function __construct($client)
2322
* Get the past, present, or future status for a stock market. The endpoint will respond with "open" for trading
2423
* days or "closed" for weekends or market holidays.
2524
*
26-
* @param string $country The country. Use the two digit ISO 3166 country code. If no country is specified, US will
25+
* @param string $country The country. Use the two-digit ISO 3166 country code. If no country is specified, US will
2726
* be assumed. Only countries that Market Data supports for stock price data are available (currently only the
2827
* United States).
2928
*
30-
* @param Carbon|null $date Consult whether the market was open or closed on the specified date.
31-
* @param Carbon|null $from The earliest date (inclusive). If you use countback, from is not required.
32-
* @param Carbon|null $to The last date (inclusive).
29+
* @param string|null $date Consult whether the market was open or closed on the specified date. Accepted timestamp
30+
* inputs: ISO 8601, unix, spreadsheet.
31+
*
32+
* @param string|null $from The earliest date (inclusive). If you use countback, from is not required. Accepted
33+
* timestamp inputs: ISO 8601, unix, spreadsheet.
34+
*
35+
* @param string|null $to The last date (inclusive). Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
36+
*
3337
* @param int|null $countback Countback will fetch a number of dates before to If you use from, countback is not
3438
* required.
35-
* @return Statuses
39+
*
3640
* @throws GuzzleException|ApiException
3741
*/
3842
public function status(
3943
string $country = "US",
40-
Carbon $date = null,
41-
Carbon $from = null,
42-
Carbon $to = null,
44+
string $date = null,
45+
string $from = null,
46+
string $to = null,
4347
int $countback = null
4448
): Statuses {
4549
// Stub

src/Endpoints/MutualFunds.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MarketDataApp\Endpoints;
44

5-
use Carbon\Carbon;
65
use GuzzleHttp\Exception\GuzzleException;
76
use MarketDataApp\Client;
87
use MarketDataApp\Endpoints\Responses\MutualFunds\Candles;
@@ -23,14 +22,20 @@ public function __construct($client)
2322
* Get historical price candles for a mutual fund.
2423
*
2524
* @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).
25+
*
26+
* @param string $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
27+
* Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
28+
*
29+
* @param string|null $to The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix,
30+
* spreadsheet.
31+
*
2832
* @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, ...)
33+
* - Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...)
34+
* - Hourly Resolutions: (hourly, H, 1H, 2H, ...)
35+
* - Daily Resolutions: (daily, D, 1D, 2D, ...)
36+
* - Weekly Resolutions: (weekly, W, 1W, 2W, ...)
37+
* - Monthly Resolutions: (monthly, M, 1M, 2M, ...)
38+
* - Yearly Resolutions:(yearly, Y, 1Y, 2Y, ...)
3439
*
3540
* @param int|null $countback Will fetch a number of candles before (to the left of) to. If you use from, countback
3641
* is not required.
@@ -40,8 +45,8 @@ public function __construct($client)
4045
*/
4146
public function candles(
4247
string $symbol,
43-
Carbon $from,
44-
Carbon $to = null,
48+
string $from,
49+
string $to = null,
4550
string $resolution = 'D',
4651
int $countback = null,
4752
): Candles {

src/Endpoints/Options.php

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MarketDataApp\Endpoints;
44

5-
use Carbon\Carbon;
65
use GuzzleHttp\Exception\GuzzleException;
76
use MarketDataApp\Client;
87
use MarketDataApp\Endpoints\Responses\Options\Expirations;
@@ -35,13 +34,13 @@ public function __construct($client)
3534
* @param int|null $strike Limit the lookup of expiration dates to the strike provided. This will cause the endpoint to
3635
* only return expiration dates that include this strike.
3736
*
38-
* @param Carbon|null $date Use to lookup a historical list of expiration dates from a specific previous trading
37+
* @param string|null $date Use to lookup a historical list of expiration dates from a specific previous trading
3938
* day. If date is omitted the expiration dates will be from the current trading day during market hours or from the
40-
* last trading day when the market is closed.
39+
* last trading day when the market is closed. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
4140
*
4241
* @throws ApiException|GuzzleException
4342
*/
44-
public function expirations(string $symbol, int $strike = null, Carbon $date = null): Expirations
43+
public function expirations(string $symbol, int $strike = null, string $date = null): Expirations
4544
{
4645
// Stub
4746
return new Expirations($this->client->execute(self::BASE_URL . "options/expirations/$symbol",
@@ -72,15 +71,15 @@ public function lookup(string $input): Lookup
7271
*
7372
* @param string $symbol The underlying ticker symbol for the options chain you wish to lookup.
7473
*
75-
* @param Carbon|null $expiration Limit the lookup of strikes to options that expire on a specific expiration date.
74+
* @param string|null $expiration Limit the lookup of strikes to options that expire on a specific expiration date.
7675
*
77-
* @param Carbon|null $date Use to lookup a historical list of strikes from a specific previous trading day. If date
76+
* @param string|null $date Use to lookup a historical list of strikes from a specific previous trading day. If date
7877
* is omitted the expiration dates will be from the current trading day during market hours or from the last trading
79-
* day when the market is closed.
78+
* day when the market is closed. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
8079
*
8180
* @throws ApiException|GuzzleException
8281
*/
83-
public function strikes(string $symbol, Carbon $expiration = null, Carbon $date = null): Strikes
82+
public function strikes(string $symbol, string $expiration = null, string $date = null): Strikes
8483
{
8584
// Stub
8685
return new Strikes($this->client->execute(self::BASE_URL . "options/strikes/$symbol",
@@ -97,13 +96,15 @@ public function strikes(string $symbol, Carbon $expiration = null, Carbon $date
9796
* all expirations.
9897
*
9998
* @param string $symbol The ticker symbol of the underlying asset.
100-
* @param Carbon|null $date Use to lookup a historical end of day options chain from a specific trading day. If no
99+
*
100+
* @param string|null $date Use to lookup a historical end of day options chain from a specific trading day. If no
101101
* date is specified the chain will be the most current chain available during market hours. When the market is
102-
* closed the chain will be from the last trading day.
102+
* closed the chain will be from the last trading day. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
103103
*
104-
* @param Carbon|Expiration $expiration
104+
* @param string|Expiration $expiration
105105
* - Limits the option chain to a specific expiration date. Accepted date inputs: ISO 8601, unix, spreadsheet. This
106-
* parameter is only required if requesting a quote along with the chain.
106+
* parameter is only required if requesting a quote along with the chain. Accepted timestamp inputs: ISO 8601, unix,
107+
* spreadsheet.
107108
*
108109
* - If omitted the next monthly expiration for real-time quotes or the next monthly expiration relative to the date
109110
* parameter for historical quotes will be returned.
@@ -114,11 +115,11 @@ public function strikes(string $symbol, Carbon $expiration = null, Carbon $date
114115
* consume your requests very quickly. The full SPX option chain has more than 20,000 contracts. A request is
115116
* consumed for each contact you request with a price in the option chain.
116117
*
117-
* @param Carbon|null $from Limit the option chain to expiration dates after from (inclusive). Should be combined
118-
* with to create a range.
118+
* @param string|null $from Limit the option chain to expiration dates after from (inclusive). Should be combined
119+
* with to create a range. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
119120
*
120-
* @param Carbon|null $to Limit the option chain to expiration dates before to (not inclusive). Should be combined
121-
* with from to create a range.
121+
* @param string|null $to Limit the option chain to expiration dates before to (not inclusive). Should be combined
122+
* with from to create a range. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
122123
*
123124
* @param int|null $month Limit the option chain to options that expire in a specific month (1-12).
124125
*
@@ -202,10 +203,10 @@ public function strikes(string $symbol, Carbon $expiration = null, Carbon $date
202203
*/
203204
public function option_chain(
204205
string $symbol,
205-
Carbon $date = null,
206-
Carbon|Expiration $expiration = Expiration::ALL,
207-
Carbon $from = null,
208-
Carbon $to = null,
206+
string $date = null,
207+
string|Expiration $expiration = Expiration::ALL,
208+
string $from = null,
209+
string $to = null,
209210
int $month = null,
210211
int $year = null,
211212
bool $weekly = true,
@@ -261,21 +262,23 @@ public function option_chain(
261262
* @param string $option_symbol The option symbol (as defined by the OCC) for the option you wish to lookup. Use the
262263
* current OCC option symbol format, even for historic options that quoted before the format change in 2010.
263264
*
264-
* @param Carbon|null $date Use to lookup a historical end of day quote from a specific trading day. If no date is
265+
* @param string|null $date Use to lookup a historical end of day quote from a specific trading day. If no date is
265266
* specified the quote will be the most current price available during market hours. When the market is closed the
266-
* quote will be from the last trading day.
267+
* quote will be from the last trading day. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
267268
*
268-
* @param Carbon|null $from Use to lookup a series of end of day quotes. From is the oldest (leftmost) date to
269+
* @param string|null $from Use to lookup a series of end of day quotes. From is the oldest (leftmost) date to
269270
* return (inclusive). If from/to is not specified the quote will be the most current price available during market
270-
* hours. When the market is closed the quote will be from the last trading day.
271+
* hours. When the market is closed the quote will be from the last trading day. Accepted timestamp inputs: ISO
272+
* 8601, unix, spreadsheet.
271273
*
272-
* @param Carbon|null $to Use to lookup a series of end of day quotes. From is the newest (rightmost) date to return
274+
* @param string|null $to Use to lookup a series of end of day quotes. From is the newest (rightmost) date to return
273275
* (exclusive). If from/to is not specified the quote will be the most current price available during market hours.
274-
* When the market is closed the quote will be from the last trading day.
276+
* When the market is closed the quote will be from the last trading day. Accepted timestamp inputs: ISO 8601, unix,
277+
* spreadsheet.
275278
*
276279
* @throws ApiException|GuzzleException
277280
*/
278-
public function quotes(string $option_symbol, Carbon $date = null, Carbon $from = null, Carbon $to = null): Quotes
281+
public function quotes(string $option_symbol, string $date = null, string $from = null, string $to = null): Quotes
279282
{
280283
// Stub
281284
return new Quotes($this->client->execute(self::BASE_URL . "options/quotes/$option_symbol/",

0 commit comments

Comments
 (0)