seolpyo-mplchart 1.4.1.2__tar.gz → 2.1.0__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.

Files changed (79) hide show
  1. seolpyo_mplchart-2.1.0/MANIFEST.in +1 -0
  2. seolpyo_mplchart-2.1.0/PKG-INFO +718 -0
  3. seolpyo_mplchart-2.1.0/README.md +691 -0
  4. {seolpyo_mplchart-1.4.1.2 → seolpyo_mplchart-2.1.0}/pyproject.toml +5 -3
  5. seolpyo_mplchart-2.1.0/seolpyo_mplchart/__init__.py +69 -0
  6. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/__init__.py +145 -0
  7. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/__init__.py +111 -0
  8. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/a_canvas.py +250 -0
  9. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/b_artist.py +143 -0
  10. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/c_draw.py +100 -0
  11. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/d_segment.py +262 -0
  12. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/e_axis.py +267 -0
  13. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/f_background.py +62 -0
  14. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/g_event.py +66 -0
  15. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/h_data.py +138 -0
  16. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/base/test.py +58 -0
  17. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/__init__.py +125 -0
  18. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/b_artist.py +130 -0
  19. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/c_draw.py +96 -0
  20. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/d_segment.py +359 -0
  21. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/e_axis.py +65 -0
  22. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/g_event.py +233 -0
  23. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/h_data.py +61 -0
  24. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/cursor/test.py +69 -0
  25. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/__init__.py +169 -0
  26. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/a_canvas.py +260 -0
  27. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/b_artist.py +91 -0
  28. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/c_draw.py +54 -0
  29. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/d_segment.py +166 -0
  30. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/e_axis.py +70 -0
  31. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/f_background.py +37 -0
  32. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/g_event.py +353 -0
  33. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/h_data.py +102 -0
  34. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_chart/slider/test.py +71 -0
  35. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/__init__.py +3 -0
  36. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/ax.py +28 -0
  37. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/candle.py +31 -0
  38. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/config.py +21 -0
  39. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/cursor.py +49 -0
  40. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/figure.py +40 -0
  41. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/format.py +51 -0
  42. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/ma.py +17 -0
  43. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/slider/__init__.py +2 -0
  44. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/slider/config.py +24 -0
  45. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/slider/figure.py +19 -0
  46. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/slider/nav.py +10 -0
  47. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/unit.py +19 -0
  48. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/utils.py +67 -0
  49. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_config/volume.py +27 -0
  50. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/__init__.py +10 -0
  51. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/nums.py +67 -0
  52. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/theme/__init__.py +15 -0
  53. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/theme/dark.py +57 -0
  54. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/theme/light.py +56 -0
  55. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/utils.py +28 -0
  56. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/xl/__init__.py +15 -0
  57. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/xl/csv.py +46 -0
  58. seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/xl/xlsx.py +49 -0
  59. seolpyo_mplchart-2.1.0/seolpyo_mplchart/sample/apple.txt +6058 -0
  60. seolpyo_mplchart-2.1.0/seolpyo_mplchart/sample/samsung.txt +5938 -0
  61. seolpyo_mplchart-2.1.0/seolpyo_mplchart/test.py +187 -0
  62. seolpyo_mplchart-2.1.0/seolpyo_mplchart.egg-info/PKG-INFO +718 -0
  63. seolpyo_mplchart-2.1.0/seolpyo_mplchart.egg-info/SOURCES.txt +65 -0
  64. seolpyo_mplchart-1.4.1.2/MANIFEST.in +0 -1
  65. seolpyo_mplchart-1.4.1.2/PKG-INFO +0 -57
  66. seolpyo_mplchart-1.4.1.2/README.md +0 -30
  67. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart/__init__.py +0 -349
  68. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart/_base.py +0 -117
  69. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart/_cursor.py +0 -558
  70. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart/_draw.py +0 -634
  71. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart/_slider.py +0 -634
  72. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart/test.py +0 -61
  73. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart/utils.py +0 -56
  74. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart.egg-info/PKG-INFO +0 -57
  75. seolpyo_mplchart-1.4.1.2/seolpyo_mplchart.egg-info/SOURCES.txt +0 -15
  76. {seolpyo_mplchart-1.4.1.2 → seolpyo_mplchart-2.1.0}/seolpyo_mplchart.egg-info/dependency_links.txt +0 -0
  77. {seolpyo_mplchart-1.4.1.2 → seolpyo_mplchart-2.1.0}/seolpyo_mplchart.egg-info/requires.txt +0 -0
  78. {seolpyo_mplchart-1.4.1.2 → seolpyo_mplchart-2.1.0}/seolpyo_mplchart.egg-info/top_level.txt +0 -0
  79. {seolpyo_mplchart-1.4.1.2 → seolpyo_mplchart-2.1.0}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ recursive-include seolpyo_mplchart *
