Skip to content

Commit

Permalink
Remove Carbon requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
KerryJones committed Jul 16, 2024
1 parent d3b7878 commit 1f94bae
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 122 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.4.1-alpha

- Changed all Carbon date endpoints to receive a string rather than a Carbon instance.

## v0.4.0-alpha

- Completed remaining endpoints:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ $client = new MarketDataApp\Client('your_api_token');
$quote = $client->indices->quote('DJI');
$candles = $client->indices->candles(
symbol: "DJI",
from: Carbon::parse('2022-09-01'),
to: Carbon::parse('2022-09-05'),
from: '2022-09-01',
to: '2022-09-05',
resolution: 'D'
);

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

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

// Mutual Funds
$candles = $client->mutual_funds->candles(
symbol: 'VFINX',
from: Carbon::parse('2022-09-01'),
to: Carbon::parse('2022-09-05'),
from: '2022-09-01',
to: '2022-09-05',
resolution: 'D'
);

Expand All @@ -56,12 +56,12 @@ $expirations = $client->options->expirations('AAPL');
$lookup = $client->options->lookup('AAPL 7/28/23 $200 Call');
$strikes = $client->options->strikes(
symbol: 'AAPL',
expiration: Carbon::parse('2023-01-20'),
date: Carbon::parse('2023-01-03'),
expiration: '2023-01-20',
date: '2023-01-03',
);
$option_chain = $client->options->option_chain(
symbol: 'AAPL',
expiration: Carbon::parse('2025-01-17'),
expiration: '2025-01-17',
side: Side::CALL,
);
$quotes = $client->options->quotes('AAPL250117C00150000');
Expand Down
16 changes: 10 additions & 6 deletions src/Endpoints/Indices.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MarketDataApp\Endpoints;

