Skip to content

Commit

Permalink
fix: use correct previousClose price (#65)
Browse files Browse the repository at this point in the history
for some reason the `previousClose` in the `fast_info` dict is slightly
incorrect, but the one in the `info` dict is good
  • Loading branch information
loiccoyle committed Nov 12, 2024
1 parent 1f76e46 commit dfbfde7
Show file tree
Hide file tree
Showing 25 changed files with 6 additions and 2 deletions.
Binary file modified tests/data/layouts/big_logo_False_False_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_logo_False_False_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_logo_False_True_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_logo_False_True_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_logo_True_False_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_logo_True_False_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_logo_True_True_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_logo_True_True_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_False_False_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_False_False_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_False_True_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_False_True_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_True_False_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_True_False_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_True_True_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/big_price_True_True_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_False_False_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_False_False_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_False_True_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_False_True_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_True_False_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_True_False_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_True_True_False.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/layouts/default_True_True_True.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions tinyticker/layouts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Optional, Tuple

import matplotlib.pyplot as plt
from yfinance.scrapers.quote import Quote
import mplfinance as mpf
import numpy as np
from matplotlib.axes import Axes
Expand Down Expand Up @@ -207,8 +208,11 @@ def historical_plot(

def perc_change(ticker: TickerBase, resp: TickerResponse) -> float:
if isinstance(ticker, TickerStock):
ticker._yf_ticker._fast_info = None
perc_change_start = ticker._yf_ticker.fast_info["previous_close"]
# reset the quote object to avoid yfinance's caching
ticker._yf_ticker._quote = Quote(
ticker._yf_ticker._data, ticker._yf_ticker.ticker
)
perc_change_start = ticker._yf_ticker.get_info()["previousClose"]
else:
perc_change_start = resp.historical.iloc[0]["Open"]
return 100 * (resp.current_price - perc_change_start) / perc_change_start
Expand Down

0 comments on commit dfbfde7

Please sign in to comment.