Change funds load from investpy to investiny to fix 403 error (#2771)

* Change investpy load lto  investiny workaround

* add investiny
This commit is contained in:
James Maslek
2022-10-10 18:37:39 -04:00
committed by GitHub
parent 4f189db935
commit 119fb1e82c
5 changed files with 217 additions and 1136 deletions

View File

@@ -6,6 +6,7 @@ from datetime import datetime, timedelta
from typing import Tuple
import investpy
import investiny
import pandas as pd
from openbb_terminal.decorators import log_start_end
@@ -184,15 +185,28 @@ def get_fund_historical(
from_date = start_date.strftime("%d/%m/%Y")
to_date = end_date.strftime("%d/%m/%Y")
search_country = matching_country if matching_country else country
# Using investiny to get around the 403 error with investment.com api
# We need to get an ID number
id_number = int(investiny.search_assets(name, limit=1)[0]["ticker"])
try:
return (
investpy.funds.get_fund_historical_data(
fund_name, search_country, from_date=from_date, to_date=to_date
),
fund_name,
fund_symbol,
matching_country,
)
# return (
# investpy.funds.get_fund_historical_data(
# fund_name, search_country, from_date=from_date, to_date=to_date
# ),
# fund_name,
# fund_symbol,
# matching_country,
# )
df = pd.DataFrame.from_dict(
investiny.historical_data(id_number, from_date=from_date, to_date=to_date)
).set_index("date")
df.columns = [col.title() for col in df.columns]
df.index = pd.to_datetime(df.index)
return (df, fund_name, fund_symbol, matching_country)
except RuntimeError as e:
console.print("[red]Error connecting to the data source.[/red]\n")
logger.exception(str(e))

1302
poetry.lock generated vendored

File diff suppressed because it is too large Load Diff

1
pyproject.toml vendored
View File

@@ -100,6 +100,7 @@ watchdog = "^2.1.9"
pythclient = "^0.1.2"
ipyflex = "^0.2.4"
"ruamel.yaml" = "^0.17.21"
investiny = "^0.5.0"
[tool.poetry.dev-dependencies]
pytest = "^6.2.2"

10
requirements-full.txt vendored
View File

@@ -4,7 +4,7 @@ aiosignal==1.2.0; python_version >= "3.6" and python_full_version >= "3.7.0"
alabaster==0.7.12; python_version >= "3.6"
alpha-vantage==2.3.1
altair==4.2.0; python_version >= "3.7" and python_full_version < "3.9.7" or python_full_version > "3.9.7" and python_version >= "3.7"
anyio==3.6.1; python_full_version >= "3.6.2" and python_version >= "3.7"
anyio==3.6.1; python_full_version >= "3.6.2" and python_version >= "3.8" and python_version < "4.0"
appnope==0.1.3; platform_system == "Darwin" and python_version >= "3.8" and python_full_version >= "3.7.0" and python_full_version < "4.0.0" and sys_platform == "darwin"
arch==5.3.1; python_version >= "3.7"
argon2-cffi-bindings==21.2.0; python_version >= "3.7"
@@ -86,10 +86,12 @@ future==0.18.2; python_version >= "2.7" and python_full_version < "3.0.0" or pyt
gitdb==4.0.9; python_version >= "3.7" and python_full_version < "3.9.7" or python_full_version > "3.9.7" and python_version >= "3.7"
gitpython==3.1.28; python_version >= "3.7"
grpcio==1.49.1; python_full_version >= "3.7.1" and python_full_version < "4.0.0" and python_version >= "3.7"
h11==0.14.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.7.0"
h11==0.12.0; python_version >= "3.8" and python_version < "4.0" and python_full_version >= "3.7.0"
hijri-converter==2.2.4; python_version >= "3.7"
holidays==0.14.2; python_version >= "3.7"
html5lib==1.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
httpcore==0.15.0; python_version >= "3.8" and python_version < "4.0"
httpx==0.23.0; python_version >= "3.8" and python_version < "4.0"
identify==2.5.6; python_version >= "3.7"
idna==3.4; python_version >= "3.8" and python_version < "4" and python_full_version >= "3.7.1" and python_full_version < "4.0.0" and (python_version >= "3.7" and python_full_version < "3.9.7" or python_full_version > "3.9.7")
imagesize==1.4.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
@@ -97,6 +99,7 @@ importlib-metadata==5.0.0; python_version >= "3.7" and python_full_version < "3.
inflection==0.5.1; python_version >= "3.6"
iniconfig==1.1.1; python_full_version >= "3.7.0" and python_full_version < "4.0.0" and python_version >= "3.7"
interface-meta==1.3.0; python_version >= "3.8" and python_version < "4.0" and python_full_version >= "3.7.1" and python_full_version < "4.0.0"
investiny==0.5.0; python_version >= "3.8" and python_version < "4.0"
investpy==1.0.8; python_version >= "3.7"
ipyflex==0.2.4; python_version >= "3.6"
ipykernel==6.16.0; python_full_version >= "3.7.0" and python_full_version < "4.0.0" and python_version >= "3.7"
@@ -240,6 +243,7 @@ regex==2022.3.2; python_version >= "3.6"
reportlab==3.6.11; python_version >= "3.7" and python_version < "4"
requests-oauthlib==1.3.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
requests==2.28.1; python_version >= "3.7" and python_version < "4"
rfc3986==1.5.0; python_version >= "3.8" and python_version < "4.0"
rich==12.6.0; python_full_version >= "3.6.3" and python_full_version < "4.0.0"
riskfolio-lib==3.3.0; python_version >= "3.7"
robin-stocks==2.1.0; python_version >= "3"
@@ -258,7 +262,7 @@ setuptools-scm==6.4.2; python_version >= "3.8"
sgmllib3k==1.0.0; python_version >= "3.6"
six==1.16.0; python_full_version >= "3.7.1" and python_version >= "3.8" and python_version < "3.11" and python_full_version < "4.0.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version < "3.9.7" and python_full_version >= "3.3.0" or python_full_version > "3.9.7") and (python_version >= "3.8" and python_full_version < "3.9.7" or python_full_version > "3.9.7" and python_version >= "3.8") and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7") and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0") and (python_version >= "3.7" and python_full_version < "3.9.7" and python_full_version >= "3.7.0" or python_full_version > "3.9.7" and python_version >= "3.7" and python_full_version < "4.0.0")
smmap==5.0.0; python_version >= "3.7"
sniffio==1.3.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.6.2"
sniffio==1.3.0; python_version >= "3.8" and python_version < "4.0" and python_full_version >= "3.6.2"
snowballstemmer==2.2.0; python_version >= "3.6"
socketio-client-nexus==0.7.6
sortedcontainers==2.4.0; python_version >= "3.7" and python_version < "4.0"

10
requirements.txt vendored
View File

@@ -3,7 +3,7 @@ aiohttp==3.8.3; python_version >= "3.6" and python_full_version >= "3.7.0"
aiosignal==1.2.0; python_version >= "3.6" and python_full_version >= "3.7.0"
alpha-vantage==2.3.1
altair==4.2.0; python_version >= "3.7" and python_full_version < "3.9.7" or python_full_version > "3.9.7" and python_version >= "3.7"
anyio==3.6.1; python_full_version >= "3.6.2" and python_version >= "3.7"
anyio==3.6.1; python_full_version >= "3.6.2" and python_version >= "3.8" and python_version < "4.0"
appnope==0.1.3; platform_system == "Darwin" and python_version >= "3.8" and sys_platform == "darwin"
arch==5.3.1; python_version >= "3.7"
argon2-cffi-bindings==21.2.0; python_version >= "3.7"
@@ -75,14 +75,17 @@ future==0.18.2; python_version >= "2.7" and python_full_version < "3.0.0" or pyt
gitdb==4.0.9; python_version >= "3.7" and python_full_version < "3.9.7" or python_full_version > "3.9.7" and python_version >= "3.7"
gitpython==3.1.28; python_version >= "3.7"
grpcio==1.49.1; python_full_version >= "3.7.1" and python_full_version < "4.0.0" and python_version >= "3.7"
h11==0.14.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.7.0"
h11==0.12.0; python_version >= "3.8" and python_version < "4.0" and python_full_version >= "3.7.0"
hijri-converter==2.2.4; python_version >= "3.7"
holidays==0.14.2; python_version >= "3.7"
html5lib==1.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
httpcore==0.15.0; python_version >= "3.8" and python_version < "4.0"
httpx==0.23.0; python_version >= "3.8" and python_version < "4.0"
idna==3.4; python_version >= "3.8" and python_version < "4" and python_full_version >= "3.7.1" and python_full_version < "4.0.0" and (python_version >= "3.7" and python_full_version < "3.9.7" or python_full_version > "3.9.7")
importlib-metadata==5.0.0; python_version >= "3.7" and python_full_version < "3.9.7" and python_version < "3.10" or python_full_version > "3.9.7" and python_version >= "3.7" and python_version < "3.10"
inflection==0.5.1; python_version >= "3.6"
interface-meta==1.3.0; python_version >= "3.8" and python_version < "4.0" and python_full_version >= "3.7.1" and python_full_version < "4.0.0"
investiny==0.5.0; python_version >= "3.8" and python_version < "4.0"
investpy==1.0.8; python_version >= "3.7"
ipyflex==0.2.4; python_version >= "3.6"
ipykernel==6.16.0; python_version >= "3.7"
@@ -208,6 +211,7 @@ regex==2022.3.2; python_version >= "3.6"
reportlab==3.6.11; python_version >= "3.7" and python_version < "4"
requests-oauthlib==1.3.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
requests==2.28.1; python_version >= "3.7" and python_version < "4"
rfc3986==1.5.0; python_version >= "3.8" and python_version < "4.0"
rich==12.6.0; python_full_version >= "3.6.3" and python_full_version < "4.0.0"
riskfolio-lib==3.3.0; python_version >= "3.7"
robin-stocks==2.1.0; python_version >= "3"
@@ -226,7 +230,7 @@ setuptools-scm==6.4.2; python_version >= "3.8"
sgmllib3k==1.0.0; python_version >= "3.6"
six==1.16.0; python_full_version >= "3.7.1" and python_version >= "3.8" and python_version < "3.11" and python_full_version < "4.0.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version < "3.9.7" and python_full_version >= "3.3.0" or python_full_version > "3.9.7") and (python_version >= "3.8" and python_full_version < "3.9.7" or python_full_version > "3.9.7" and python_version >= "3.8") and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7") and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0") and (python_version >= "3.7" and python_full_version < "3.9.7" and python_full_version >= "3.7.0" or python_full_version > "3.9.7" and python_version >= "3.7") and (python_version >= "3.8" and python_full_version < "3.0.0" or python_version >= "3.8" and python_full_version >= "3.3.0")
smmap==5.0.0; python_version >= "3.7"
sniffio==1.3.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.6.2"
sniffio==1.3.0; python_version >= "3.8" and python_version < "4.0" and python_full_version >= "3.6.2"
socketio-client-nexus==0.7.6
sortedcontainers==2.4.0; python_version >= "3.7" and python_version < "4.0"
soupsieve==2.3.2.post1; python_version >= "3.6" and python_full_version >= "3.6.0"