mrhappyasthma / IsThisStockGood

A tool for evaluating companies using the Rule #1 investing principles.
http://www.isthisstockgood.com
22 stars 10 forks source link

Support for tickets with hyphen - or period . ? #54

Closed benninkcorien closed 1 month ago

benninkcorien commented 1 year ago

How do I enter tickers that contain a hyphen or a period?

For example SHELL.AS or BRK-B

mrhappyasthma commented 1 year ago

This is probably broken. All of the sites I use for data use a slightly different format. This worked once upon a time, but I've had to shuffle data providers and have not tested this thoroughly.

When I have some time I'll take a look at this again.

benninkcorien commented 1 year ago

BRK needs a period, not a hyphen. BRK.B shows correct results.

The code already supports the period in searchbox.html, if you want to support stocks with hyphens this works (I thought I had to add this, but turns out I didn't):

const hyphenKey = 173;
const otherHyphenKey = 109;
return ((key >= 65 && key <= 90) || key == backspaceKey || key == periodKey || key == hyphenKey || key == otherHyphenKey);

Yahoo seems to work fine with SHELL.AS. I checked this by throwing some print() statements into the YahooFinance.py file, and checking the output in the console (it prints a correct self.current_price for example).

But it looks like stockrow.com is not supporting any Dutch tickers, so the Shell.AS one will never work for that API.

And if Stockrow results in a 404, the json.loads(data) in StockRow crashes because it is trying to parse plain HTML and not JSON.

And this is where I stopped tweaking/working my way back through your code :) I'll mark this as closed and will have to figure out a different way to get something like this for Dutch tickers.

mrhappyasthma commented 1 year ago

Seems stockrow defaults to using period notation (e.g. BRK.B seems to work).

stockrow definitely does not have anything other than US stocks. I used to use Morningstar (which was still mostly US data, but had some international stocks) but they changed their site to make it harder to scrape.

I still need to find a more universal data source.

mrhappyasthma commented 1 year ago

That said, I think I should update the code to support either a period or a hyphen. And then internally just convert it to the format expected by each data source. Rather than preventing the hyphen from being used at all.

benninkcorien commented 1 year ago

You could also do something like OpenBB is doing maybe? https://github.com/OpenBB-finance/OpenBBTerminal/

Ask for any free (or paid) API keys the user is able to enter on first run. Those are less likely to change and break something in the future.

mrhappyasthma commented 1 year ago

I'm hesitant to require users to provide API keys. This tool is designed to be run as a webpage that can be easily accessed and is simple/free (which is what limits my data options).

I suppose a feature request could be to run the tool via the command line providing it an API key to collect more accurate data. But that's outside the scope of my original intent -- which was just to get the web page running and functional.

benninkcorien commented 1 year ago

That's also what I really like about this tool - no hassle, it just runs.

(But most of the free APIs are really easy to sign up for, and if that would make maintaining this easier, I wouldn't mind having to do that.)

kocielnik commented 1 month ago

BRK.B shows correct results.

Verified again with the current data source (MSN Money).

Checked SHELL.AS: not available in MSN Money at all (refers to Amsterdam Exchange, Yahoo has it).

Checked SHEL (Shell): Result OK.

@benninkcorien, I would say the main issue you mentioned is not reproducible anymore, and what is left is that the search box has a length limit set at 5 while SHELL.AS is 8 characters long.

Created #73 to increase the limit.

kocielnik commented 1 month ago

Underlying data for Shell will be the same for both American and European exchanges.

The difference is in price: $74.13 (US) vs 34.39€ [^1].

If this matters, we could fetch the price from a separate source for European exchanges when an exchange code follows the ticker after a dot.

@benninkcorien, please create a separate ticket for that if it's a use case that matters to you.

[^1]: I don't understand, why the difference is over 200% while EUR/USD rate I see is 1.07.

benninkcorien commented 1 month ago

Thanks for checking!

I'll just take it as: Amsterdam Exchange AEX tickers are not supported. Closing this.