<jupyter_start><jupyter_text>Define Constants<jupyter_code>TICKERS = ['PLUG']
START = '2019-01-01'
END = None
INTERVAL = '1d'<jupyter_output><empty_output><jupyter_text>Live Data Availability<jupyter_code>data = yfinance.download(
            tickers=TICKERS,
            start=START,
            end=END,
            interval=INTERVAL,
            auto_adjust=False,
            prepost=False
        )
data.tail()<jupyter_output><empty_output><jupyter_text>We can see that we have data even during the current date.  Download Data<jupyter_code>tickers_data_unadjusted = yfinance.download(
            tickers=TICKERS,
            start=START,
            end=END,
            interval=INTERVAL,
            auto_adjust=False,
            prepost=False
        )
tickers_data_unadjusted.head()
tickers_data = yfinance.download(
            tickers=TICKERS,
            start=START,
            end=END,
            interval=INTERVAL,
            auto_adjust=True,
            prepost=False
        )
print(len(tickers_data))
tickers_data.head()
tickers_data_with_actions = yfinance.download(
            tickers=TICKERS,
            start=START,
            end=END,
            interval=INTERVAL,
            auto_adjust=True,
            prepost=False,
            actions=True
        )
print(len(tickers_data_with_actions))
tickers_data.head(n=40)<jupyter_output>741<jupyter_text>Check Different Intervals<jupyter_code>yfinance.download(
            tickers=TICKERS,
            start=START,
            end=END,
            interval='1h',
            auto_adjust=True,
            prepost=False,
        )
yfinance.download(
            tickers=TICKERS,
            start='2019-12-07',
            end='2021-12-07',
            interval='1h',
            auto_adjust=True,
            prepost=False,
        )
one_hour_data = yfinance.download(
            tickers=TICKERS,
            start='2021-6-07',
            end='2021-12-08',
            interval='1h',
            auto_adjust=True,
            prepost=False,
        )
one_hour_data.head()
one_hour_data.tail()
yfinance.download(
            tickers=TICKERS,
            start=START,
            end=END,
            interval='1m',
            auto_adjust=True,
            prepost=False,
        )<jupyter_output>[*********************100%***********************]  1 of 1 completed

1 Failed download:
- PLUG: 1m data not available for startTime=1546293600 and endTime=1638899793. Only 7 days worth of 1m granularity data are allowed to be fetched per request.<jupyter_text>Data Continuity<jupyter_code>mpf.plot(tickers_data.loc['2020-01-01':'2020-02-01'], type='candle')<jupyter_output><empty_output><jupyter_text>We can see that there is noise between weekends or other holidays when the market is not open.  Stock Splits Continuity A stock split was made on the APPL stock on 31 August 2021. Lets see if the data is readjusted to the split.<jupyter_code>tickers_data_with_actions.loc['2020-08-20':'2020-9-10']
mpf.plot(tickers_data_with_actions.loc['2020-07-01':'2020-10-01'], type='candle')<jupyter_output><empty_output><jupyter_text>We can see that prices are adjusted to stock splits.  Log Difference<jupyter_code>tickers_data_values = tickers_data.values
tickers_data_values = np.log(tickers_data_values)
print(f'Shape: {tickers_data_values.shape}')
print(f'Min: {tickers_data_values.min()}')
print(f'Max: {tickers_data_values.max()}')
tickers_data_diff = np.diff(tickers_data_values, axis=0, prepend=tickers_data_values[0, :].reshape(1, -1))
print(f'Shape: {tickers_data_diff.shape}')
print(f'Min: {tickers_data_diff.min()}')
print(f'Max: {tickers_data_diff.max()}')
tickers_data_diff[0]
tickers_data_diff[1]
tickers_data_diff[-1]
# plot open prices
plt.plot(tickers_data_diff[:, 0])
# plot high prices
plt.plot(tickers_data_diff[:, 1])
# plot low prices
plt.plot(tickers_data_diff[:, 2])
# plot closing prices
plt.plot(tickers_data_diff[:, 3])
# plot volume 
plt.plot(tickers_data_diff[:, 4])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11930965482741371, 'fraction_numerical': 0.03576788394197099, 'mean_word_length': 3.080612244897959, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '515903', 'license': 'Apache-2.0', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1341, 'n_words': 231, 'path': 'notebooks/yfinance_data.ipynb', 'repo_name': 'IusztinPaul/yacht', 'size': '3998'}