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

Tibble display not useful #4

Closed
eddelbuettel opened this issue Apr 16, 2018 · 12 comments
Closed

Tibble display not useful #4

eddelbuettel opened this issue Apr 16, 2018 · 12 comments

Comments

@eddelbuettel
Copy link

R> res <- riingo_iex_latest("SPY")
R> tail(res)
# A tibble: 6 x 6
  ticker date                 open  high   low close
  <chr>  <dttm>              <dbl> <dbl> <dbl> <dbl>
1 SPY    2018-04-16 13:49:00.000000  267.  267.  267.  267.
2 SPY    2018-04-16 13:50:00.000000  267.  267.  267.  267.
3 SPY    2018-04-16 13:51:00.000000  266.  266.  266.  266.
4 SPY    2018-04-16 13:52:00.000000  266.  266.  266.  266.
5 SPY    2018-04-16 13:53:00.000000  266.  266.  266.  266.
6 SPY    2018-04-16 13:54:00.000000  266.  266.  266.  266.
R> 

The time should be aware of localtime, and the resolution is simply not useful for pricing data.

@DavisVaughan
Copy link
Collaborator

Agreed. I already include convert_to_local_time() because I was unsure of what the best thing to do here was, but can default to local time. I can make the resolution dependent on the resample_frequency and return Date when appropriate rather than POSIXct

@eddelbuettel
Copy link
Author

Also omitting the pennies when the only difference is in pennies is ... not good. These are prices (and OHLC aren't even computed aggregates). Can we not always show two digits?

Also not how my options(digits.secs=6) creeps in and messes up the column alignment, but I guess that may be a tibble issue.

@DavisVaughan
Copy link
Collaborator

Re digits.secs) Yes ive reported that r-lib/pillar#102

Re pennies) Another pillar issue. Aggressive truncation. Try) options(pillar.sigfig = 6)

@eddelbuettel
Copy link
Author

eddelbuettel commented Apr 16, 2018

sigfig=6 may still fail on high priced stocks.But I guess this is a new bug :-/

R> res <- riingo_iex_latest("BRK.A")
Error: lexical error: invalid char in json text.
                                       <h1>Not Found</h1><p>The reques
                     (right here) ------^
R> 

Also affects ringo_latest.

@DavisVaughan
Copy link
Collaborator

Frustrating. I can catch riingo_iex_latest("abcde") because it returns actual JSON. riingo_iex_latest("BRK.A") returns HTML which gets converted into an xml_document

@tiingo
Copy link

tiingo commented Apr 16, 2018

Hi all,

Thanks for the great work @DavisVaughan

The reason for the URL handling is that we do not use "." in our ticker methodology. Let me talk to my team and see if we can implement a better JSON-encoded 404 for when "." are used. This should make it consistent. Thank you for the catch.

@DavisVaughan
Copy link
Collaborator

DavisVaughan commented Apr 16, 2018

Thanks @tiingo for the great support.

In the mean time, the dev version catches it with a slightly more informative error:

> riingo::riingo_iex_latest("BRK.A")
Error: The ticker name, BRK.A, is invalid or data is currently not available. Check ticker validity with is_supported_ticker().
Tiingo msg) <h1>Not Found</h1><p>The requested URL /iex/BRK.A/prices was not found on this server.</p>

Which is still somewhat frustrating because:

> is_supported_ticker("BRK.A", "iex")
[1] TRUE

IEX supported tickers data come from:
https://iextrading.com/api/mobile/refdata

@tiingo
Copy link

tiingo commented Apr 16, 2018

@DavisVaughan We are able to return a JSON error message on a 404 with a ticker with a ".".

For "is_supported_ticker" would you be open to querying a Tiingo endpoint to see if the ticker is available?

Holding off pushing the API change for the 404 error depending on your answer to is_supported_ticker

@DavisVaughan
Copy link
Collaborator

@tiingo Yea that'd be great

@tiingo
Copy link

tiingo commented Apr 17, 2018

You should now see a consistent error message if the ticker contains a "."

E.g. https://api.tiingo.com/tiingo/daily/brk.a/prices?startDate=2017-1-1

Additionally, you can use the meta endpoint to see if a ticker exists, which is simply:
https://api.tiingo.com/tiingo/daily/brk.a

Let me know if this works @DavisVaughan

Thanks all

@eddelbuettel
Copy link
Author

But ... BRK.A is a valid symbol and known / traded on IEX rfom what I can tell.

@tiingo
Copy link

tiingo commented Apr 17, 2018

@eddelbuettel We use "-" instead of "."

e.g. https://api.tiingo.com/tiingo/daily/brk-b/prices?startDate=2017-1-1
or
https://api.tiingo.com/iex/brk-b/prices?startDate=2018-04-16&resampleFreq=5min

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

3 participants