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 request: history #13

Open
BamaJoe411 opened this issue Jan 23, 2025 · 4 comments · May be fixed by #14
Open

Feature request: history #13

BamaJoe411 opened this issue Jan 23, 2025 · 4 comments · May be fixed by #14
Assignees

Comments

@BamaJoe411
Copy link

History

I would like a way to get the transaction history found in the https://public.com/settings/history uri

@NelsonDane NelsonDane linked a pull request Jan 23, 2025 that will close this issue
@NelsonDane
Copy link
Owner

Sure! Started working on it here: #14. Let me know how it works!

@NelsonDane NelsonDane self-assigned this Jan 23, 2025
@NelsonDane NelsonDane linked a pull request Jan 23, 2025 that will close this issue
@BamaJoe411
Copy link
Author

I tried using the updated version in #14 but it seems that the get_account_history method doesn't seem to be getting the entire account history.

Here is my script

from public_invest_api import Public
from dotenv import load_dotenv
import json
import os

load_dotenv()
username = os.getenv('username')
password = os.getenv('password')

public = Public()
public.login(
    username=username,
    password=password,
    wait_for_2fa=False
)

history = public.get_account_history(date='all')
json_history = json.dumps(history, indent=4)

with open('history.json', 'w') as file:
    file.write(json_history)

@BamaJoe411
Copy link
Author

I'm a noob and didn't mean to close the issue. 😅

@BamaJoe411 BamaJoe411 reopened this Jan 25, 2025
@NelsonDane
Copy link
Owner

I tried using the updated version in #14 but it seems that the get_account_history method doesn't seem to be getting the entire account history.

Here is my script

from public_invest_api import Public
from dotenv import load_dotenv
import json
import os

load_dotenv()
username = os.getenv('username')
password = os.getenv('password')

public = Public()
public.login(
username=username,
password=password,
wait_for_2fa=False
)

history = public.get_account_history(date='all')
json_history = json.dumps(history, indent=4)

with open('history.json', 'w') as file:
file.write(json_history)

That is correct, it doesn't get the entire history in one request (neither does the public website). If you notice in the function's returns, one of them is the nextToken. This is used for pagination. So if you want the next page of history, get the nextToken from the previous function call, then pass it into the next function call. If you really want the entire history, then you could make a loop where each nextToken is fed into the next request. Hopefully that makes sense!

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 a pull request may close this issue.

2 participants