Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion schwab_api/schwab.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ def get_account_info(self):

return account_info

def get_transaction_history_v2(self, account_id):
def get_transaction_history_v2(self, account_id, from_date=None, to_date=None):
"""
account_id (int) - The account ID to place the trade on. If the ID is XXXX-XXXX,
we're looking for just XXXXXXXX.
from_date (datetime.date) - the date the transaction history starts from. Leave it empty to search for all.
to_date (datetime.date) - the date the transaction history ends with. Leave it empty to search for all.

Returns a dictionary of transaction history entries for the provided account ID.
"""
Expand Down Expand Up @@ -116,6 +118,11 @@ def get_transaction_history_v2(self, account_id):
"sortColumn": "Date",
"sortDirection": "Descending"
}
if from_date and to_date:
data["timeFrame"] = "SpecifyDateRange"
data["fromDate"] = from_date.strftime('%Y-%m-%d')
data["toDate"] = to_date.strftime('%Y-%m-%d')

r = requests.post(urls.transaction_history_v2(), json=data, headers=self.headers)
if r.status_code != 200:
return [r.text], False
Expand Down