<jupyter_start><jupyter_text>!pip install quandl<jupyter_code># importing libraries
import quandl as qd
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
#qd.ApiConfig.api_key = ''
import numpy as np
dataset = qd.get("BITSTAMP/USD").to_csv('Bitcoin.csv') #importing bitcoin dataframe from quandl and saving it to csv file for later use
df = pd.read_csv('Bitcoin.csv',parse_dates=True,index_col=0) #The dataes were previously prased but to increase usibility param are given
df.rename(columns = {'Last':'Close'},inplace=True)
df.head()
short = int(input('Enter the short window size '))
long = int(input('Enter the long window size '))
signals = pd.DataFrame(index=df.index)
signals['signal'] = 0.0
signals['short_mavg'] = df['Close'].rolling(window=short, min_periods=1, center=False).mean()
signals['long_mavg'] = df['Close'].rolling(window=long, min_periods=1, center=False).mean()
signals['signal'][short:] = np.where(signals['short_mavg'][short:]
> signals['long_mavg'][short:], 1.0, 0.0) 
signals['positions'] = signals['signal'].diff()
fig = plt.figure()
ax1 = fig.add_subplot(111, ylabel='Price in $')
df['Close'].plot(ax=ax1, lw=2.)
signals[['short_mavg', 'long_mavg']].plot(ax=ax1, lw=2.)
ax1.plot(signals.loc[signals.positions == 1.0].index,
signals.short_mavg[signals.positions == 1.0],
'^', markersize=10, color='m') 
ax1.plot(signals.loc[signals.positions == -1.0].index,
signals.short_mavg[signals.positions == -1.0],
'v', markersize=10, color='#FF0023')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1760104302477184, 'fraction_numerical': 0.022816166883963495, 'mean_word_length': 7.208556149732621, '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': '276002', 'license': 'MIT', 'n_tokens_mistral': 587, 'n_tokens_neox': 563, 'n_words': 114, 'path': 'SMA_Crossover/SMA_Crossover.ipynb', 'repo_name': 'ashneg/FinTech-python-', 'size': '1534'}