Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic if ticker not available #79

Closed
smjure opened this issue Jan 11, 2022 · 1 comment
Closed

Panic if ticker not available #79

smjure opened this issue Jan 11, 2022 · 1 comment

Comments

@smjure
Copy link

smjure commented Jan 11, 2022

I am requesting quotes client.GetQuotes([]symbols) for a bunch of tickers and get panic if a ticker is not available in FinViz, e.g. ticker SHAC is not.. 
error received while scraping quote for 'SHAC': error getting url: 'https://finviz.com/quote.ashx?t=SHAC&ty=c&p=d&b=1', status code: '404'
I could catch the error, remove the ticker and pull again, but that could be much overhead, specially from FinViz point of view. Could this be fixed internally so the program does not panic but throws warning instead that a ticker is not available?

d3an added a commit that referenced this issue Jan 13, 2022
### Change to Function Signature

`GetQuotes` now returns `(Results, error)`. The error here should either be `nil` or `fmt.Errorf("error failed to generate rows from quote KVP map")`.

`Results` is constructed as `Results{Data: *dataframe.DataFrame, Warnings: []Warning, Errors: []Error}`. As follows:
  - `Data` is the previously returned DataFrame
  - `Warnings` is a slice of new `Warning` structs. An example `Warning` is given by `Warning{Ticker: "INVALID", Error: fmt.Errorf("resource not found")}`. Right now, warnings only indicate that Finviz does not support the given ticker.
  - `Errors` is a slice of new `Error` structs. An example `Error` is given by `Error{Ticker: "SNAP", Error: fmt.Errorf(...)}`. Errors could occur if Finviz has placed you on a block list (usually done via Cloudflare) or could be an internal library error. 

If a Warning or Error exists for a Ticker, then the returned DataFrame will not have a row for that Ticker. The three sets, i.e., Data, Warnings, and Errors, are mutually exclusive.

### Other Changes

- Added `Exchange` column to returned DataFrame.
- Fixed a bug that sometimes returned `S&P,500` as a stock's Index; now returns `S&P500`.
- Added data cleaning to DataFrame results, i.e., most columns should now correspond to their actual data type. 
- Added support for backoff algorithm on request frequency.

Closes #78, #79
@d3an d3an closed this as completed Jan 13, 2022
@d3an d3an reopened this Jan 13, 2022
@d3an
Copy link
Owner

d3an commented Jan 13, 2022

Read about the changes here.

@d3an d3an closed this as completed Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants