dchrostowski / investopedia_simulator_api

A simple Python API for Investopedia's stock simulator games. This programmatically logs into Investopedia and can retrieve portfolio summary, get stock quotes & option chain lookups, execute trades - buy & sell shares, puts, calls, sell short, etc.
MIT License
33 stars 12 forks source link

Add better error handling for unquotable stocks. #28

Open jcdocka opened 3 years ago

jcdocka commented 3 years ago

Some stocks that I search using quote come back as either "unable to parse quote" e.g. GMBL,WW,XYF, etc. or "unable to get quote for" e.g. TCTL, TTAC

Thoughts?

dchrostowski commented 3 years ago

Sorry it took me a while to look into this. So I attempted to get quotes for the 5 stocks you mentioned there. I was able to get quotes back for GMBL, WW, and XYF and got parse failures on TCTL and TTAC.

I'm blaming the failures for TCTL and TTAC on Investopedia. If you go and try to order TCTL or TTAC on their site, no results show up..

Can you reproduce your issue? Here's basically what I did to test your issue. GMBL, WW, and XYF returned quotes as expected, and TCTL and TTAC did not, also as expected.

client = InvestopediaApi(credentials)

p = client.portfolio

quotes_to_test = ['GMBL','WW','XYF','TCTL','TTAC']

for quote in quotes_to_test:
    try:
        result = client.get_stock_quote(quote)
        if result is not None:
            print(result.__dict__)
    except Exception as err:
        print(err)
jcdocka commented 3 years ago

Attached is the list of stocks I could not get to parse. I checked a couple of these the way you did, via the trade (they did not show up), but they did have a quote page for them, which is weird.
parse.txt