Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add stock options functionality #50

Merged
merged 3 commits into from Apr 2, 2024

Conversation

CompoTypo
Copy link
Contributor

@CompoTypo CompoTypo commented Mar 14, 2024

This branch contains a small refactor for cookie and crumb acquisition as well as the primary feature of a getStockOptions method.

I have been using this package for quite a while now and love it. I have been getting more into options and I would like to enhance my own personal trading info infra by adding onto this library.

I tried my best to stick to the conventions laid out in the API/decoder and followed the formatting and checks as described in the CONTRIB. Hopefully it is up to standard.

If you have any recommendations or questions, please don't hesitate to comment.

Best,
Compo

@CompoTypo CompoTypo force-pushed the feature/add_stock_options_functionality branch from 17982da to 729e02a Compare March 16, 2024 06:39
Copy link
Owner

@scheb scheb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look really good! I'd just want to have a test case for the value mapping and then we'd be good to merge.

Comment on lines 304 to 317
public function transformOptions(string $responseBody): array
{
$decoded = json_decode($responseBody, true);
if (!isset($decoded['optionChain']['result']) || !\is_array($decoded['optionChain']['result'])) {
throw new ApiException('Yahoo Search API returned an invalid result.', ApiException::INVALID_RESPONSE);
}

$results = $decoded['optionChain']['result'];

// Single element is returned directly in "quote"
return array_map(function (array $item) {
return $this->createOption($item);
}, $results);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have a test case similar to transformQuotes_jsonGiven_createArrayOfQuote for this method. So we can ensure all expected fields are properly mapped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is updated with additional tests for the options result

@CompoTypo CompoTypo force-pushed the feature/add_stock_options_functionality branch 2 times, most recently from d4549dc to 184edf6 Compare March 27, 2024 09:38
@CompoTypo
Copy link
Contributor Author

Thank you for the positive words! I do recommend re-reviewing the work since the models are expanded upon greatly since the initial pr. Thank you for your patience. Please let me know if there are any new issues.

@CompoTypo CompoTypo requested a review from scheb March 27, 2024 09:43
@CompoTypo CompoTypo force-pushed the feature/add_stock_options_functionality branch 2 times, most recently from 124b0e4 to 17acd21 Compare March 27, 2024 09:53
@scheb
Copy link
Owner

scheb commented Mar 29, 2024

Wow, you really did a great effort with the unit tests, thank you!

Other than that, I'd be happy to merge that in.

@CompoTypo CompoTypo force-pushed the feature/add_stock_options_functionality branch from 17acd21 to d58d79f Compare March 30, 2024 05:00
@CompoTypo
Copy link
Contributor Author

I squashed another commit on top. The changes should take care of those few requests. Have a great weekend!

@scheb scheb merged commit 91a740b into scheb:4.x Apr 2, 2024
5 checks passed
@scheb
Copy link
Owner

scheb commented Apr 2, 2024

Thank you for your work. Has been released under v4.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants