itsjafer / schwab-api

A python library for placing trades on Charles Schwab
MIT License
213 stars 66 forks source link

Not Placing orders #16

Closed MaxxRK closed 11 months ago

MaxxRK commented 1 year ago

When placing an order the following message is produced and it does not place the order. This happens whether buying or selling.

unsuccessful [11:18 AM] The order verification produced the following messages: ['message not found', 'Please note that the issuer of this security is deficient in meeting the Exchange\x92s continued listing requirements. You may want to consider doing further research before placing this order. (DO840)', 'Please Note: %SYMBOL% has a special maintenance requirement of %2%%. (AC157)'] [11:18 AM] unsuccessful

itsjafer commented 12 months ago

An update on this -- Schwab's web app calls a new API endpoint that didn't exist when I first created this package.

I spent some time today to understand how we can call it (because there's been some changes in authorization) and believe I've figured out how to get the package to place orders on the new API. I don't use Schwab anymore to actively trade, so I'll have to move some money around and test it in the coming days, but I'm optimistic this could solve this problem (or, offer more transparency in identifying the solution)!

MaxxRK commented 12 months ago

Awesome! I did try to do this myself, and it seemed like the authorization cookies were getting changed more than I could keep them updated. I hope you have better luck.

I also made a fork and got this working using the form and filling it out with the web driver. If you cannot hit the endpoint directly I can do a PR with those changes if you would like.

itsjafer commented 11 months ago

I just pushed version 0.3.0, which features a trade_v2() function. I suspect this alone will not resolve the issue, but I can more clearly reproduce the trade in the UI now to identify what needs to be done to verify the order.

Could you all give me an example stock that generates this message?

MaxxRK commented 11 months ago

For me I get this message on all stocks I try to buy with this. An example would be SYTA.

itsjafer commented 11 months ago

Hi, could you please try placing an order using both the regular api.trade() and api.trade_v2() functions? I was able to successfully buy SYTA using both accounts. cc: @NelsonDane

MaxxRK commented 11 months ago

On api.trade() I get unsuccessful The order verification produced the following messages: ['message not found'] ([''], False)

On api.trade_v2() I get unsuccessful The order verification produced the following messages: ['message not found'] ([''], False)

I also have multiple accounts and the api is only showing that I have one account now. I also tried this with INTC

WinesProof commented 11 months ago

@MaxxRK, can you identify where in trade_v2() it returns? I suspect it's one of the if r.status_code != 200 sections, in which case we could learn more if you print out r.reason. I encountered some "request entity too large" errors that I was able to get around, but I'm still trying to understand why I get the error and why the workaround works.

MaxxRK commented 11 months ago

I ran this the first time with just example.py and schwab_api==0.3.2 installed. I put some prints in after each if response and ran it from the folder itself schwab_api.schwab_api

this is what I got

The order verification was successful The order verification produced the following messages: []

There was quite a bit of json underneath this. I did not see this order in my order status page still only seeing one account when I should see multiple, but it does seem to output something.

Correction: I was looking at the wrong account the order did input with this as long as I am using the package downloaded from github.

itsjafer commented 11 months ago

@MaxxRK, to be clear, the orders are going through as expected then?

MaxxRK commented 11 months ago

They went through if I just download the repo from GitHub and run the example through that. If I run it from the package it did not seem to go through.

cnMuggle commented 11 months ago

An update on this -- Schwab's web app calls a new API endpoint that didn't exist when I first created this package.

I spent some time today to understand how we can call it (because there's been some changes in authorization) and believe I've figured out how to get the package to place orders on the new API. I don't use Schwab anymore to actively trade, so I'll have to move some money around and test it in the coming days, but I'm optimistic this could solve this problem (or, offer more transparency in identifying the solution)!

Schwab acquired TD Ameritrade and closed the TD API, resulting in the original python tda-api (https://tda-api.readthedocs.io/en/latest/getting-started.html#important-new-about-the-charles-schwab-transition) no-longer work any more. I think that's where this new API endpoint come from.