Skip to content

Commit

Permalink
πŸ”€ Merge pull request #50 from alvarobartt/date-patch
Browse files Browse the repository at this point in the history
πŸ› Fix issue with wrong timestamps for Bond Yields
  • Loading branch information
alvarobartt authored Oct 17, 2022
2 parents 78aa35d + 07ae077 commit 693376b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "investiny"
version = "0.7.0"
version = "0.7.1"
packages = [
{ include = "investiny", from = "src" },
]
Expand Down
2 changes: 1 addition & 1 deletion src/investiny/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""`investiny `: `investpy` but made tiny."""

__author__ = "Alvaro Bartolome, alvarobartt @ GitHub"
__version__ = "0.7.0"
__version__ = "0.7.1"

from investiny.historical import historical_data # noqa: F401
from investiny.info import info # noqa: F401
Expand Down
7 changes: 4 additions & 3 deletions src/investiny/historical.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def historical_data(
Config.time_format if interval not in ["D", "W", "M"] else Config.date_format
)

has_volume = not investing_info(investing_id=investing_id)["has_no_volume"]
info = investing_info(investing_id=investing_id)

has_volume = not info["has_no_volume"]
days_shift = 1 if info["type"] in ["Yield"] else 0

for to_datetime, from_datetime in zip(to_datetimes, from_datetimes):
params = {
Expand All @@ -55,8 +58,6 @@ def historical_data(
"resolution": interval,
}
data = request_to_investing(endpoint="history", params=params)
# Dates are shifted due to an Investing.com issue with returned timestamps
days_shift = (datetime.fromtimestamp(data["t"][0]) - from_datetime).days # type: ignore
result["date"] += [
(datetime.fromtimestamp(t) - timedelta(days=days_shift)).strftime(
datetime_format
Expand Down

0 comments on commit 693376b

Please sign in to comment.