use Carbon\Carbon;
use GuzzleHttp\Exception\GuzzleException;
use MarketDataApp\Client;
use MarketDataApp\Endpoints\Responses\Indices\Candles;
Expand Down Expand Up @@ -38,8 +37,12 @@ public function quote(string $symbol, bool $fifty_two_week = false): Quote
* @param string $symbol The index symbol, without any leading or trailing index identifiers. For example, use DJI
* do not use $DJI, ^DJI, .DJI, DJI.X, etc.
*
* @param Carbon $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
* @param Carbon|null $to The rightmost candle on a chart (inclusive).
* @param string $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
* Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param string|null $to The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix,
* spreadsheet.
*
* @param string $resolution The duration of each candle.
* Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...) Hourly Resolutions: (hourly, H, 1H, 2H, ...)
* Daily Resolutions: (daily, D, 1D, 2D, ...)
Expand All @@ -51,12 +54,13 @@ public function quote(string $symbol, bool $fifty_two_week = false): Quote
* is not required.
*
* @return Candles
* @throws GuzzleException|ApiException
* @throws ApiException
* @throws GuzzleException
*/
public function candles(
string $symbol,
Carbon $from,
Carbon $to = null,
string $from,
string $to = null,
string $resolution = 'D',
int $countback = null
): Candles {
Expand Down
22 changes: 13 additions & 9 deletions src/Endpoints/Markets.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MarketDataApp\Endpoints;

use Carbon\Carbon;
use GuzzleHttp\Exception\GuzzleException;
use MarketDataApp\Client;
use MarketDataApp\Endpoints\Responses\Markets\Statuses;
Expand All @@ -23,23 +22,28 @@ public function __construct($client)
* Get the past, present, or future status for a stock market. The endpoint will respond with "open" for trading
* days or "closed" for weekends or market holidays.
*
* @param string $country The country. Use the two digit ISO 3166 country code. If no country is specified, US will
* @param string $country The country. Use the two-digit ISO 3166 country code. If no country is specified, US will
* be assumed. Only countries that Market Data supports for stock price data are available (currently only the
* United States).
*
* @param Carbon|null $date Consult whether the market was open or closed on the specified date.
* @param Carbon|null $from The earliest date (inclusive). If you use countback, from is not required.
* @param Carbon|null $to The last date (inclusive).
* @param string|null $date Consult whether the market was open or closed on the specified date. Accepted timestamp
* inputs: ISO 8601, unix, spreadsheet.
*
* @param string|null $from The earliest date (inclusive). If you use countback, from is not required. Accepted
* timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param string|null $to The last date (inclusive). Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param int|null $countback Countback will fetch a number of dates before to If you use from, countback is not
* required.
* @return Statuses
*
* @throws GuzzleException|ApiException
*/
public function status(
string $country = "US",
Carbon $date = null,
Carbon $from = null,
Carbon $to = null,
string $date = null,
string $from = null,
string $to = null,
int $countback = null
): Statuses {
// Stub
Expand Down
25 changes: 15 additions & 10 deletions src/Endpoints/MutualFunds.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MarketDataApp\Endpoints;

use Carbon\Carbon;
use GuzzleHttp\Exception\GuzzleException;
use MarketDataApp\Client;
use MarketDataApp\Endpoints\Responses\MutualFunds\Candles;
Expand All @@ -23,14 +22,20 @@ public function __construct($client)
* Get historical price candles for a mutual fund.
*
* @param string $symbol The mutual fund's ticker symbol.
* @param Carbon $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
* @param Carbon|null $to The rightmost candle on a chart (inclusive).
*
* @param string $from The leftmost candle on a chart (inclusive). If you use countback, to is not required.
* Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param string|null $to The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix,
* spreadsheet.
*
* @param string $resolution The duration of each candle.
* Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...) Hourly Resolutions: (hourly, H, 1H, 2H, ...)
* Daily Resolutions: (daily, D, 1D, 2D, ...)
* Weekly Resolutions: (weekly, W, 1W, 2W, ...)
* Monthly Resolutions: (monthly, M, 1M, 2M, ...)
* Yearly Resolutions:(yearly, Y, 1Y, 2Y, ...)
* - Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...)
* - Hourly Resolutions: (hourly, H, 1H, 2H, ...)
* - Daily Resolutions: (daily, D, 1D, 2D, ...)
* - Weekly Resolutions: (weekly, W, 1W, 2W, ...)
* - Monthly Resolutions: (monthly, M, 1M, 2M, ...)
* - Yearly Resolutions:(yearly, Y, 1Y, 2Y, ...)
*
* @param int|null $countback Will fetch a number of candles before (to the left of) to. If you use from, countback
* is not required.
Expand All @@ -40,8 +45,8 @@ public function __construct($client)
*/
public function candles(
string $symbol,
Carbon $from,
Carbon $to = null,
string $from,
string $to = null,
string $resolution = 'D',
int $countback = null,
): Candles {
Expand Down
57 changes: 30 additions & 27 deletions src/Endpoints/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MarketDataApp\Endpoints;

use Carbon\Carbon;
use GuzzleHttp\Exception\GuzzleException;
use MarketDataApp\Client;
use MarketDataApp\Endpoints\Responses\Options\Expirations;
Expand Down Expand Up @@ -35,13 +34,13 @@ public function __construct($client)
* @param int|null $strike Limit the lookup of expiration dates to the strike provided. This will cause the endpoint to
* only return expiration dates that include this strike.
*
* @param Carbon|null $date Use to lookup a historical list of expiration dates from a specific previous trading
* @param string|null $date Use to lookup a historical list of expiration dates from a specific previous trading
* day. If date is omitted the expiration dates will be from the current trading day during market hours or from the
* last trading day when the market is closed.
* last trading day when the market is closed. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @throws ApiException|GuzzleException
*/
public function expirations(string $symbol, int $strike = null, Carbon $date = null): Expirations
public function expirations(string $symbol, int $strike = null, string $date = null): Expirations
{
// Stub
return new Expirations($this->client->execute(self::BASE_URL . "options/expirations/$symbol",
Expand Down Expand Up @@ -72,15 +71,15 @@ public function lookup(string $input): Lookup
*
* @param string $symbol The underlying ticker symbol for the options chain you wish to lookup.
*
* @param Carbon|null $expiration Limit the lookup of strikes to options that expire on a specific expiration date.
* @param string|null $expiration Limit the lookup of strikes to options that expire on a specific expiration date.
*
* @param Carbon|null $date Use to lookup a historical list of strikes from a specific previous trading day. If date
* @param string|null $date Use to lookup a historical list of strikes from a specific previous trading day. If date
* is omitted the expiration dates will be from the current trading day during market hours or from the last trading
* day when the market is closed.
* day when the market is closed. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @throws ApiException|GuzzleException
*/
public function strikes(string $symbol, Carbon $expiration = null, Carbon $date = null): Strikes
public function strikes(string $symbol, string $expiration = null, string $date = null): Strikes
{
// Stub
return new Strikes($this->client->execute(self::BASE_URL . "options/strikes/$symbol",
Expand All @@ -97,13 +96,15 @@ public function strikes(string $symbol, Carbon $expiration = null, Carbon $date
* all expirations.
*
* @param string $symbol The ticker symbol of the underlying asset.
* @param Carbon|null $date Use to lookup a historical end of day options chain from a specific trading day. If no
*
* @param string|null $date Use to lookup a historical end of day options chain from a specific trading day. If no
* date is specified the chain will be the most current chain available during market hours. When the market is
* closed the chain will be from the last trading day.
* closed the chain will be from the last trading day. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param Carbon|Expiration $expiration
* @param string|Expiration $expiration
* - Limits the option chain to a specific expiration date. Accepted date inputs: ISO 8601, unix, spreadsheet. This
* parameter is only required if requesting a quote along with the chain.
* parameter is only required if requesting a quote along with the chain. Accepted timestamp inputs: ISO 8601, unix,
* spreadsheet.
*
* - If omitted the next monthly expiration for real-time quotes or the next monthly expiration relative to the date
* parameter for historical quotes will be returned.
Expand All @@ -114,11 +115,11 @@ public function strikes(string $symbol, Carbon $expiration = null, Carbon $date
* consume your requests very quickly. The full SPX option chain has more than 20,000 contracts. A request is
* consumed for each contact you request with a price in the option chain.
*
* @param Carbon|null $from Limit the option chain to expiration dates after from (inclusive). Should be combined
* with to create a range.
* @param string|null $from Limit the option chain to expiration dates after from (inclusive). Should be combined
* with to create a range. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param Carbon|null $to Limit the option chain to expiration dates before to (not inclusive). Should be combined
* with from to create a range.
* @param string|null $to Limit the option chain to expiration dates before to (not inclusive). Should be combined
* with from to create a range. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param int|null $month Limit the option chain to options that expire in a specific month (1-12).
*
Expand Down Expand Up @@ -202,10 +203,10 @@ public function strikes(string $symbol, Carbon $expiration = null, Carbon $date
*/
public function option_chain(
string $symbol,
Carbon $date = null,
Carbon|Expiration $expiration = Expiration::ALL,
Carbon $from = null,
Carbon $to = null,
string $date = null,
string|Expiration $expiration = Expiration::ALL,
string $from = null,
string $to = null,
int $month = null,
int $year = null,
bool $weekly = true,
Expand Down Expand Up @@ -261,21 +262,23 @@ public function option_chain(
* @param string $option_symbol The option symbol (as defined by the OCC) for the option you wish to lookup. Use the
* current OCC option symbol format, even for historic options that quoted before the format change in 2010.
*
* @param Carbon|null $date Use to lookup a historical end of day quote from a specific trading day. If no date is
* @param string|null $date Use to lookup a historical end of day quote from a specific trading day. If no date is
* specified the quote will be the most current price available during market hours. When the market is closed the
* quote will be from the last trading day.
* quote will be from the last trading day. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
*
* @param Carbon|null $from Use to lookup a series of end of day quotes. From is the oldest (leftmost) date to
* @param string|null $from Use to lookup a series of end of day quotes. From is the oldest (leftmost) date to
* return (inclusive). If from/to is not specified the quote will be the most current price available during market
* hours. When the market is closed the quote will be from the last trading day.
* hours. When the market is closed the quote will be from the last trading day. Accepted timestamp inputs: ISO
* 8601, unix, spreadsheet.
*
* @param Carbon|null $to Use to lookup a series of end of day quotes. From is the newest (rightmost) date to return
* @param string|null $to Use to lookup a series of end of day quotes. From is the newest (rightmost) date to return
* (exclusive). If from/to is not specified the quote will be the most current price available during market hours.
* When the market is closed the quote will be from the last trading day.
* When the market is closed the quote will be from the last trading day. Accepted timestamp inputs: ISO 8601, unix,
* spreadsheet.
*
* @throws ApiException|GuzzleException
*/
public function quotes(string $option_symbol, Carbon $date = null, Carbon $from = null, Carbon $to = null): Quotes
public function quotes(string $option_symbol, string $date = null, string $from = null, string $to = null): Quotes
{
// Stub
return new Quotes($this->client->execute(self::BASE_URL . "options/quotes/$option_symbol/",
Expand Down
Loading

0 comments on commit 1f94bae

Please sign in to comment.