business-science/alphavantager

Technical indicator values are being rounded to nearest integer.

mgiglia opened this issue · 2 comments

Using the av_get function, it appears that the values are being rounded:

av_get( symbol = "IBM" ,av_fun = "SMA" ,time_period = 10 ,interval = "weekly" ,series_type = "open" )

Returns:

# A tibble: 1,110 x 2
time sma

1 2021-04-12 16:00:01 126.
2 2021-04-09 00:00:00 125.
3 2021-04-01 00:00:00 123.
4 2021-03-26 00:00:00 122.
5 2021-03-19 00:00:00 122.
6 2021-03-12 00:00:00 122.
7 2021-03-05 00:00:00 122.
8 2021-02-26 00:00:00 122.
9 2021-02-19 00:00:00 122.
10 2021-02-12 00:00:00 123.
# … with 1,100 more rows

However the example JSON (https://www.alphavantage.co/query?function=SMA&symbol=IBM&interval=weekly&time_period=10&series_type=open&apikey=demo) looks like this:

{
"Meta Data": {
"1: Symbol": "IBM",
"2: Indicator": "Simple Moving Average (SMA)",
"3: Last Refreshed": "2021-04-12 16:00:01",
"4: Interval": "weekly",
"5: Time Period": 10,
"6: Series Type": "open",
"7: Time Zone": "US/Eastern"
},
"Technical Analysis: SMA": {
"2021-04-12 16:00:01": {
"SMA": "126.3905"
},
"2021-04-09": {
"SMA": "124.7205"
},
"2021-04-01": {
"SMA": "123.0763"
},
.....

Notice that the values returned by av_get are rounded and the original data is not. Is this something that could be fixed easily in the av_get function?

Thanks in advance, the package is great!

I believe that the values are not rounded but rather you're seeing how the data frame (tibble) is being printed to the screen. Try using the View() function and the data should appear differently.

Thanks for the quick reply @mdancho84. You're correct-- piping it into a View shows that the 4 significant digits are there. I'll check the tibble view options. Thanks again!