@@ -0,0 +1,718 @@
1
+ Metadata-Version: 2.4
2
+ Name: seolpyo-mplchart
3
+ Version: 2.1.0
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(English), https://white.seolpyo.com/entry/148/
9
+ Project-URL: Documentation(한글), https://white.seolpyo.com/entry/147/
10
+ Project-URL: repository, https://github.com/white-seolpyo/seolpyo-mplchart
11
+ Project-URL: Issues, https://github.com/white-seolpyo/seolpyo-mplchart/issues
12
+ Keywords: chart,차트,stock,주식,invest,투자,finance,파이낸스,candle,캔들,candlestick,캔들스틱,matplotlib,mplfinance,pyqtgraph,finplot,virtual currency,가상화폐,coin,코인,bitcoin,비트코인,ethereum,이더리움
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Framework :: Matplotlib
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: matplotlib>=3.7.0
26
+ Requires-Dist: pandas>=2.0.0
27
+
28
+ # Donation
29
+ Bitcoin: 1MKCHW8smDZv5DFMiVkA5G3DeXcMn871ZX
30
+
31
+ Ethereum: 0x1c5fb8a5e0b1153cd4116c91736bd16fabf83520
32
+
33
+
34
+ # Document
35
+ [English Document](https://github.com/white-seolpyo/seolpyo-mplchart/tree/maind)
36
+
37
+ [한글 설명서](https://white.seolpyo.com/entry/147/?from=pypi)
38
+
39
+
40
+ # This document was originally written in Korean and translated using a machine translation tool.
41
+
42
+
43
+ reference version
44
+ ----
45
+
46
+ 2.1.0
47
+
48
+ Package Introduction
49
+ ------
50
+
51
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/candle.png?raw=true)![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/40000.gif?raw=true)
52
+
53
+ Sample Charts with Over 40,000 Stock Price Data Points, with Intel i5 4690
54
+
55
+ seolpyo-mplchart is a Python package built on top of matplotlib.
56
+
57
+ While libraries like finplot and plotly are commonly used to draw candlestick charts in Python, I created this package because none of the existing tools fully met my needs.
58
+
59
+
60
+
61
+ **Key Features**
62
+
63
+ * Provides three types of Chart classes for flexible charting.
64
+ * Includes an overview slider (SliderChart) that highlights the visible range, allowing users to select or move the viewing window interactively.
65
+ * Integrates smoothly with various GUI frameworks, including tkinter, ensuring responsive performance.
66
+ * Displays stock price information as text (CursorChart, SliderChart). Simply hover your mouse over a candlestick or volume bar to view the corresponding data.
67
+ - Built-in support for toggling moving average lines on and off.
68
+
69
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/ma%20on%20off.gif?raw=true)
70
+
71
+ You can check out a sample of drawing candlestick charts integrated with tkinter at the following link:
72
+
73
+ [View tkinter sample code](https://white.seolpyo.com/entry/214/)
74
+
75
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/with%20tkinter.gif?raw=true)
76
+
77
+ ✅ Verified to work with 32-bit Python 3.11, pandas 2.0.0, and matplotlib 3.7.0.
78
+
79
+ Installation
80
+ -----
81
+
82
+ > pip install seolpyo-mplchart
83
+
84
+ Quick Start
85
+ -----
86
+
87
+ ### OnlyChart
88
+
89
+ It is a chart that simply renders without any interaction.
90
+
91
+ import seolpyo_mplchart as mc
92
+
93
+ chart = mc.OnlyChart()
94
+ df: pandas.DataFrame = {stock price data frame}
95
+ chart.set_data(df)
96
+ mc.show()
97
+
98
+
99
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/chart%20only.png?raw=true)
100
+
101
+ ### CursorChart
102
+
103
+ This chart is an enhanced version of OnlyChart with mouse interaction capabilities.
104
+ It displays the date information corresponding to the mouse cursor position at the bottom of the chart, and price or volume data on the right side.
105
+ When the mouse cursor hovers over a candlestick or volume bar, the relevant information is shown as text.
106
+
107
+
108
+ import seolpyo_mplchart as mc
109
+
110
+ chart = mc.CursorChart()
111
+ df: pandas.DataFrame = {stock price data frame}
112
+ chart.set_data(df)
113
+ mc.show()
114
+
115
+
116
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/chart%20cursor.png?raw=true)
117
+
118
+ ### SliderChart
119
+
120
+ This chart is an extended version of CursorChart with an added overview slider.
121
+ The slider allows users to select or move the viewing range, and users can also click and drag within the chart area to shift the visible region.
122
+
123
+
124
+ import seolpyo_mplchart as mc
125
+
126
+ chart = mc.SliderChart()
127
+ df: pandas.DataFrame = {stock price data frame}
128
+ chart.set_data(df)
129
+ mc.show()
130
+
131
+
132
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/sample.gif?raw=true)
133
+
134
+ Chart Description
135
+ --------
136
+
137
+ ### Chart Class Variables
138
+
139
+ #### CONFIG
140
+
141
+ Chart Configuration File
142
+ If not provided, the predefined CONFIG\* settings will be used.
143
+
144
+ \* CONFIG: mc.DEFAULTCONFIG(OnlyChart, CursorChart) 또는 mc.SLIDERCONFIG(SliderChart)
145
+
146
+
147
+ #### watermark
148
+
149
+ Watermark text displayed at the center of the chart.
150
+ If if not self.watermark evaluates to true, the watermark will not be rendered.
151
+
152
+
153
+ #### candle\_on\_ma
154
+
155
+ If true, candlesticks are drawn above the moving average line.
156
+ If false, candlesticks are drawn below the moving average line, as shown in the following image.
157
+
158
+
159
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/ma%20above%20candle.png?raw=true)
160
+
161
+ #### limit\_candle
162
+
163
+ If the number of candlesticks to be drawn on the screen is less than or equal to this value, full candlesticks are rendered.
164
+ If it exceeds the value, only wicks are drawn.
165
+
166
+
167
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/wick.png?raw=true)
168
+
169
+ #### limit\_wick
170
+
171
+ If the number of candlesticks to be drawn on the screen is less than or equal to this value, only wicks are rendered.
172
+ If it exceeds the value, a line chart is drawn instead.
173
+
174
+
175
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/line.png?raw=true)
176
+
177
+ #### limit\_volume
178
+
179
+ If the number of candlesticks drawn on the screen is less than or equal to self.limit_wick, the entire volume data is rendered.
180
+ If it exceeds that value, only a subset of volume data is drawn — specifically, the top limit_volume entries sorted in descending order of volume.
181
+ If you experience buffering when moving across a wide range, lowering this value may help improve performance.
182
+ This only applies while the chart is being moved in the Slider chart.
183
+
184
+ #### limit\_ma
185
+
186
+ If the number of candlesticks drawn on the screen is less than or equal to this value, the moving average line is rendered.
187
+ If you experience buffering when navigating across a wide range, lowering this value may help improve performance.
188
+ This only applies while the chart is being moved in the Slider chart.
189
+
190
+ #### key\_date, key\_open, key\_high, key\_low, key\_close, key\_volume
191
+
192
+ Keys for each column used in the provided data
193
+ If if not self.key_volume evaluates to true at the time of executing Chart.set_data(df), the volume chart will not be rendered.
194
+
195
+
196
+ import seolpyo_mplchart as mc
197
+
198
+ df: pandas.DataFrame = {stock price data frame}
199
+
200
+ c = mc.SliderChart()
201
+ c.key_date= '시간'
202
+ c.key_open = '시가'
203
+ c.key_high = '고가'
204
+ c.key_low = '저가'
205
+ c.key_close = '종가'
206
+ # c.key_volume = '거래량'
207
+ c.key_volume = None
208
+ c.set_data(df)
209
+
210
+ mc.show() # same as matplotlib.pyplot.show()
211
+
212
+
213
+ ### OR ###
214
+
215
+
216
+ import json
217
+
218
+ import seolpyo_mplchart as mc
219
+ import pandas as pd
220
+
221
+ file = {stock price data path}
222
+ with open(file, 'r', encoding='utf-8') as txt:
223
+ data = json.load(txt)
224
+ df = pd.DataFrame(data)
225
+
226
+ class Chart(mc.SliderChart):
227
+ key_date = '시간'
228
+ key_open, key_high, key_low, key_close = ('시가', '고가', '저가', '종가')
229
+ # key_volume = '거래량'
230
+ key_volume = None
231
+
232
+ c = Chart()'
233
+ c.set_data(df)
234
+
235
+ mc.show() # same as matplotlib.pyplot.show()
236
+
237
+
238
+
239
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/en%20no%20vol%20(2).png?raw=true)
240
+
241
+ #### fraction
242
+
243
+ If true, decimal values are displayed as fractions.
244
+
245
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/fraction.png?raw=true)
246
+
247
+ #### slider\_top
248
+
249
+ If true, the slider is positioned above the chart.
250
+
251
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/slider%20bottom.png?raw=true)
252
+
253
+ #### min\_distance
254
+
255
+ Minimum number of candlesticks required when selecting a slider range
256
+ If the selected range contains fewer candlesticks than this value, the previous range will be retained.
257
+
258
+
259
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/min%20distance.gif?raw=true)
260
+
261
+ #### in\_chart
262
+
263
+ Determines whether the mouse cursor is located within the price chart or volume chart area.
264
+
265
+
266
+ #### in\_slider
267
+
268
+ Determines whether the mouse cursor is located within the slider area.
269
+
270
+
271
+ #### in\_price\_chart
272
+
273
+ Determines whether the mouse cursor is located within the price chart area.
274
+
275
+
276
+ #### in\_volume\_chart
277
+
278
+ Determines whether the mouse cursor is located within the volume chart area.
279
+
280
+
281
+ ### Chart class method
282
+ #### Chart.\_\_init\_\_(config=DEFAULTCONFIG or SLIDERCONFIG)
283
+
284
+ Creates a chart object.
285
+
286
+ #### Chart.set_data(df, change_xlim=True)
287
+
288
+ Passes stock price data to the chart object.
289
+ The chart object generates chart data based on the received input.
290
+ When retrieving data from a DataFrame, the predefined keys — Chart.key\_date, Chart.key\_open, Chart.key\_high, Chart.key\_low, Chart.key\_close, and Chart.key\_volume — are used.
291
+ Therefore, these keys should be properly set before calling set\_data.
292
+ `if change_lim is True`, it retrieves the values from Chart.get_default_lim() and updates the xlim accordingly.
293
+
294
+
295
+
296
+ #### Chart.get_default_xlim()
297
+
298
+ It retrieves the xlim values set when Chart.set_data() is called.
299
+
300
+ #### Chart.refresh()
301
+
302
+ Refreshes the chart.
303
+ During the refresh, any changes made to self.CONFIG are applied.
304
+
305
+
306
+ #### Chart.add\_artists()
307
+
308
+ Function that adds the Artists used in the chart. Called during initialization (init).
309
+
310
+
311
+ #### Chart.draw\_artists()
312
+
313
+ Function that renders the Artists on the chart.
314
+ Called when the on_draw event is triggered.
315
+
316
+
317
+ #### Chart.set\_artists()
318
+
319
+ Function that applies the settings of chart Artists.
320
+ Called during refresh.
321
+
322
+
323
+ #### Chart.set\_collections()
324
+
325
+ Function that applies the settings of candlestick and volume chart Artists.
326
+ Called during refresh or when the display area changes.
327
+
328
+
329
+ #### Chart.add\_candle\_color\_column(), Chart.add\_volume\_color\_column()
330
+
331
+ This method determines the colors of candlesticks and volume bars drawn on the chart.
332
+ It adds the following columns to self.df:
333
+ - ['facecolor', 'edgecolor'] for candlesticks
334
+ - ['facecolor_volume', 'edgecolor_volume'] for volume bars
335
+ By modifying the values in these columns, you can customize the colors as desired.
336
+
337
+
338
+ ##### Candlestick Colors
339
+ - Open < Close, Previous Close < Close
340
+ → self.CONFIG.CANDLE.FACECOLOR.bull_rise, self.CONFIG.CANDLE.EDGECOLOR.bull_rise
341
+ - Open < Close, Previous Close > Close
342
+ → self.CONFIG.CANDLE.FACECOLOR.bull_fall, self.CONFIG.CANDLE.EDGECOLOR.bull_fall
343
+ - Close < Open, Close < Previous Close
344
+ → self.CONFIG.CANDLE.FACECOLOR.bear_fall, self.CONFIG.CANDLE.EDGECOLOR.bear_fall
345
+ - Close < Open, Close > Previous Close
346
+ → self.CONFIG.CANDLE.FACECOLOR.bear_rise, self.CONFIG.CANDLE.EDGECOLOR.bear_rise
347
+ - Open == Close
348
+ → self.CONFIG.CANDLE.EDGECOLOR.doji
349
+
350
+
351
+
352
+
353
+ ##### Volume Bar Colors
354
+ - Previous Close < Current Close
355
+ → self.CONFIG.VOLUME.FACECOLOR.rise, self.CONFIG.VOLUME.EDGECOLOR.rise
356
+ - Previous Close > Current Close
357
+ → self.CONFIG.VOLUME.FACECOLOR.fall, self.CONFIG.VOLUME.EDGECOLOR.fall
358
+ - Previous Close == Current Close
359
+ → self.CONFIG.VOLUME.FACECOLOR.doji, self.CONFIG.VOLUME.EDGECOLOR.doji
360
+
361
+
362
+
363
+
364
+ #### Chart.get\_cnadle\_segment(x, left, right, top, bottom, is\_up, high, low)
365
+
366
+ This method is provided to modify the appearance of candlesticks drawn on the chart.
367
+
368
+
369
+ import pandas as pd
370
+ import seolpyo_mplchart as mc
371
+
372
+ class Chart(mc.SliderChart):
373
+ def __init__(self, *args, **kwargs):
374
+ super().__init__(*args, **kwargs)
375
+ self.collection_candle.set_linewidth(1.5)
376
+ return
377
+
378
+ def get_candle_segment(self, *, x, left, right, top, bottom, is_up, high, low):
379
+ if is_up:
380
+ return (
381
+ (x, high),
382
+ (x, top), (right, top), (x, top),
383
+ (x, bottom), (left, bottom),
384
+ (x, bottom), (x, low), (x, high)
385
+ )
386
+ else:
387
+ return (
388
+ (x, high),
389
+ (x, bottom), (right, bottom), (x, bottom),
390
+ (x, top), (left, top), (x, top),
391
+ (x, low), (x, high)
392
+ )
393
+
394
+
395
+ C = Chart()
396
+
397
+ data = {stock price data}
398
+ df = pd.DataFrame(data)
399
+
400
+ C.set_data(df)
401
+
402
+ mc.show()
403
+
404
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/en%20bar%20chart.png?raw=true)
405
+
406
+ ### Chart.get\_info\_kwargs(is\_price, \*\*kwargs)
407
+
408
+ You can modify or add the data displayed in the text box using the get_info_kwargs method.
409
+ The **kwargs parameter receives predefined keyword arguments.
410
+
411
+ If you'd like, I can help format this as a docstring or comment for your code. For example:
412
+ Allows customization of the data shown in the text box.
413
+ Predefined keyword arguments are passed via **kwargs.
414
+
415
+
416
+ import pandas as pd
417
+ import seolpyo_mplchart as mc
418
+
419
+
420
+ class Chart(mc.SliderChart):
421
+ format_candleinfo = mc.format_candleinfo_ko + '\nCustom info: {ci}'
422
+
423
+ def get_info_kwargs(self, is_price, **kwargs):
424
+ if is_price:
425
+ kwargs['ci'] = 'this is custom add info kwargs'
426
+ kwargs['close'] = 'Cusotom close value'
427
+ return kwargs
428
+
429
+ C = Chart()
430
+ data = {stock price data}
431
+ df = pd.DataFrame(data)
432
+
433
+ C.set_data(df)
434
+
435
+ mc.show()
436
+
437
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/change%20text%20info.png?raw=true)
438
+
439
+ #### Chart.on\_draw(e)
440
+
441
+ Method called when the draw event is triggered.
442
+ Only invoked in CursorChart and SliderChart.
443
+
444
+
445
+ #### Chart.on\_resize(e)
446
+
447
+ Method called when the resize event is triggered.
448
+ Only invoked in SliderChart.
449
+
450
+
451
+ #### Chart.on\_pick(e)
452
+
453
+ Method called when the pick event is triggered.
454
+
455
+
456
+ #### Chart.on\_move(e)
457
+
458
+ Method called when a mouse movement event occurs.
459
+ Only invoked in CursorChart and SliderChart.
460
+
461
+
462
+ #### Chart.on\_click(e)
463
+
464
+ Method called when a mouse click event occurs.
465
+
466
+ Only invoked in SliderChart.
467
+
468
+ #### Chart.on\_release(e)
469
+
470
+ Method called when a mouse release event occurs.
471
+
472
+ Only invoked in SliderChart.
473
+
474
+ ### CONFIG
475
+
476
+ A configuration that includes setting class objects such as FIGURE, AX, FORMAT, UNIT, CURSOR, CANDLE, VOLUME, MA, and SLIDER.
477
+
478
+
479
+ ### DEFAULTCONFIG
480
+
481
+ CONFIG applied to OnlyChart and CursorChart.
482
+
483
+
484
+ ### DEFAULTCONFIG\_EN
485
+
486
+ CONFIG applied to OnlyChart and CursorChart, with the price unit set to $, the volume unit set to Vol, and the formatting based on English conventions.
487
+
488
+
489
+ ### SLIDERCONFIG
490
+
491
+ CONFIG applied to SliderChart.
492
+
493
+
494
+ ### SLIDERCONFIG\_EN
495
+
496
+ CONFIG applied to SliderChart, with the price unit set to $, the volume unit set to Vol, and the formatting based on English conventions.
497
+
498
+ ```
499
+ # seolpyo_mplchart/_config/slider/config.py
500
+
501
+ from .. import config
502
+ from .figure import FIGURE, SliderFigureData
503
+ from .nav import NAVIGATOR
504
+
505
+
506
+ class SliderData:
507
+ def __init__(self):
508
+ self.NAVIGATOR = NAVIGATOR
509
+
510
+ SLIDER = SliderData()
511
+
512
+ class SliderConfigData(config.ConfigData):
513
+ FIGURE: SliderFigureData
514
+ SLIDER: SliderData
515
+
516
+
517
+ SLIDERCONFIG: SliderConfigData = config.DEFAULTCONFIG
518
+ SLIDERCONFIG.FIGURE = FIGURE
519
+ SLIDERCONFIG.SLIDER = SLIDER
520
+
521
+ SLIDERCONFIG_EN: SliderConfigData = config.DEFAULTCONFIG_EN
522
+ SLIDERCONFIG_EN.FIGURE = FIGURE
523
+ SLIDERCONFIG_EN.SLIDER = SLIDER
524
+ ```
525
+
526
+ ```
527
+ # seolpyo_mplchart/_config/config.py
528
+
529
+ from . import figure, ax, candle, volume, ma, unit, cursor, format
530
+
531
+
532
+ class ConfigData:
533
+ def __init__(self):
534
+ self.FIGURE = figure.FIGURE
535
+ self.UNIT = unit.UNIT
536
+ self.AX = ax.AX
537
+ self.CANDLE = candle.CANDLE
538
+ self.VOLUME = volume.VOLUME
539
+ self.MA = ma.MA
540
+ self.CURSOR = cursor.CURSOR
541
+ self.FORMAT = format.FORMAT
542
+
543
+ DEFAULTCONFIG = ConfigData()
544
+
545
+ DEFAULTCONFIG_EN = ConfigData()
546
+ DEFAULTCONFIG_EN.UNIT = unit.UNIT_EN
547
+ DEFAULTCONFIG_EN.MA = ma.MA_EN
548
+ DEFAULTCONFIG_EN.FORMAT = format.FORMAT_EN
549
+ ```
550
+
551
+
552
+ # Others
553
+
554
+ ---
555
+
556
+ # Required data
557
+ -------
558
+
559
+ A chart object must be provided with a DataFrame that contains the following columns:
560
+ [timestamp, open, high, low, close, volume]
561
+
562
+
563
+ ## How to Change Language and Text Format
564
+ The default language is Korean.
565
+ If needed, you can change the units for price and volume, and customize the text format to match your preferred style.
566
+
567
+
568
+ ### How to Change Display Units
569
+
570
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/en%20no%20vol%20(2).png?raw=true)
571
+
572
+ The price and volume units, as well as the number of decimal places for price and volume, are managed in CONFIG.UNIT.
573
+
574
+ from .utils import convert_unit, convert_unit_en
575
+ # seolpyo_mplchart._config.unit.py
576
+
577
+ class UnitData:
578
+ def __init__(self):
579
+ self.price = '원'
580
+ self.volume = '주'
581
+ self.digit = 0
582
+ self.digit_volume = 0
583
+ self.func = convert_unit
584
+
585
+ UNIT = UnitData()
586
+
587
+ UNIT_EN = UnitData()
588
+ UNIT_EN.price = ' $'
589
+ UNIT_EN.volume = ' Vol'
590
+ UNIT_EN.digit = 2
591
+ UNIT_EN.func = convert_unit_en
592
+
593
+
594
+
595
+ ### How to Change the Information Text Format
596
+
597
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/en%20no%20vol%20(2).png?raw=true)![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/kor%20vol.png?raw=true)
598
+
599
+ You can customize the name of the price moving average line and the text displayed in the information box.
600
+ Text formatting is managed through CONFIG.FORMAT.
601
+ Additional kwargs for customizing the text can be passed via the chart’s get_info_kwargs method.
602
+
603
+
604
+ # seolpyo_mplchart/_config/format.py
605
+
606
+ format_candleinfo_ko = """\
607
+ {dt}
608
+
609
+ 종가:  {close}
610
+ 등락률: {rate}
611
+ 대비:  {compare}
612
+ 시가:  {open}({rate_open})
613
+ 고가:  {high}({rate_high})
614
+ 저가:  {low}({rate_low})
615
+ 거래량: {volume}({rate_volume})\
616
+ """
617
+ format_volumeinfo_ko = """\
618
+ {dt}
619
+
620
+ 거래량:    {volume}
621
+ 거래량증가율: {rate_volume}
622
+ 대비:     {compare}\
623
+ """
624
+
625
+ class FormatData:
626
+ def __init__(self):
627
+ self.candle = format_candleinfo_ko
628
+ self.volume = format_volumeinfo_ko
629
+
630
+ FORMAT = FormatData()
631
+
632
+ format_candleinfo_en = """\
633
+ {dt}
634
+
635
+ close: {close}
636
+ rate: {rate}
637
+ compare: {compare}
638
+ open: {open}({rate_open})
639
+ high: {high}({rate_high})
640
+ low: {low}({rate_low})
641
+ volume: {volume}({rate_volume})\
642
+ """
643
+ format_volumeinfo_en = """\
644
+ {dt}
645
+
646
+ volume: {volume}
647
+ volume rate: {rate_volume}
648
+ compare: {compare}\
649
+ """
650
+
651
+ FORMAT_EN = FormatData()
652
+ FORMAT_EN.candle = format_candleinfo_en
653
+ FORMAT_EN.volume = format_volumeinfo_en
654
+
655
+
656
+
657
+ How to Change Chart Style
658
+ -----------
659
+
660
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/theme%20light.png?raw=true)![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/theme%20dark.png?raw=true)
661
+
662
+ Since I prefer a white background, the default chart style is set to light mode.
663
+ If you want to change the chart style, simply modify the color values defined in CONFIG.
664
+ A function named set_theme has been created to switch between light and dark themes.
665
+ You can either use this function directly, or check which values it modifies and adjust them to suit your preferences.
666
+
667
+
668
+ import json
669
+
670
+ import seolpyo_mplchart as mc
671
+ import pandas as pd
672
+
673
+
674
+ class Chart(mc.SliderChart):
675
+ def __init__(self, config, *args, **kwargs):
676
+ config = mc.set_theme(config, theme='dark')
677
+
678
+
679
+ file = {stock price data path}
680
+ with open(file, 'r', encoding='utf-8') as txt:
681
+ data = json.load(txt)
682
+ df = pd.DataFrame(data)
683
+
684
+ c = Chart()
685
+ c.set_data(df)
686
+
687
+ mc.show()
688
+
689
+
690
+ How to Change Chart Aspect Ratio
691
+ --------
692
+
693
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/ratio.png?raw=true)
694
+
695
+ You can adjust the proportions of each chart area using the values of
696
+ ratio_ax_slider, ratio_ax_legend, ratio_ax_price, ratio_ax_volume, and ratio_ax_none.
697
+ Note: ratio_ax_none is only used when the value of slider_top is set to False.
698
+
699
+
700
+ # seolpyo_mplchart/_config/slider/figure.py
701
+
702
+
703
+ class RatioData:
704
+ def __init__(self):
705
+ self.legend = 2
706
+ self.price = 18
707
+ self.volume = 5
708
+ self.slider = 3
709
+ self.none = 2
710
+
711
+ RATIO = RatioData()
712
+
713
+ class SliderFigureData(figure.FigureData):
714
+ def __init__(self):
715
+ super().__init__()
716
+ self.RATIO: RatioData = RATIO
717
+
718
+ FIGURE = SliderFigureData()