tylerebowers / Schwab-API-Python

An easy and lightweight wrapper for using the Charles Schwab API.
https://pypi.org/project/schwabdev/
MIT License
300 stars 117 forks source link

Building a basic Schwab client #2

Closed luckman212 closed 7 months ago

luckman212 commented 7 months ago

Hi @tylerebowers thank you for this.

Abstract

I'm trying to build my first Schwab Python client and hitting some walls. I was very happy to stumble onto your repo, and want to use it as a stepping stone to a simple client that can fetch a token via OAuth and download a list of positions from my TDA (Schwab) account.

What I've done

I've registered and been approved for developer access, and created my first app on beta-developer.schwab.com. I added my appSecret and appKey to universe.py. The status of my app is currently Approved - Pending, like so:

(that may be the problem, not sure...)

Problems

First "problem" was I had to comment out stream from the main.py imports because the window_terminal package is only compatible with Windows and Linux (I use macOS...)

SUPPORTED_PLATFORMS = ('Windows', 'Linux')
assert (platform.system() in SUPPORTED_PLATFORMS), 'Platform not supported'

Next I was getting this somewhat cryptic error which turned out to be a red herring

-bash: ./main.py: cannot execute: required file not found

The actual problem was the main.py file was saved with Windows line-endings, which was throwing off my shell. Switching it to Unix format cleared that up.

TL;DR

So where I am now is this:

~/Schwab-API-Python 🐍 v3.12.2 (schwab-api)main!? $ ./main.py
Welcome to the unofficial Schwab api interface!
Github: https://github.com/tylerebowers/Schwab-API-Python
[ERROR]: Error in reading/writing token file, creating new token file.
[USER]: Please authorize this program to access your schwab account.
[USER]: Click to authenticate: https://api.schwabapi.com/v1/oauth/authorize?client_id=JvcExxxxxxxxxxxxxxxxxxxxxxxxxxxx&redirect_uri=https://127.0.0.1
[INFO]: Opening browser...
[INPUT]: After authorizing, wait for it to load (<1min) and paste the WHOLE url here:
(never loads)

screenshot:

Is any of this normal in your opinion?

tylerebowers commented 7 months ago

Approved - Pending means pending approval. Wait for the status to be approved. They really need to change this status, I have seen so many questions about this.

tylerebowers commented 7 months ago

And macOS is not currently supported. There are some file io issues (for arm-based) and window-terminals is used to spawn a seperate window to show the stream output. I am considering some alternatives but these fixes are not high on the todo list.