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

Add queries for net value, recent daily account values #93

Merged
merged 8 commits into from
Apr 21, 2024

Conversation

keegandahm
Copy link
Contributor

@keegandahm keegandahm commented Mar 7, 2024

This PR adds 3 queries, for retrieving aggregateSnapshots, snapshotsByAccountType, and accounts.recentBalances.

recentBalances is used by the web app to retrieve the daily value of a given account, primarily to generate the sparklines seen on the Accounts page.

snapshotsByAccountType is used by the web app to generate the bar charts showing different account types' contributions to your net worth, on the Accounts page.

aggregateSnapshots is used by the mobile app to show your historical daily net worth, or to see the historical value of certain account types, e.g. cash, loans, brokerage, etc..

Copy link
Owner

@hammem hammem left a comment

Choose a reason for hiding this comment

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

Thanks, @keegandahm ! I completely agree with you on using the date type for a function param. However, as of now, the rest of the library is using str. I'd like to keep it consistent, even if not ideal.

It's worth starting a discussion, if you'd like, to see if it's worth migrating the whole library over to using date types. It would give us some more guarantees and is probably the better long-term way to go.

Comment on lines 282 to 283
Note, `month` is not a full ISO datestring, as it doesn't include the day.
Instead it looks like, e.g., 2023-01
Copy link
Owner

Choose a reason for hiding this comment

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

wow, that's fun. thanks, Monarch!

@@ -248,6 +248,112 @@ async def get_account_type_options(self) -> Dict[str, Any]:
graphql_query=query,
)

async def get_recent_account_balances(
self, start_date: Optional[date] = None
Copy link
Owner

Choose a reason for hiding this comment

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

For now, please change the start_date param and others in this PR to str.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this to a str

@hammem
Copy link
Owner

hammem commented Apr 20, 2024

@keegandahm , if you'd like this included in the next PyPI version, please update with requested changes and I'll merge it in. Thanks!

@keegandahm
Copy link
Contributor Author

Hey @hammem, just give me a bit and I'll add these changes today

@keegandahm
Copy link
Contributor Author

Hey @hammem, I've made the changes you requested.

Regarding moving the library over to date types, I'm generally in favor of leaning on the type system to enforce valid arguments to an interface, even with dynamically typed languages like Python. Having date objects means developers don't have to think about how the argument is formatted, and that if they give you a date object, you can guarantee a correctly formatted request.

That said, consistency is also very important. One way I can think of to softly transition existing functions to date arguments is to only document using them with dates, but support both by checking the type of the argument and acting appropriately.

Let me know if there are any other changes you want, thanks!

Copy link
Owner

@hammem hammem left a comment

Choose a reason for hiding this comment

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

Thanks, @keegandahm !

@hammem hammem merged commit 1820f3c into hammem:main Apr 21, 2024
2 checks passed
@keegandahm keegandahm deleted the keegandahm/add-recent-balance branch April 22, 2024 03:42
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.

2 participants