seolpyo-mplchart 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of seolpyo-mplchart might be problematic. Click here for more details.

@@ -0,0 +1 @@
1
+ recursive-include seolpyo_mplchart/data *
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.1
2
+ Name: seolpyo-mplchart
3
+ Version: 0.0.1
4
+ Summary: Fast candlestick chart using Python. Includes navigator, slider, navigation, and text information display functions
5
+ Author-email: white-seolpyo <white-seolpyo@naver.com>
6
+ License: MIT License
7
+ Project-URL: Homepage, https://white.seolpyo.com/
8
+ Project-URL: Documentation, https://white.seolpyo.com/entry/148/
9
+ Project-URL: repository, https://github.com/white-seolpyo/seolpyo-mplchart
10
+ Project-URL: Issues, https://github.com/white-seolpyo/seolpyo-mplchart/issues
11
+ Keywords: chart,차트,stock,주식,invest,투자,finance,파이낸스,candle,캔들,candlestick,캔들스틱,matplotlib,mplfinance,pyqtgraph,finplot,virtual currency,가상화폐,coin,코인,bitcoin,비트코인,ethereum,이더리움
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Framework :: Matplotlib
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: matplotlib>=3.9.2
25
+ Requires-Dist: pandas>=2.2.2
26
+
27
+ # Donation
28
+ Bitcoin: 1MKCHW8smDZv5DFMiVkA5G3DeXcMn871ZX
29
+
30
+ Ethereum: 0x1c5fb8a5e0b1153cd4116c91736bd16fabf83520
31
+
32
+
33
+ # Document
34
+ [English](https://white.seolpyo.com/entry/148/)
35
+
36
+ [한글](https://white.seolpyo.com/entry/147/)
@@ -0,0 +1,10 @@
1
+ # Donation
2
+ Bitcoin: 1MKCHW8smDZv5DFMiVkA5G3DeXcMn871ZX
3
+
4
+ Ethereum: 0x1c5fb8a5e0b1153cd4116c91736bd16fabf83520
5
+
6
+
7
+ # Document
8
+ [English](https://white.seolpyo.com/entry/148/)
9
+
10
+ [한글](https://white.seolpyo.com/entry/147/)
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools >= 65.0",
4
+ "matplotlib >= 3.9.2",
5
+ "pandas >= 2.2.2",
6
+ ]
7
+ build-backend = "setuptools.build_meta"
8
+
9
+ [project]
10
+ name = "seolpyo-mplchart"
11
+ version = "0.0.1"
12
+ dependencies = [
13
+ "matplotlib >= 3.9.2",
14
+ "pandas >= 2.2.2",
15
+ ]
16
+ license = {text = "MIT License"}
17
+ description = "Fast candlestick chart using Python. Includes navigator, slider, navigation, and text information display functions"
18
+ readme = "README.md"
19
+ requires-python = ">= 3.11"
20
+ authors = [
21
+ {name="white-seolpyo", email="white-seolpyo@naver.com"},
22
+ ]
23
+ classifiers = [
24
+ "License :: OSI Approved :: MIT License",
25
+ "Development Status :: 5 - Production/Stable",
26
+ "Framework :: Matplotlib",
27
+ "Operating System :: Microsoft :: Windows",
28
+ "Intended Audience :: Developers",
29
+ "Programming Language :: Python",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3 :: Only",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ ]
35
+ keywords = [
36
+ "chart", "차트", "stock", "주식", "invest", "투자", "finance", "파이낸스",
37
+ "candle", "캔들", "candlestick", "캔들스틱", "matplotlib", "mplfinance",
38
+ "pyqtgraph", "finplot", "virtual currency", "가상화폐", "coin", "코인",
39
+ "bitcoin", "비트코인", "ethereum", "이더리움",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://white.seolpyo.com/"
44
+ Documentation = "https://white.seolpyo.com/entry/148/"
45
+ repository = "https://github.com/white-seolpyo/seolpyo-mplchart"
46
+ Issues = "https://github.com/white-seolpyo/seolpyo-mplchart/issues"
47
+
48
+ [tool.setuptools]
49
+ packages = [
50
+ "seolpyo_mplchart",
51
+ "seolpyo_mplchart.data",
52
+ ]
53
+
@@ -0,0 +1,49 @@
1
+ """
2
+ This software includes Matplotlib, which is licensed under the BSD License.
3
+ Matplotlib Copyright (c) 2012- Matplotlib Development Team.
4
+ Full license can be found in the LICENSE file or at https://matplotlib.org/stable/users/license.html
5
+ """
6
+
7
+
8
+ import json
9
+ from pathlib import Path
10
+ from typing import Literal
11
+
12
+ import matplotlib.pyplot as plt
13
+ import pandas as pd
14
+
15
+
16
+ from .slider import Chart
17
+
18
+
19
+ _name = {'samsung', 'apple'}
20
+ def sample(name: Literal['samsung', 'apple']='samsung'):
21
+ if name not in _name:
22
+ print('name should be either samsung or apple.')
23
+ return
24
+ file = Path(__file__).parent / f'data/{name}.txt'
25
+ with open(file, 'r', encoding='utf-8') as txt:
26
+ data = json.load(txt)
27
+ data = data
28
+ df = pd.DataFrame(data)
29
+
30
+ c = Chart()
31
+ if name == 'apple':
32
+ c.unit_price = '$'
33
+ c.unit_volume = ' vol'
34
+ c.digit_price = 3
35
+ c.label_ma = 'ma{}'
36
+ c.candleformat = '{}\n\nend: {}\nrate: {}\ncompare: {}\nopen: {}({})\nhigh: {}({})\nlow: {}({})\nvolume: {}({})'
37
+ c.volumeformat = '{}\n\nvolume: {}\nvolume rate: {}'
38
+ c.set_data(df)
39
+ show()
40
+
41
+ return
42
+
43
+
44
+ def show():
45
+ return plt.show()
46
+
47
+
48
+ if __name__ == '__main__':
49
+ sample('apple')
@@ -0,0 +1,113 @@
1
+ from time import time
2
+
3
+ import matplotlib.pyplot as plt
4
+ import matplotlib.style as mplstyle
5
+ from matplotlib.axes import Axes
6
+ from matplotlib.backends.backend_agg import FigureCanvasAgg
7
+
8
+
9
+ from .utils import convert_unit
10
+
11
+
12
+ try: plt.switch_backend('TkAgg')
13
+ except: pass
14
+
15
+ # 한글 깨짐 문제 방지
16
+ try: plt.rcParams['font.family'] ='Malgun Gothic'
17
+ except: pass
18
+
19
+ mplstyle.use('fast')
20
+
21
+
22
+ class Base:
23
+ canvas: FigureCanvasAgg
24
+ unit_price, unit_volume = ('원', '주')
25
+
26
+ figsize = (12, 6)
27
+ ratio_ax_slider, ratio_ax_legend, ratio_ax_price, ratio_ax_volume = (3, 2, 18, 5)
28
+ adjust = dict(
29
+ top=0.95, bottom=0.05, left=0.01, right=0.93, # 여백
30
+ wspace=0, hspace=0 # 플롯간 간격
31
+ )
32
+ color_grid = '#d0d0d0'
33
+ color_background = '#fafafa'
34
+
35
+ slider_top = True
36
+ title = 'seolpyo mplchart'
37
+
38
+ def __init__(self, *args, **kwargs):
39
+ # 기본 툴바 비활성화
40
+ plt.rcParams['toolbar'] = 'None'
41
+
42
+ self._set_plot()
43
+ return
44
+
45
+ def _set_plot(self):
46
+ if self.slider_top:
47
+ fig, ax = plt.subplots(
48
+ 4, # row 수
49
+ figsize=self.figsize, # 기본 크기
50
+ height_ratios=(self.ratio_ax_slider, self.ratio_ax_legend, self.ratio_ax_price, self.ratio_ax_volume) # row 크기 비율
51
+ )
52
+ ax: list[Axes]
53
+ ax_slider, ax_legend, ax_price, ax_volume = ax
54
+ else:
55
+ fig, ax = plt.subplots(
56
+ 5, # row 수
57
+ figsize=self.figsize, # 기본 크기
58
+ height_ratios=(self.ratio_ax_legend, self.ratio_ax_price, self.ratio_ax_volume, self.ratio_ax_legend, self.ratio_ax_slider) # row 크기 비율
59
+ )
60
+ ax: list[Axes]
61
+ ax_legend, ax_price, ax_volume, ax_none, ax_slider = ax
62
+ # 사용하지 않는 axes 숨기기
63
+ ax_none.axis('off')
64
+ ax_legend.axis('off')
65
+
66
+ ax_slider.xaxis.set_animated(True)
67
+ ax_slider.yaxis.set_animated(True)
68
+
69
+ ax_price.xaxis.set_animated(True)
70
+ ax_price.yaxis.set_animated(True)
71
+
72
+ ax_volume.xaxis.set_animated(True)
73
+ ax_volume.yaxis.set_animated(True)
74
+
75
+ fig.canvas.manager.set_window_title(f'{self.title}')
76
+
77
+ # 플롯간 간격 제거(Configure subplots)
78
+ fig.subplots_adjust(**self.adjust)
79
+
80
+ # y ticklabel foramt 설정
81
+ ax_slider.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_price))
82
+ ax_price.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_price))
83
+ ax_volume.yaxis.set_major_formatter(lambda x, _: convert_unit(x, word=self.unit_volume))
84
+
85
+ # 공통 설정
86
+ for a in [ax_slider, ax_price, ax_volume]:
87
+ # y tick 우측으로 이동
88
+ a.tick_params(left=False, right=True, labelleft=False, labelright=True)
89
+ # 차트 영역 배경 색상
90
+ a.set_facecolor(self.color_background)
91
+ # grid(구분선, 격자) 그리기
92
+ a.grid(True, color=self.color_grid, linewidth=1)
93
+ # x tick 제거
94
+ a.set_xticklabels([])
95
+
96
+ self.fig, self.canvas = (fig, fig.canvas)
97
+ self.ax_slider, self.ax_legend, self.ax_price, self.ax_volume = (ax_slider, ax_legend, ax_price, ax_volume)
98
+
99
+ return self.set_plot()
100
+
101
+ def set_plot(self):
102
+ "This function works after set plot process is done."
103
+ return
104
+
105
+
106
+ class Chart(Base):
107
+ pass
108
+
109
+
110
+ if __name__ == '__main__':
111
+ Base()
112
+
113
+ plt.show()