<jupyter_start><jupyter_text><jupyter_code>import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt
import datetime
import pandas_datareader.data as web
start = datetime.datetime(2020, 2, 1) 
end = datetime.datetime(2021, 2, 1) 
ultratech_df = web.DataReader(['LTC-BTC'], 'yahoo', start = start, end = end)['Close']
ultratech_df.columns = {'Close Price'}
ultratech_df.head()
ultratech_df["Close Price"].plot(figsize = (15, 8))
plt.grid()
plt.show()
ultratech_df["1_SMA"] = ultratech_df["Close Price"].rolling(window = 1, min_periods = 1).mean()
ultratech_df["5_SMA"] = ultratech_df["Close Price"].rolling(window = 5, min_periods = 1).mean()
ultratech_df['Signal'] = 0.0
ultratech_df['Signal'] = np.where(ultratech_df['1_SMA'] > ultratech_df['5_SMA'], 1.0, 0.0)
ultratech_df.head()
ultratech_df["Position"] = ultratech_df["Signal"].diff()

ultratech_df.head()
plt.figure(figsize = (20,10))


ultratech_df["Close Price"].plot(color = "black", label= "Цены закрытия") 
ultratech_df["5_SMA"].plot(color = "orange",label = "Пятидневная скользящая средняя") 


plt.plot(ultratech_df[ultratech_df["Position"] == 1].index, 
         ultratech_df["1_SMA"][ultratech_df["Position"] == 1], 
         "^", markersize = 15, color = "g", label = 'Купить')


plt.plot(ultratech_df[ultratech_df["Position"] == -1].index, 
         ultratech_df["5_SMA"][ultratech_df["Position"] == -1], 
         "v", markersize = 15, color = "r", label = 'Продать')

plt.title('LTC-BTC', fontsize = 20)
plt.legend()
plt.grid()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18193548387096775, 'fraction_numerical': 0.02967741935483871, 'mean_word_length': 5.802631578947368, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '128478', 'license': 'MIT', 'n_tokens_mistral': 691, 'n_tokens_neox': 615, 'n_words': 106, 'path': 'SMATrading.ipynb', 'repo_name': 'ikarteeva/SMATrading', 'size': '1550'}