본문 바로가기

프로그래밍

(69)
71. Finplot Candlestick PyQt에 그리기 71-1 예제: ex70 import sys import finplot as plt import pyupbit as bit from PyQt5.QtWidgets import QApplication, QGraphicsView, QVBoxLayout plt.candle_bull_color = '#FF0000' plt.candle_bull_body_color = '#FF0000' plt.candle_bear_color = '#0000FF' class MyApp(QGraphicsView): def __init__(self): super().__init__() self.initUI() def initUI(self): vbox = QVBoxLayout() self.setLayout(vbox) self.setWind..
70. Finplot 기본 챠트 그리기 finplot은 실시간 챠트 그리기에 적합한 PyQtGraph 모듈을 기반으로 구성된 파이썬 금융 챠트 라이브러리입니다. finplot 설치 pip install -U finplot 70-1 예제: ex69 import finplot as plt import FinanceDataReader as fdr plt.candle_bull_color = '#FF0000' plt.candle_bull_body_color = '#FF0000' # 빨간색 plt.candle_bear_color = '#0000FF' # 파랑색 df = fdr.DataReader("KS11", "2021") plt.candlestick_ochl(df[['Open', 'Close', 'High', 'Low']]) plt.show() 70-..
68. PyQtChart 시계열 그래프 주식 데이터는 시계열 데이터이므로 그래프의 x축은 날짜와 시간을 표시합니다. QtChart 에서 그래프의 x축을 시계열로 표현할 때 QDateTimeAxis 클래스를 사용합니다. 68-1 예제: ex67 import sys import FinanceDataReader as fdr import pyupbit as upbit from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtChart import QChart, QChartView, QLineSeries, QDateTimeAxis, QValueAxis from PyQt5.QtGui import QPainter from PyQt5.QtCore import Qt class MyApp(QMain..
67. PyQtChart 줄 그리기 PyQtChart 설치 pip install pyqtchart LineChart 그리기 67-1 예제:ex66 import sys from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtChart import QChart, QChartView, QLineSeries from PyQt5.QtGui import QPainter class MyApp(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): # data series = QLineSeries() series.append(0, 0) series.append(1, 1) series.append..
65. PyQtGraph 시계열 그래프 그리기 시계열 데이터를 그래프로 그릴 때 시간축을 표현하는 것이 중요하고 어렵습니다. pyqtgraph 0.12 버전부터 시간축을 표현하기 위한 DateAxisItem 클래스를 기본으로 제공하고 있습니다. 65-1 예제: ex64 import sys import FinanceDataReader as fdr import pyqtgraph as pg from PyQt5.QtWidgets import QApplication, QMainWindow class MyApp(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): # data 셀트리온 df = fdr.DataReader("068270") # pandas DataF..
64. PyQtGraph 그래프 두 개 그리기 64-1 예제: ex63 import sys import pyqtgraph as pg from PyQt5.QtWidgets import QApplication, QMainWindow class MyApp(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): # 데이터 x1 = [1, 2, 3, 4, 5] y1 = [10, 15, 20, 25, 30] x2 = [1, 2, 3, 4, 5] y2 = [1, 4, 9, 16, 23] plot_widget = pg.PlotWidget() self.setCentralWidget(plot_widget) # graph style plot_widget.setBackgrou..
63. PyQtGraph 기본 그래프 그리기 PyQtGraph 는 PyQt 와 Numpy 를 기반으로 만들어진 과학 그래픽 및 GUI 라이브러리입니다. Matplotlib 모듈이 정적인 그래프에 적당하다면 PyQtGraph는 실시간 챠트를 그리는데 유용합니다. PyQtGraph 설치 pip install pyqtgraph PyQtGraph 예제 python -m pyqtgraph.examples -m 옵션은 모듈을 직접 실행할 때 사용합니다. 63-1 예제: ex62 기본 그래프 출력 import sys import pyqtgraph as pg from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtWidgets import QApplication, QMainWindow class M..
62. 주가 챠트 챠트와 관련된 라이브러리 설치하기 pip install -U matplotlib pip install -U mpl_finance pip install -U mplfinance import datetime import numpy as np import FinanceDataReader as fdr import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.font_manager as fm import matplotlib.gridspec as gridspec # import mplfinance as mpf # 셀트리온, 2020년 df_068270 = fdr.DataReader("068270", "2020") df_068270 = df..