Skip to content

Commit

Permalink
Add documenting comments
Browse files Browse the repository at this point in the history
  • Loading branch information
keegandahm committed Mar 7, 2024
1 parent 3dd1c7d commit 6f897c7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions monarchmoney/monarchmoney.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,14 @@ async def get_recent_account_balances(self, start_date: date = None) -> Dict[str
)

async def get_account_snapshots_by_type(self, start_date: date, timeframe: str):
# if timeframe not in ('year', 'month', 'day'):
# raise Exception(f'Unknown timeframe "{timeframe}"')
"""
Retrieves snapshots of the net values of all accounts of a given type, with either a yearly
monthly granularity.
Note, `month` is not a full ISO datestring, as it doesn't include the day.
Instead it looks like, e.g., 2023-01
"""
if timeframe not in ('year', 'month'):
raise Exception(f'Unknown timeframe "{timeframe}"')

query = gql("""
query GetSnapshotsByAccountType($startDate: Date!, $timeframe: Timeframe!) {
Expand All @@ -298,7 +304,13 @@ async def get_account_snapshots_by_type(self, start_date: date, timeframe: str):
}
)

async def get_aggregate_snapshots(self, start_date: date = None, end_date: date = None, account_type: str = None) -> dict:
async def get_aggregate_snapshots(
self, start_date: Optional[date] = None, end_date: Optional[date] = None, account_type: Optional[str] = None
) -> dict:
"""
Retrieves the daily net value of all accounts, optionally between `start_date` and `end_date`,
and optionally only for accounts of type `account_type`.
"""
query = gql("""
query GetAggregateSnapshots($filters: AggregateSnapshotFilters) {
aggregateSnapshots(filters: $filters) {
Expand All @@ -313,7 +325,7 @@ async def get_aggregate_snapshots(self, start_date: date = None, end_date: date
start_date = start_date.isoformat()
else:
# The mobile app defaults to 150 years ago today
# The mobile app might have a leap year bug, so I'm just setting day=1
# The mobile app might have a leap year bug, so instead default to setting day=1
today = date.today()
start_date = date(year=today.year - 150, month=today.month, day=1).isoformat()
if end_date is not None:
Expand Down

0 comments on commit 6f897c7

Please sign in to comment.