Fixes integrated tests for alt and economy (#2655)

* Fixes integrated tests for alt and economy

* Added fixes

* Added fixes
This commit is contained in:
Colin Delahunty
2022-09-28 17:18:55 +02:00
committed by GitHub
parent 446a29ec91
commit 6c0942898c
3 changed files with 22 additions and 6 deletions

View File

@@ -111,7 +111,8 @@ def get_startups() -> pd.DataFrame:
pandas.DataFrame:
list of startups
"""
soup = _make_request("https://runacap.com/ross-index/")
response = requests.get("https://runacap.com/ross-index/", timeout=10)
soup = BeautifulSoup(response.content, "html.parser")
startups = []
if soup:
table = soup.find("table", {"id": "table_1"})

View File

@@ -561,7 +561,11 @@ def get_macro_data(
return pd.Series(dtype=float), ""
if start_date or end_date:
df = df.loc[start_date:end_date]
try:
df = df.loc[start_date:end_date]
except TypeError:
console.print("[red]Invalid date sent. Format as YYYY-MM-DD[/red]\n")
return pd.DataFrame(), "NA/NA"
if (
symbol

View File

@@ -2,6 +2,8 @@
__docformat__ = "numpy"
import logging
from datetime import datetime
from typing import Optional
import pandas as pd
import yfinance as yf
@@ -590,8 +592,8 @@ INDICES = {
def get_index(
index: str,
interval: str = "1d",
start_date: int = None,
end_date: int = None,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
column: str = "Adj Close",
) -> pd.Series:
"""Obtain data on any index [Source: Yahoo Finance]
@@ -600,9 +602,9 @@ def get_index(
----------
index: str
The index you wish to collect data for.
start_date : str
start_date : Optional[str]
the selected country
end_date : bool
end_date : Optional[str]
The currency you wish to convert the data to.
interval : str
Valid intervals: 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo or 3mo
@@ -620,6 +622,15 @@ def get_index(
else:
ticker = index
try:
if start_date:
datetime.strptime(str(start_date), "%Y-%m-%d")
if end_date:
datetime.strptime(str(end_date), "%Y-%m-%d")
except ValueError:
console.print("[red]Please format date as YYYY-MM-DD[/red]\n")
return pd.Series(dtype="object")
index_data = yf.download(
ticker,
start=start_date,