SlideShare a Scribd company logo
Bitcoin Price Analysis (2014 - 2023)
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.graph_objects as go
data = pd.read_csv('BTC-USD.csv')
Price by Date Graph
fig, ax = plt.subplots(figsize=(20, 8))
ax.plot(data['Date'], data['Close'], color='green')
ax.xaxis.set_major_locator(plt.MaxNLocator(15))
ax.set_xlabel('Date', fontsize=14)
ax.set_ylabel('Price in USD', fontsize=14)
plt.title('Bitcoin Prices', fontsize=18)
plt.grid()
plt.show()
Bitcoin Volume Trend
fig, ax = plt.subplots(figsize=(20, 8))
ax.plot(data['Date'], data['Volume'])
ax.xaxis.set_major_locator(plt.MaxNLocator(15))
ax.set_xlabel('Date', fontsize=14)
ax.set_ylabel('Volumes', fontsize=14)
plt.title('Bitcoin Volume Trends', fontsize=18)
plt.grid()
plt.show()
Finding Market cap
data['Market Cap'] = data['Open'] * data['Volume']
print(data['Market Cap'])
Market cap by Date graph
fig, ax = plt.subplots(figsize=(20, 8))
ax.plot(data['Date'], data['Market Cap'], color='Orange')
ax.xaxis.set_major_locator(plt.MaxNLocator(15))
ax.set_xlabel('Date', fontsize=14)
ax.set_ylabel('Market Cap', fontsize=14)
plt.title('Market Cap', fontsize=18)
plt.grid()
plt.show()
Calculating Volatility
data['vol'] = (data['Close'] / data['Close'].shift(1)) - 1
print(data['vol'])
fig, ax = plt.subplots(figsize=(20, 8))
ax.plot(data['Date'], data['vol'], color='purple')
ax.xaxis.set_major_locator(plt.MaxNLocator(15))
plt.title('Volatility', fontsize=14)
plt.grid()
plt.show()
Cumulative Return Calculation
data['Cumulative Return'] = (1 + data['vol']).cumprod()
print(data['Cumulative Return'])
fig, ax = plt.subplots(figsize=(20, 8))
ax.bar(data['Date'], data['Cumulative Return'], color='Brown')
ax.xaxis.set_major_locator(plt.MaxNLocator(15))
ax.set_xlabel('Date', fontsize=14)
ax.set_ylabel('Cumulative Return', fontsize=14)
plt.title('Cumulative Return', fontsize=14)
plt.grid()
plt.show()
Calculating Moving Averages
data['MA for 10 days'] = data['Open'].rolling(10).mean()
data['MA for 20 days'] = data['Open'].rolling(20).mean()
data['MA for 50 days'] = data['Open'].rolling(50).mean()
data['MA for 100 days'] = data['Open'].rolling(100).mean()
truncated_data = data.truncate()
truncated_data[['Adj Close', 'MA for 10 days', 'MA for 20 days', 'MA
for 50 days', 'MA for 100 days']].plot(subplots=False, figsize=(12, 5))
plt.title('Bitcoin Stock: Adjusted Close Price and Moving Averages')
plt.xlabel('Date')
plt.ylabel('Price')
plt.show()
Daily Price Change
data = data.sort_values(by='Date')
data['Daily_Price_Change'] = data['Close'].diff()
print(data)
fig1, ax = plt.subplots(figsize=(20, 6))
ax.plot(data['Date'], data['Daily_Price_Change'], color='b',
label='Daily Price Change')
ax.xaxis.set_major_locator(plt.MaxNLocator(15))
plt.xlabel('Date')
plt.ylabel('Daily Price Change')
plt.title('Daily Price Change of Bitcoin', fontsize=14)
plt.grid()
plt.show()
Candlestick Chart
data['Date'] = pd.to_datetime(data['Date'])
data = data.sort_values(by='Date')
fig = go.Figure(data=[go.Candlestick(x=data['Date'],
open=data['Open'],
high=data['High'],
low=data['Low'],
close=data['Close'])])
fig.update_layout(title='Bitcoin Candlestick Chart',
xaxis_title='Date',
yaxis_title='Price')
fig.show()
Relative Strength Index of Bitcoin
data['Date'] = pd.to_datetime(data['Date'])
data = data.sort_values(by='Date')
data['Daily_Price_Change'] = data['Close'].diff()
def calculate_rsi(data, window=14):
delta = data['Daily_Price_Change']
gain = delta.where(delta > 0, 0)
loss = -delta.where(delta < 0, 0)
avg_gain = gain.rolling(window=window, min_periods=1).mean()
avg_loss = loss.rolling(window=window, min_periods=1).mean()
relative_strength = avg_gain / avg_loss
rsi = 100 - (100 / (1 + relative_strength))
return rsi
data['RSI'] = calculate_rsi(data)
fig, ax = plt.subplots(figsize=(20, 8))
ax.plot(data['Date'], data['RSI'], color='b', label='RSI')
ax.axhline(y=70, color='r', linestyle='--', label='Overbought (70)')
ax.axhline(y=30, color='g', linestyle='--', label='Oversold (30)')
ax.set_xlabel('Date', fontsize=14)
ax.set_ylabel('RSI', fontsize=14)
plt.title('Relative Strength Index (RSI) of Bitcoin', fontsize=18)
plt.grid()
plt.show()

More Related Content

Similar to Bitcoin Price Analysis (2014 - 2023).pdf

bbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docx
bbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docxbbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docx
bbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docx
ikirkton
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
Paras Intotech
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
Yoshiki Satotani
 
Kotlin Mullets
Kotlin MulletsKotlin Mullets
Kotlin Mullets
James Ward
 
The Web map stack on Django
The Web map stack on DjangoThe Web map stack on Django
The Web map stack on Django
Paul Smith
 
Pycon2011
Pycon2011Pycon2011
Pycon2011
Django Stars
 
Data visualization in python/Django
Data visualization in python/DjangoData visualization in python/Django
Data visualization in python/Django
kenluck2001
 
What is wrong with this code def plotCountryDensitiesdata.pdf
What is wrong with this code def plotCountryDensitiesdata.pdfWhat is wrong with this code def plotCountryDensitiesdata.pdf
What is wrong with this code def plotCountryDensitiesdata.pdf
accumencomp
 
Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams
Seiya Mizuno
 
Interactive financial analytics with vix(cboe)
Interactive financial analytics with vix(cboe)Interactive financial analytics with vix(cboe)
Interactive financial analytics with vix(cboe)
Aiden Wu, FRM
 
Youth Tobacco Survey Analysis
Youth Tobacco Survey AnalysisYouth Tobacco Survey Analysis
Youth Tobacco Survey Analysis
Roshik Ganesan
 
12-IP.pdf
12-IP.pdf12-IP.pdf
12-IP.pdf
kajalkhorwal106
 

Similar to Bitcoin Price Analysis (2014 - 2023).pdf (12)

bbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docx
bbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docxbbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docx
bbyopenApp_Code.DS_StorebbyopenApp_CodeVBCodeGoogleMaps.docx
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
Kotlin Mullets
Kotlin MulletsKotlin Mullets
Kotlin Mullets
 
The Web map stack on Django
The Web map stack on DjangoThe Web map stack on Django
The Web map stack on Django
 
Pycon2011
Pycon2011Pycon2011
Pycon2011
 
Data visualization in python/Django
Data visualization in python/DjangoData visualization in python/Django
Data visualization in python/Django
 
What is wrong with this code def plotCountryDensitiesdata.pdf
What is wrong with this code def plotCountryDensitiesdata.pdfWhat is wrong with this code def plotCountryDensitiesdata.pdf
What is wrong with this code def plotCountryDensitiesdata.pdf
 
Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams
 
Interactive financial analytics with vix(cboe)
Interactive financial analytics with vix(cboe)Interactive financial analytics with vix(cboe)
Interactive financial analytics with vix(cboe)
 
Youth Tobacco Survey Analysis
Youth Tobacco Survey AnalysisYouth Tobacco Survey Analysis
Youth Tobacco Survey Analysis
 
12-IP.pdf
12-IP.pdf12-IP.pdf
12-IP.pdf
 

Recently uploaded

DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
SaffaIbrahim1
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
dataschool1
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
agdhot
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
ywqeos
 
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
mkkikqvo
 
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
oaxefes
 
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
asyed10
 
Module 1 ppt BIG DATA ANALYTICS NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS NOTES FOR MCAModule 1 ppt BIG DATA ANALYTICS NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS NOTES FOR MCA
yuvarajkumar334
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
Márton Kodok
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
ytypuem
 
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
actyx
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
uevausa
 
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
hqfek
 
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
slg6lamcq
 
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
nyvan3
 
一比一原版(UofT毕业证)多伦多大学毕业证如何办理
一比一原版(UofT毕业证)多伦多大学毕业证如何办理一比一原版(UofT毕业证)多伦多大学毕业证如何办理
一比一原版(UofT毕业证)多伦多大学毕业证如何办理
exukyp
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
Vineet
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
MastanaihnaiduYasam
 

Recently uploaded (20)

DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
 
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
 
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
 
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
 
Module 1 ppt BIG DATA ANALYTICS NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS NOTES FOR MCAModule 1 ppt BIG DATA ANALYTICS NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS NOTES FOR MCA
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
 
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
 
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
 
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
 
一比一原版(UofT毕业证)多伦多大学毕业证如何办理
一比一原版(UofT毕业证)多伦多大学毕业证如何办理一比一原版(UofT毕业证)多伦多大学毕业证如何办理
一比一原版(UofT毕业证)多伦多大学毕业证如何办理
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
 

Bitcoin Price Analysis (2014 - 2023).pdf

  • 1. Bitcoin Price Analysis (2014 - 2023) import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import plotly.graph_objects as go data = pd.read_csv('BTC-USD.csv') Price by Date Graph fig, ax = plt.subplots(figsize=(20, 8)) ax.plot(data['Date'], data['Close'], color='green') ax.xaxis.set_major_locator(plt.MaxNLocator(15)) ax.set_xlabel('Date', fontsize=14) ax.set_ylabel('Price in USD', fontsize=14) plt.title('Bitcoin Prices', fontsize=18) plt.grid() plt.show()
  • 2. Bitcoin Volume Trend fig, ax = plt.subplots(figsize=(20, 8)) ax.plot(data['Date'], data['Volume']) ax.xaxis.set_major_locator(plt.MaxNLocator(15)) ax.set_xlabel('Date', fontsize=14) ax.set_ylabel('Volumes', fontsize=14) plt.title('Bitcoin Volume Trends', fontsize=18) plt.grid() plt.show() Finding Market cap data['Market Cap'] = data['Open'] * data['Volume'] print(data['Market Cap'])
  • 3. Market cap by Date graph fig, ax = plt.subplots(figsize=(20, 8)) ax.plot(data['Date'], data['Market Cap'], color='Orange') ax.xaxis.set_major_locator(plt.MaxNLocator(15)) ax.set_xlabel('Date', fontsize=14) ax.set_ylabel('Market Cap', fontsize=14) plt.title('Market Cap', fontsize=18) plt.grid() plt.show() Calculating Volatility data['vol'] = (data['Close'] / data['Close'].shift(1)) - 1 print(data['vol']) fig, ax = plt.subplots(figsize=(20, 8)) ax.plot(data['Date'], data['vol'], color='purple') ax.xaxis.set_major_locator(plt.MaxNLocator(15)) plt.title('Volatility', fontsize=14) plt.grid() plt.show()
  • 4. Cumulative Return Calculation data['Cumulative Return'] = (1 + data['vol']).cumprod() print(data['Cumulative Return']) fig, ax = plt.subplots(figsize=(20, 8)) ax.bar(data['Date'], data['Cumulative Return'], color='Brown') ax.xaxis.set_major_locator(plt.MaxNLocator(15)) ax.set_xlabel('Date', fontsize=14) ax.set_ylabel('Cumulative Return', fontsize=14) plt.title('Cumulative Return', fontsize=14) plt.grid() plt.show()
  • 5. Calculating Moving Averages data['MA for 10 days'] = data['Open'].rolling(10).mean() data['MA for 20 days'] = data['Open'].rolling(20).mean() data['MA for 50 days'] = data['Open'].rolling(50).mean() data['MA for 100 days'] = data['Open'].rolling(100).mean() truncated_data = data.truncate() truncated_data[['Adj Close', 'MA for 10 days', 'MA for 20 days', 'MA for 50 days', 'MA for 100 days']].plot(subplots=False, figsize=(12, 5)) plt.title('Bitcoin Stock: Adjusted Close Price and Moving Averages') plt.xlabel('Date') plt.ylabel('Price') plt.show()
  • 6. Daily Price Change data = data.sort_values(by='Date') data['Daily_Price_Change'] = data['Close'].diff() print(data) fig1, ax = plt.subplots(figsize=(20, 6)) ax.plot(data['Date'], data['Daily_Price_Change'], color='b', label='Daily Price Change') ax.xaxis.set_major_locator(plt.MaxNLocator(15)) plt.xlabel('Date') plt.ylabel('Daily Price Change') plt.title('Daily Price Change of Bitcoin', fontsize=14) plt.grid() plt.show()
  • 7. Candlestick Chart data['Date'] = pd.to_datetime(data['Date']) data = data.sort_values(by='Date') fig = go.Figure(data=[go.Candlestick(x=data['Date'], open=data['Open'], high=data['High'], low=data['Low'], close=data['Close'])]) fig.update_layout(title='Bitcoin Candlestick Chart', xaxis_title='Date', yaxis_title='Price') fig.show() Relative Strength Index of Bitcoin data['Date'] = pd.to_datetime(data['Date']) data = data.sort_values(by='Date') data['Daily_Price_Change'] = data['Close'].diff() def calculate_rsi(data, window=14): delta = data['Daily_Price_Change'] gain = delta.where(delta > 0, 0) loss = -delta.where(delta < 0, 0)
  • 8. avg_gain = gain.rolling(window=window, min_periods=1).mean() avg_loss = loss.rolling(window=window, min_periods=1).mean() relative_strength = avg_gain / avg_loss rsi = 100 - (100 / (1 + relative_strength)) return rsi data['RSI'] = calculate_rsi(data) fig, ax = plt.subplots(figsize=(20, 8)) ax.plot(data['Date'], data['RSI'], color='b', label='RSI') ax.axhline(y=70, color='r', linestyle='--', label='Overbought (70)') ax.axhline(y=30, color='g', linestyle='--', label='Oversold (30)') ax.set_xlabel('Date', fontsize=14) ax.set_ylabel('RSI', fontsize=14) plt.title('Relative Strength Index (RSI) of Bitcoin', fontsize=18) plt.grid() plt.show()