slevin48 / stock

Predicting Stock Prices Using Machine Learning
0 stars 0 forks source link

Switch stock price provider #4

Open slevin48 opened 9 months ago

slevin48 commented 9 months ago

line 40

File "/home/adminuser/venv/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)
File "/mount/src/stock/streamlit_app.py", line 40, in <module>
    name = keyword['bestMatches'][0]['2. name']
slevin48 commented 9 months ago

Alpha Vantage standard API rate limit is 25 requests per day

slevin48 commented 9 months ago

Yahoo Finance

slevin48 commented 9 months ago

Retrieve stock by ISIN https://investpy.readthedocs.io/

import investpy

df = investpy.stocks.search_stocks(by='isin', value='US0126531013')
print(df)
#          country       name              full_name          isin currency symbol
# 0         mexico  Albemarle         Albemarle Corp  US0126531013      MXN    ALB
# 1  united states  Albemarle         Albemarle Corp  US0126531013      USD    ALB
# 2        germany  Albemarle  Albemarle Corporation  US0126531013      EUR   ALLE
from pandas_datareader import data as pdr

symbol = df.loc[df['country']=='united states','symbol'].values[0]
print(symbol) # ALB

stock = pdr.DataReader(symbol, data_source="yahoo", start="2021-01-01", end="2021-10-30")
print(stock.head())

https://stackoverflow.com/questions/70233546/python-call-pandas-datareader-with-isin-or-wkn-or-translate-this-into-ticker-sy

slevin48 commented 9 months ago

Twelve Data

slevin48 commented 9 months ago

Pandas Datareader