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

Error in sts.batch_request_eod_prices() with just a date and no tickers #2

Closed
klueska opened this issue May 17, 2020 · 5 comments
Closed
Assignees

Comments

@klueska
Copy link

klueska commented May 17, 2020

The following does not seem to work:

sts.batch_request_eod_prices(date='2020-04-15')

From reading through the documentation, it appears the API does not support this type of query (though I'm not sure why it wouldn't). From the documentation it seems you can only supply a date if you also supply a list of tickers . Otherwise, you just get all of the EOD prices from the last closing date (without the ability to supply a different date).

@klueska
Copy link
Author

klueska commented May 17, 2020

To be clear, the query appears to return successfully, but the data returned does not correspond to the date specified (but rather just whatever the last closing date was).

@razorhash razorhash self-assigned this May 18, 2020
@razorhash razorhash pinned this issue May 18, 2020
@razorhash
Copy link
Owner

Hi @klueska,

A new API endpoint was created yesterday on fmpcloud to handle this request. It should work now. Could you confirm? I'll close the issue once you have.

Thanks!

@klueska
Copy link
Author

klueska commented May 19, 2020

It appears to work when I hit the endpoint directly in the browser, i.e.:

https://fmpcloud.io/api/v3/batch-request-end-of-day-prices?date=2020-04-15&apikey=<my-key>

But setting my API key and then using it via the python package still return data from the last closing date (2020-05-18 in my case).

from pyfmpcloud import settings
from pyfmpcloud import stock_time_series as sts

settings.set_apikey("<my-key>")
eod = sts.batch_request_eod_prices(date='2020-04-15')
print(eod)
$ python fmptest.py
         symbol                      date   open    low   high  close  adjClose    volume
0      2CRSI.PA 2020-05-18 00:00:00+00:00   2.67   2.67   2.77   2.78      2.78     39169
1             A 2020-05-18 00:00:00+00:00  83.24  82.29  84.39  83.66     83.66   2019421
2            AA 2020-05-18 00:00:00+00:00   7.07   7.01   7.88   7.80      7.80  12821866
3        AAA.AS 2020-05-15 00:00:00+00:00   0.06   0.06   0.06   0.06      0.06       709
4          AAAU 2020-05-18 00:00:00+00:00  17.44  17.23  17.44  17.25     17.25    552161
...         ...                       ...    ...    ...    ...    ...       ...       ...
10894     ZXZZT 2020-05-18 00:00:00+00:00  25.08  25.14  25.14  25.14     25.14     15032
10895      ZYME 2020-05-18 00:00:00+00:00  38.00  36.09  38.24  37.99     37.99    387700
10896      ZYNE 2020-05-18 00:00:00+00:00   4.20   4.11   4.91   4.89      4.89   1699483
10897      ZYXI 2020-05-18 00:00:00+00:00  22.38  19.54  22.70  20.26     20.26   1405863
10898    ZZZ.TO 2020-05-15 00:00:00+00:00  13.21  12.97  13.66  13.52     13.52     73854

[10899 rows x 8 columns]

Looks like you want the following diff:

--- .virtualenv/lib/python3.7/site-packages/pyfmpcloud/stock_time_series.py	2020-05-19 13:45:49.998451167 +0200
+++ .virtualenv/lib/python3.7/site-packages/pyfmpcloud/stock_time_series_new.py	2020-05-19 13:45:44.218254835 +0200
@@ -97,8 +97,10 @@
     """
     urlroot = settings.get_urlroot()
     apikey = settings.get_apikey()
-    if tickers is None:
+    if (tickers is None) and (date is None):
         url = urlroot + "batch-request-end-of-day-prices?apikey=" + apikey
+    elif (tickers is None) and (date is not None):
+        url = urlroot + "batch-request-end-of-day-prices?date=" + date + "&apikey=" + apikey
     elif (tickers is not None) and (date is None):
         raise Exception('For batch query of specific stocks, please specify a date in the format yyyy-mm-dd')
     elif (tickers is not None) and (date is not None):

razorhash added a commit that referenced this issue May 19, 2020
@razorhash
Copy link
Owner

Hey @klueska, I hope to have fixed this in release 1.1.5
Let me know how it works.

@klueska
Copy link
Author

klueska commented May 19, 2020

Yep. Things seem to be working now. Thanks!

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