Compare commits
No commits in common. "cc8708e2c963f71d8f3f4ae166e4376ff6b27517" and "175ca5ebdd895a3d561ba5450a365bb3ca264611" have entirely different histories.
cc8708e2c9
...
175ca5ebdd
|
|
@ -1 +0,0 @@
|
||||||
.venv/
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
from schwab import auth, client
|
|
||||||
from authlib.integrations.base_client.errors import OAuthError
|
|
||||||
import os
|
|
||||||
import json
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
script_directory = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
|
|
||||||
api_key = 'mwxx0yUewlCWbRscYEhArMVoJiS8GTGP'
|
|
||||||
app_secret = 'C41aiGaJUFgdMnTu'
|
|
||||||
redirect_uri = 'https://127.0.0.1:8182'
|
|
||||||
token_path = os.path.join(script_directory, 'token.json')
|
|
||||||
|
|
||||||
try:
|
|
||||||
c = auth.client_from_token_file(token_path, api_key, app_secret)
|
|
||||||
except FileNotFoundError as e:
|
|
||||||
print(e)
|
|
||||||
c = auth.client_from_login_flow(
|
|
||||||
api_key, app_secret, redirect_uri, token_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
r = c.get_price_history("TSLA",
|
|
||||||
period_type=client.Client.PriceHistory.PeriodType.DAY,
|
|
||||||
start_datetime=datetime.datetime.strptime("2024-8-1", "%Y-%m-%d"),
|
|
||||||
end_datetime=datetime.datetime.strptime("2024-8-1", "%Y-%m-%d"),
|
|
||||||
frequency_type=client.Client.PriceHistory.FrequencyType.MINUTE,
|
|
||||||
frequency=client.Client.PriceHistory.Frequency.EVERY_THIRTY_MINUTES)
|
|
||||||
|
|
||||||
# assert r.status_code == 200, r.raise_for_status()
|
|
||||||
print(json.dumps(r.json(), indent=4))
|
|
||||||
|
|
||||||
except OAuthError:
|
|
||||||
print("Token is invalid; please refresh manually")
|
|
||||||
auth.client_from_login_flow(api_key, app_secret, redirect_uri, token_path)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"creation_timestamp": 1744667071, "token": {"expires_in": 1800, "token_type": "Bearer", "scope": "api", "refresh_token": "iZjtH8G_wElu5Iw-_IiP0ZIeiP2Qikmtji931m-UpcmuXZ4UFs-MKrqALNfMdpVb-ErVIDhnZLr78gL_I-LEAKGaVsBXSa-PeKyKC5UsXQTeyFGXjBmeKpLvu1X-E0yRvvVcnfqLO9M@", "access_token": "I0.b2F1dGgyLmNkYy5zY2h3YWIuY29t.rN7e5-o4kNvP5j9om0aQWJPrFJzcUZu0c8FHOSbjgD4@", "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2YmZkYzYyODMwMmY5YTQyNjYzYjM3MTM3ODcyN2IxZjM3ZDJkOTkyOWUwZjg3NDYzNjkwYzcyMThiZDA5MDllIiwiYXVkIjoidlV2c0RXTHR6V2tROHVmeExVTWhkd1Fpd0FDZ0dWM3UiLCJpc3MiOiJ1cm46Ly9hcGkuc2Nod2FiYXBpLmNvbSIsImV4cCI6MTc0NDY3MDY2OSwiaWF0IjoxNzQ0NjY3MDY5LCJqdGkiOiIwZTdhMDgxMi1lN2VmLTQ3OTctYTg4OC1jZjRiNDY5MjlmMzIifQ.gpTcd3-B0W92wxhXItyvI70WF7CTEyEznCdtPKROjcA", "expires_at": 1744668871}}
|
|
||||||
Loading…
Reference in New Issue