본문 바로가기
Python

[Python] Candle Stick Chart

by YJHTPII 2024. 5. 7.
반응형

 

 

https://levelup.gitconnected.com/7-fascinating-python-financial-graphs-that-will-amaze-you-b21d5f65cd1a

 

7 Fascinating Python Financial Graphs That Will Amaze You!

Introduction: Exploring the Power of Python in Financial Graphs

levelup.gitconnected.com

 

 

import plotly.graph_objects as go
import pandas as pd

# Sample data: Date, Open, High, Low, Close
data = {
    'Date': pd.date_range(start='2024-01-01', periods=5, freq='D'),
    'Open': [100, 105, 103, 108, 107],
    'High': [110, 108, 106, 112, 109],
    'Low': [95, 102, 101, 105, 106],
    'Close': [105, 107, 104, 110, 108],
}
df = pd.DataFrame(data)

# Creating the candlestick chart
fig = go.Figure(data=[go.Candlestick(x=df['Date'],
                open=df['Open'], high=df['High'],
                low=df['Low'], close=df['Close'],
                increasing_line_color='green', decreasing_line_color='red')])
fig.update_layout(title='Candlestick Chart', xaxis_title='Date', yaxis_title='Price')
fig.show()
반응형

'Python' 카테고리의 다른 글

[Python]파이썬 출력 화면 지우기  (0) 2024.05.10
[Python]PyQt Widgets  (0) 2024.05.07
Dragon Moving Banner  (0) 2024.05.07
[Errno 13] Permission denied: '/dev/ttyUSB0'  (0) 2024.05.02
[Python] How to Run 70B LLMs on a Single 4GB GPU  (0) 2024.04.25

댓글