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

JsonAnnouncement's RecordDate should be able to parse to null. #658

Merged
merged 1 commit into from
Aug 22, 2023
Merged

JsonAnnouncement's RecordDate should be able to parse to null. #658

merged 1 commit into from
Aug 22, 2023

Conversation

KevinDeBeer
Copy link
Contributor

@KevinDeBeer KevinDeBeer commented Aug 21, 2023

Description

Currently GetAnnouncementAsync and ListAnnouncementsAsync might fail when record_date is null.
In that case, an unhandled exception occurs.
Checking the API reference on https://paper-api.alpaca.markets/v2/corporate_actions/announcements shows that record_date is returned as null quite often.

Fixes # (657)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Reproduction:
Execute ListAnnouncementsAsync with a StartDate of 2023-08-01 and EndDate of 2023-08-20.

Code sample:

var actionTypes = new CorporateActionType[] { CorporateActionType.Dividend, CorporateActionType.Merger, CorporateActionType.SpinOff, CorporateActionType.Split };
var interval = new Interval<DateOnly>(DateOnly.FromDateTime(startDate), DateOnly.FromDateTime(endDate));
var announcementsRequest = new AnnouncementsRequest(actionTypes.ToList(), interval);
var announcements = await _tradingClient.ListAnnouncementsAsync(announcementsRequest, cancellationToken);

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

@OlegRa OlegRa self-requested a review August 22, 2023 19:21
@OlegRa OlegRa self-assigned this Aug 22, 2023
@OlegRa OlegRa added the bug Something isn't working label Aug 22, 2023
@OlegRa OlegRa added this to the SDK 6.x Stable milestone Aug 22, 2023
Copy link
Collaborator

@OlegRa OlegRa left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks a lot for this fix!

@OlegRa OlegRa merged commit 83cd5bb into alpacahq:develop Aug 22, 2023
2 checks passed
OlegRa pushed a commit that referenced this pull request Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants