seolpyo-mplchart 1.4.1__py3-none-any.whl → 2.0.0.3__py3-none-any.whl

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.
Files changed (44) hide show
  1. seolpyo_mplchart/__init__.py +144 -308
  2. seolpyo_mplchart/_chart/__init__.py +137 -0
  3. seolpyo_mplchart/_chart/_base.py +217 -0
  4. seolpyo_mplchart/_chart/_cursor/__init__.py +2 -0
  5. seolpyo_mplchart/_chart/_cursor/_artist.py +217 -0
  6. seolpyo_mplchart/_chart/_cursor/_cursor.py +165 -0
  7. seolpyo_mplchart/_chart/_cursor/_info.py +187 -0
  8. seolpyo_mplchart/_chart/_draw/__init__.py +2 -0
  9. seolpyo_mplchart/_chart/_draw/_artist.py +50 -0
  10. seolpyo_mplchart/_chart/_draw/_data.py +314 -0
  11. seolpyo_mplchart/_chart/_draw/_draw.py +103 -0
  12. seolpyo_mplchart/_chart/_draw/_lim.py +265 -0
  13. seolpyo_mplchart/_chart/_slider/__init__.py +1 -0
  14. seolpyo_mplchart/_chart/_slider/_base.py +268 -0
  15. seolpyo_mplchart/_chart/_slider/_data.py +105 -0
  16. seolpyo_mplchart/_chart/_slider/_mouse.py +176 -0
  17. seolpyo_mplchart/_chart/_slider/_nav.py +204 -0
  18. seolpyo_mplchart/_chart/test.py +121 -0
  19. seolpyo_mplchart/_config/__init__.py +3 -0
  20. seolpyo_mplchart/_config/ax.py +28 -0
  21. seolpyo_mplchart/_config/candle.py +30 -0
  22. seolpyo_mplchart/_config/config.py +21 -0
  23. seolpyo_mplchart/_config/cursor.py +49 -0
  24. seolpyo_mplchart/_config/figure.py +41 -0
  25. seolpyo_mplchart/_config/format.py +51 -0
  26. seolpyo_mplchart/_config/ma.py +15 -0
  27. seolpyo_mplchart/_config/slider/__init__.py +2 -0
  28. seolpyo_mplchart/_config/slider/config.py +24 -0
  29. seolpyo_mplchart/_config/slider/figure.py +20 -0
  30. seolpyo_mplchart/_config/slider/nav.py +9 -0
  31. seolpyo_mplchart/_config/unit.py +19 -0
  32. seolpyo_mplchart/_config/utils.py +67 -0
  33. seolpyo_mplchart/_config/volume.py +26 -0
  34. seolpyo_mplchart/_cursor.py +27 -25
  35. seolpyo_mplchart/_draw.py +7 -18
  36. seolpyo_mplchart/_slider.py +26 -20
  37. seolpyo_mplchart/test.py +172 -56
  38. seolpyo_mplchart/xl_to_dict.py +47 -0
  39. seolpyo_mplchart-2.0.0.3.dist-info/METADATA +710 -0
  40. seolpyo_mplchart-2.0.0.3.dist-info/RECORD +50 -0
  41. {seolpyo_mplchart-1.4.1.dist-info → seolpyo_mplchart-2.0.0.3.dist-info}/WHEEL +1 -1
  42. seolpyo_mplchart-1.4.1.dist-info/METADATA +0 -57
  43. seolpyo_mplchart-1.4.1.dist-info/RECORD +0 -17
  44. {seolpyo_mplchart-1.4.1.dist-info → seolpyo_mplchart-2.0.0.3.dist-info}/top_level.txt +0 -0
@@ -5,43 +5,53 @@ from pathlib import Path
5
5
  import matplotlib.pyplot as plt
6
6
  import pandas as pd
7
7
 
8
- from ._draw import Chart as _BaseChart
9
- from ._cursor import Chart as _BaseCursorChart, format_candleinfo_ko, format_volumeinfo_ko, format_candleinfo_en, format_volumeinfo_en
10
- from ._slider import Chart as _BaseSliderChart
8
+ from ._chart import OnlyChart, CursorChart, SliderChart
9
+ from ._config import DEFAULTCONFIG, DEFAULTCONFIG_EN, SLIDERCONFIG, SLIDERCONFIG_EN, ConfigData, SliderConfigData
11
10
 
12
11
 
13
- __all__ = [
14
- 'path_samsung', 'path_apple',
15
- 'format_candleinfo_ko', 'format_volumeinfo_ko',
16
- 'format_candleinfo_en', 'format_volumeinfo_en',
17
- 'sample', 'switch_backend', 'show', 'close',
18
- 'OnlyChart', 'CursorChart', 'SliderChart',
19
- 'set_theme',
20
- ]
12
+ # __all__ = [
13
+ # 'path_samsung', 'path_apple',
14
+ # 'format_candleinfo_ko', 'format_volumeinfo_ko',
15
+ # 'format_candleinfo_en', 'format_volumeinfo_en',
16
+ # 'sample', 'switch_backend', 'show', 'close',
17
+ # 'OnlyChart', 'CursorChart', 'SliderChart',
18
+ # 'set_theme',
19
+ # ]
21
20
 
22
21
 
23
- path_samsung = Path(__file__).parent / 'sample/samsung.txt'
24
- path_apple = Path(__file__).parent / 'sample/apple.txt'
22
+ pkg_name = 'seolpyo_mplchart'
23
+ path_pkg = Path(__file__)
24
+ while path_pkg.name != pkg_name:
25
+ path_pkg = path_pkg.parent
26
+ path_samsung = path_pkg / 'sample' / 'samsung.txt'
27
+ path_apple = path_pkg / 'sample' / 'apple.txt'
25
28
 
26
29
  def sample(stock: Literal['samsung', 'apple']='samsung', chart: Literal['Chart', 'CursorChart', 'SliderChart']='SliderChart'):
27
- C: _BaseSliderChart = {'Chart': _BaseChart, 'CursorChart': _BaseCursorChart, 'SliderChart': _BaseSliderChart}[chart]()
30
+ d = {
31
+ 'Chart': OnlyChart,
32
+ 'CursorChart': CursorChart,
33
+ 'SliderChart': SliderChart,
34
+ }
35
+ C = d[chart]
28
36
  path_file = path_samsung if stock == 'samsung' else path_apple
29
37
  if stock == 'samsung':
30
- C.format_candleinfo = format_candleinfo_ko
31
- C.format_volumeinfo = format_volumeinfo_ko
38
+ if chart == 'SliderChart':
39
+ config = SLIDERCONFIG
40
+ else:
41
+ config = DEFAULTCONFIG
32
42
  else:
33
- C.format_candleinfo = format_candleinfo_en
34
- C.format_volumeinfo = format_volumeinfo_en
35
- C.unit_price = '$'
36
- C.unit_volume = 'Vol'
37
- C.digit_price = 3
38
- C.format_ma = 'ma{}'
43
+ if chart == 'SliderChart':
44
+ config = SLIDERCONFIG_EN
45
+ else:
46
+ config = DEFAULTCONFIG_EN
47
+
48
+ CHART: SliderChart = C(config)
39
49
 
40
50
  with open(path_file, 'r', encoding='utf-8') as txt:
41
51
  data = json.load(txt)
42
52
  df = pd.DataFrame(data)
43
53
 
44
- C.set_data(df)
54
+ CHART.set_data(df)
45
55
 
46
56
  show()
47
57
  close()
@@ -53,297 +63,123 @@ def switch_backend(newbackend='TkAgg'):
53
63
  return plt.switch_backend(newbackend)
54
64
 
55
65
 
56
- def show(Close=False):
66
+ def close(fig='all'):
67
+ "call matplotlib.pyplot.close(fig)"
68
+ return plt.close(fig)
69
+
70
+ def show(Close=True):
57
71
  """
58
72
  call matplotlib.pyplot.show()
59
73
  ```if Close``` if True, run matplotlib.pyplot.close('all') after window closee.
60
74
  """
61
75
  plt.show()
62
- if Close: close()
76
+ if Close:
77
+ close()
63
78
  return
64
79
 
65
80
 
66
- def close(fig='all'):
67
- "call matplotlib.pyplot.close(fig)"
68
- return plt.close(fig)
69
-
70
-
71
- class OnlyChart(_BaseChart):
72
- r"""
73
- You can see the guidance document:
74
- Korean: https://white.seolpyo.com/entry/147/
75
- English: https://white.seolpyo.com/entry/148/
76
-
77
- Quick Start:
78
- ```
79
- import seolpyo_mplchart as mc
80
- chart = mc.SliderChart() # Create instance
81
- chart.set_data(df) # set stock price data
82
- mc.show() # show chart(run ```matplotlib.pyplot.show()```)
83
- mc.close() # run ```matplotlib.pyplot.close('close')```
84
- ```
85
-
86
- Class Variables:
87
- watermark: watermark text.
88
-
89
- figsize: Default size when creating a matplotlib window
90
- ratio_ax_legend, ratio_ax_price, ratio_ax_volume: Axes ratio
91
- adjust: figure adjust. default ```dict(top=0.95, bottom=0.05, left=0.01, right=0.93, wspace=0, hspace=0)```.
92
- color_background: color of background. default '#fafafa'.
93
- gridKwargs: kwargs applied to the grid
94
- color_tick, color_tick_label: Tick and tick label colors. default ('k', 'k').
95
-
96
- df: stock data DataFrame.
97
- date: date column key. default 'date'
98
- Open, high, low, close: price column key. default ('open', 'high', 'low', 'close')
99
- volume: volume column key. default 'volume'. If ```if self.volume``` is ```False```, the volume chart is not drawn.
100
-
101
- format_ma: moving average legend label format. default '{}일선'
102
- list_ma: Decide how many days to draw the moving average line. default (5, 20, 60, 120, 240)
103
- list_macolor: Color the moving average line. If the number of colors is greater than the moving average line, black is applied
104
-
105
- candle_on_ma: Decide whether to draw candles on the moving average line. default ```True```
106
- color_navigator_line: Color of left and right dividing lines in selected area
107
- color_navigator_cover: Color of unselected area.
108
-
109
- color_priceline: The color of the price line
110
-
111
- color_up: The color of the candle. When the closing price is greater than the opening price
112
- color_down: The color of the candle. When the opening price is greater than the opening price
113
- color_flat: The color of the candle. When the closing price is the same as the opening price
114
- color_up_down: The color of the candle. If the closing price is greater than the opening price, but is lower than the previous day's closing price
115
- color_down_up: The color of the candle. If the opening price is greater than the closing price, but is higher than the closing price of the previous day
116
- colors_volume: The color of the volume bar. default '#1f77b4'
117
-
118
- color_volume_up: The color of the volume. When the closing price is greater than the opening price
119
- color_volume_down: The color of the volume. When the opening price is greater than the opening price
120
- color_volume_flatt: The color of the volume. When the closing price is the same as the opening price
121
-
122
- candle_width_half, volume_width_half: half of the thickness of the candle and volume
123
-
124
- color_box: The color of the candlebox and volumebox. Used when the mouse is over a candle or volume bar. default 'k'
81
+ def set_theme(config: ConfigData|SliderConfigData, theme: Literal['light', 'dark']='dark'):
82
+ if theme == 'light':
83
+ # axes
84
+ config.FIGURE.facecolor = '#fafafa'
85
+ config.AX.facecolor = '#fafafa'
86
+ config.AX.TICK.edgecolor = 'k'
87
+ config.AX.TICK.fontcolor = 'k'
88
+ config.AX.GRID.color = '#d0d0d0'
89
+
90
+ # candle
91
+ config.CANDLE.line_color = 'k'
92
+ config.CANDLE.FACECOLOR.bull_rise = '#FF2400'
93
+ config.CANDLE.FACECOLOR.bull_fall = 'w'
94
+ config.CANDLE.FACECOLOR.bear_fall = '#1E90FF'
95
+ config.CANDLE.FACECOLOR.bear_rise = 'w'
96
+
97
+ config.CANDLE.EDGECOLOR.bull_rise = '#FF2400'
98
+ config.CANDLE.EDGECOLOR.bull_fall = '#FF2400'
99
+ config.CANDLE.EDGECOLOR.bear_fall = '#1E90FF'
100
+ config.CANDLE.EDGECOLOR.bear_rise = '#1E90FF'
101
+ config.CANDLE.EDGECOLOR.doji = 'k'
102
+
103
+ # volume
104
+ config.VOLUME.FACECOLOR.rise = '#F27663'
105
+ config.VOLUME.FACECOLOR.fall = '#70B5F2'
106
+ config.VOLUME.FACECOLOR.doji = '#BEBEBE'
107
+
108
+ config.VOLUME.EDGECOLOR.rise = '#F27663'
109
+ config.VOLUME.EDGECOLOR.fall = '#70B5F2'
110
+ config.VOLUME.EDGECOLOR.doji = '#BEBEBE'
111
+
112
+ # ma
113
+ config.MA.color_default = 'k'
114
+ config.MA.color_list = ['#8B00FF', '#008000', '#A0522D', '#008B8B', '#FF0080']
115
+ # text
116
+ config.CURSOR.TEXT.BBOX.facecolor = 'w'
117
+ config.CURSOR.TEXT.BBOX.edgecolor = 'k'
118
+ config.CURSOR.TEXT.color = 'k'
119
+
120
+ # box
121
+ config.CURSOR.BOX.edgecolor = 'k'
122
+
123
+ # line
124
+ config.CURSOR.CROSSLINE.edgecolor = 'k'
125
+
126
+ # wartermark
127
+ config.FIGURE.WATERMARK.color = 'k'
128
+
129
+ if getattr(config, 'SLIDER', None):
130
+ config.SLIDER.NAVIGATOR.edgecolor = '#2962FF'
131
+ config.SLIDER.NAVIGATOR.facecolor = '#0000002E'
132
+ elif theme == 'dark':
133
+ # axes
134
+ config.FIGURE.facecolor = '#0f0f0f'
135
+ config.AX.facecolor = '#0f0f0f'
136
+ config.AX.TICK.edgecolor = '#dbdbdb'
137
+ config.AX.TICK.fontcolor = '#dbdbdb'
138
+ config.AX.GRID.color = '#1c1c1c'
139
+
140
+ # candle
141
+ config.CANDLE.line_color = 'w'
142
+ config.CANDLE.FACECOLOR.bull_rise = '#089981'
143
+ config.CANDLE.FACECOLOR.bull_fall = '#0f0f0f'
144
+ config.CANDLE.FACECOLOR.bear_fall = '#f23645'
145
+ config.CANDLE.FACECOLOR.bear_rise = '#0f0f0f'
146
+
147
+ config.CANDLE.EDGECOLOR.bull_rise = '#089981'
148
+ config.CANDLE.EDGECOLOR.bull_fall = '#089981'
149
+ config.CANDLE.EDGECOLOR.bear_fall = '#f23645'
150
+ config.CANDLE.EDGECOLOR.bear_rise = '#f23645'
151
+ config.CANDLE.EDGECOLOR.doji = 'w'
152
+
153
+ # volume
154
+ config.VOLUME.FACECOLOR.rise = '#2A8076'
155
+ config.VOLUME.FACECOLOR.fall = '#BE4F58'
156
+ config.VOLUME.FACECOLOR.doji = '#82828A'
157
+
158
+ config.VOLUME.EDGECOLOR.rise = '#2A8076'
159
+ config.VOLUME.EDGECOLOR.fall = '#BE4F58'
160
+ config.VOLUME.EDGECOLOR.doji = '#82828A'
161
+
162
+ # ma
163
+ config.MA.color_default = 'w'
164
+ config.MA.color_list = ['#FFB300', '#03A9F4', '#AB47BC', '#8BC34A', '#EF5350']
165
+
166
+ # text
167
+ config.CURSOR.TEXT.BBOX.facecolor = '#3d3d3d'
168
+ config.CURSOR.TEXT.BBOX.edgecolor = '#ffffff'
169
+ config.CURSOR.TEXT.color = '#ffffff'
170
+
171
+ # box
172
+ config.CURSOR.BOX.edgecolor = 'w'
173
+
174
+ # line
175
+ config.CURSOR.CROSSLINE.edgecolor = '#9c9c9c'
176
+
177
+ # wartermark
178
+ config.FIGURE.WATERMARK.color = 'w'
179
+
180
+ if getattr(config, 'SLIDER', None):
181
+ config.SLIDER.NAVIGATOR.edgecolor = "#00A6FF"
182
+ config.SLIDER.NAVIGATOR.facecolor = '#FFFFFF4D'
183
+
184
+ return config
125
185
 
126
- limit_candle: Maximum number of candles to draw. default 800
127
- limit_wick: Maximum number of candle wicks to draw. default 4,000
128
- """
129
- pass
130
-
131
-
132
- class CursorChart(_BaseCursorChart):
133
- r"""
134
- You can see the guidance document:
135
- Korean: https://white.seolpyo.com/entry/147/
136
- English: https://white.seolpyo.com/entry/148/
137
-
138
- Quick Start:
139
- ```
140
- import seolpyo_mplchart as mc
141
- chart = mc.SliderChart() # Create instance
142
- chart.set_data(df) # set stock price data
143
- mc.show() # show chart(run ```matplotlib.pyplot.show()```)
144
- mc.close() # run ```matplotlib.pyplot.close('close')```
145
- ```
146
-
147
- Class Variables:
148
- watermark: watermark text.
149
-
150
- unit_price, unit_volume: price and volume unit. default ('원', '주').
151
- digit_price, digit_volume: display decimal places when displaying price and volume. default (0, 0),
152
-
153
- figsize: Default size when creating a matplotlib window
154
- ratio_ax_legend, ratio_ax_price, ratio_ax_volume: Axes ratio
155
- adjust: figure adjust. default ```dict(top=0.95, bottom=0.05, left=0.01, right=0.93, wspace=0, hspace=0)```.
156
- color_background: color of background. default '#fafafa'.
157
- gridKwargs: kwargs applied to the grid
158
- color_tick, color_tick_label: Tick and tick label colors. default ('k', 'k').
159
-
160
- df: stock data DataFrame.
161
- date: date column key. default 'date'
162
- Open, high, low, close: price column key. default ('open', 'high', 'low', 'close')
163
- volume: volume column key. default 'volume'. If ```if self.volume``` is ```False```, the volume chart is not drawn.
164
-
165
- format_ma: moving average legend label format. default '{}일선'
166
- list_ma: Decide how many days to draw the moving average line. default (5, 20, 60, 120, 240)
167
- list_macolor: Color the moving average line. If the number of colors is greater than the moving average line, black is applied
168
-
169
- candle_on_ma: Decide whether to draw candles on the moving average line. default ```True```
170
- color_navigator_line: Color of left and right dividing lines in selected area
171
- color_navigator_cover: Color of unselected area.
172
-
173
- color_priceline: The color of the price line
174
-
175
- color_up: The color of the candle. When the closing price is greater than the opening price
176
- color_down: The color of the candle. When the opening price is greater than the opening price
177
- color_flat: The color of the candle. When the closing price is the same as the opening price
178
- color_up_down: The color of the candle. If the closing price is greater than the opening price, but is lower than the previous day's closing price
179
- color_down_up: The color of the candle. If the opening price is greater than the closing price, but is higher than the closing price of the previous day
180
- colors_volume: The color of the volume bar. default '#1f77b4'
181
-
182
- color_volume_up: The color of the volume. When the closing price is greater than the opening price
183
- color_volume_down: The color of the volume. When the opening price is greater than the opening price
184
- color_volume_flatt: The color of the volume. When the closing price is the same as the opening price
185
-
186
- candle_width_half, volume_width_half: half of the thickness of the candle and volume
187
-
188
- color_box: The color of the candlebox and volumebox. Used when the mouse is over a candle or volume bar. default 'k'
189
-
190
- lineKwargs: kwarg applied to lines drawn based on mouse cursor position
191
- textboxKwargs: kwarg applied to the info text bbox drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
192
- textKwargs: A kwarg that applies to the informational text drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
193
-
194
- fraction: Decide whether to express information as a fraction. default False
195
- format_candleinfo: Candle information text format. default '{dt}\n\n종가:  {close}\n등락률: {rate}\n대비:  {compare}\n시가:  {open}({rate_open})\n고가:  {high}({rate_high})\n저가:  {low}({rate_low})\n거래량: {volume}({rate_volume})'
196
- format_volumeinfo: Volume information text format. default '{dt}\n\n거래량:    {volume}\n거래량증가율: {rate_volume}\n대비:     {compare}'
197
-
198
- limit_candle: Maximum number of candles to draw. default 800
199
- limit_wick: Maximum number of candle wicks to draw. default 4,000
200
- """
201
- pass
202
-
203
-
204
- class SliderChart(_BaseSliderChart):
205
- r"""
206
- You can see the guidance document:
207
- Korean: https://white.seolpyo.com/entry/147/
208
- English: https://white.seolpyo.com/entry/148/
209
-
210
- Quick Start:
211
- ```
212
- import seolpyo_mplchart as mc
213
- chart = mc.SliderChart() # Create instance
214
- chart.set_data(df) # set stock price data
215
- mc.show() # show chart(run ```matplotlib.pyplot.show()```)
216
- mc.close() # run ```matplotlib.pyplot.close('close')```
217
- ```
218
-
219
- Class Variables:
220
- watermark: watermark text.
221
-
222
- unit_price, unit_volume: price and volume unit. default ('원', '주').
223
- digit_price, digit_volume: display decimal places when displaying price and volume. default (0, 0),
224
-
225
- figsize: Default size when creating a matplotlib window
226
- slider_top: ax_slider is located at the top or bottom. default ```True```.
227
- ratio_ax_slider, ratio_ax_legend, ratio_ax_price, ratio_ax_volume: Axes ratio
228
- ratio_ax_none: Ratio between volume chart and slider. Used only when ```self.slider_top``` is ```False```
229
- adjust: figure adjust. default ```dict(top=0.95, bottom=0.05, left=0.01, right=0.93, wspace=0, hspace=0)```.
230
- color_background: color of background. default '#fafafa'.
231
- gridKwargs: kwargs applied to the grid
232
- color_tick, color_tick_label: Tick and tick label colors. default ('k', 'k').
233
-
234
- df: stock data DataFrame.
235
- date: date column key. default 'date'
236
- Open, high, low, close: price column key. default ('open', 'high', 'low', 'close')
237
- volume: volume column key. default 'volume'. If ```if self.volume``` is ```False```, the volume chart is not drawn.
238
-
239
- format_ma: moving average legend label format. default '{}일선'
240
- list_ma: Decide how many days to draw the moving average line. default (5, 20, 60, 120, 240)
241
- list_macolor: Color the moving average line. If the number of colors is greater than the moving average line, black is applied
242
-
243
- candle_on_ma: Decide whether to draw candles on the moving average line. default ```True```
244
- color_navigator_line: Color of left and right dividing lines in selected area
245
- color_navigator_cover: Color of unselected area.
246
-
247
- color_priceline: The color of the price line
248
-
249
- color_up: The color of the candle. When the closing price is greater than the opening price
250
- color_down: The color of the candle. When the opening price is greater than the opening price
251
- color_flat: The color of the candle. When the closing price is the same as the opening price
252
- color_up_down: The color of the candle. If the closing price is greater than the opening price, but is lower than the previous day's closing price
253
- color_down_up: The color of the candle. If the opening price is greater than the closing price, but is higher than the closing price of the previous day
254
- colors_volume: The color of the volume bar. default '#1f77b4'
255
-
256
- color_volume_up: The color of the volume. When the closing price is greater than the opening price
257
- color_volume_down: The color of the volume. When the opening price is greater than the opening price
258
- color_volume_flatt: The color of the volume. When the closing price is the same as the opening price
259
-
260
- candle_width_half, volume_width_half: half of the thickness of the candle and volume
261
-
262
- color_box: The color of the candlebox and volumebox. Used when the mouse is over a candle or volume bar. default 'k'
263
-
264
- lineKwargs: kwarg applied to lines drawn based on mouse cursor position
265
- textboxKwargs: kwarg applied to the info text bbox drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
266
- textKwargs: A kwarg that applies to the informational text drawn on the chart. When this is applied, the following occurs: ```textKwargs['bbox'] = textboxKwargs```
267
-
268
- fraction: Decide whether to express information as a fraction. default False
269
- format_candleinfo: Candle information text format. default '{dt}\n\n종가:  {close}\n등락률: {rate}\n대비:  {compare}\n시가:  {open}({rate_open})\n고가:  {high}({rate_high})\n저가:  {low}({rate_low})\n거래량: {volume}({rate_volume})'
270
- format_volumeinfo: Volume information text format. default '{dt}\n\n거래량:    {volume}\n거래량증가율: {rate_volume}\n대비:     {compare}'
271
-
272
- min_distance: Minimum number of candles that can be selected with the slider. default 30
273
- limit_candle: Maximum number of candles to draw. default 800
274
- limit_wick: Maximum number of candle wicks to draw. default 4,000
275
- limit_volume: Maximum number of volume bars to draw. default 200. Applies only to drawing candle wicks or price line.
276
- limit_ma: If the number of displayed data is more than this, the price moving average line is not drawn. default 8,000
277
-
278
- color_navigator_line: Navigator divider color. default '#1e78ff'
279
- color_navigator_cover: Unselected slider area color. default = 'k'
280
- """
281
- pass
282
-
283
-
284
- def set_theme(chart: SliderChart|CursorChart|OnlyChart, theme: Literal['light', 'dark']='dark'):
285
- initialized = hasattr(chart, 'ax_price')
286
-
287
- if theme == 'dark':
288
- chart.color_background = '#000000'
289
- chart.color_tick, chart.color_tick_label = ('w', 'w')
290
- chart.gridKwargs = {'color': '#FFFFFF'}
291
-
292
- chart.color_priceline = 'w'
293
- chart.color_up, chart.color_down = ('#00FF00', '#FF0000')
294
- chart.color_flat = 'w'
295
- chart.color_up_down, chart.color_down_up = ('#000000', '#000000')
296
-
297
- chart.color_volume_up, chart.color_volume_down = ('#32CD32', '#FF4500')
298
- chart.color_volume_flat = 'w'
299
-
300
- chart.list_macolor = ('#1E90FF', '#FFA500', '#FF1493', '#FFFF00', '#00CED1')
301
-
302
- chart.lineKwargs = {'edgecolor': 'w'}
303
- chart.color_box = 'w'
304
- chart.textboxKwargs = {'facecolor': 'k', 'edgecolor': 'w'}
305
- chart.textKwargs = {'color': 'w'}
306
- chart.color_navigator_cover, chart.color_navigator_line = ('k', '#FF2400')
307
-
308
- if initialized:
309
- chart.change_background_color('k')
310
- chart.change_tick_color('w')
311
- chart.change_line_color('w')
312
- if hasattr(chart, 'navigator'): chart.collection_navigator.set_edgecolor([chart.color_navigator_cover, chart.color_navigator_line])
313
-
314
- if hasattr(chart, 'df'):
315
- chart.set_data(chart.df, sort_df=False, calc_ma=False, set_candlecolor=True, set_volumecolor=True, calc_info=False, change_lim=False)
316
- chart.draw_canvas()
317
- elif theme == 'light':
318
- chart.color_background = '#fafafa'
319
- chart.color_tick, chart.color_tick_label = ('k', 'k')
320
- chart.gridKwargs = {'color': '#d0d0d0'}
321
-
322
- chart.color_priceline = 'k'
323
- chart.color_up, chart.color_down = ('#FF2400', '#1E90FF')
324
- chart.color_flat = 'k'
325
- chart.color_up_down, chart.color_down_up = ('w', 'w')
326
-
327
- chart.color_volume_up, chart.color_volume_down = ('#FF6666', '#5CA8F4')
328
- chart.color_volume_flat = '#808080'
329
-
330
- chart.list_macolor = ('#006400', '#8B008B', '#FFA500', '#0000FF', '#FF0000')
331
-
332
- chart.lineKwargs = {'edgecolor': 'k'}
333
- chart.color_box = 'k'
334
- chart.textboxKwargs = {'facecolor': 'w', 'edgecolor': 'k'}
335
- chart.textKwargs = {'color': 'k'}
336
- chart.color_navigator_cover, chart.color_navigator_line = ('k', '#1E78FF')
337
-
338
- if initialized:
339
- chart.change_background_color('#fafafa')
340
- chart.change_tick_color('k')
341
- chart.change_line_color('k')
342
- if hasattr(chart, 'navigator'): chart.collection_navigator.set_edgecolor([chart.color_navigator_cover, chart.color_navigator_line])
343
-
344
- if hasattr(chart, 'df'):
345
- chart.set_data(chart.df, sort_df=False, calc_ma=False, set_candlecolor=True, set_volumecolor=True, calc_info=False, change_lim=False)
346
- chart.draw_canvas()
347
- else: raise ValueError(f'You send wrong arg.\n{theme=}')
348
-
349
- return chart
@@ -0,0 +1,137 @@
1
+ from ._draw import Chart as _OC
2
+ from ._cursor import Chart as _CC
3
+ from ._slider import Chart as _SC
4
+
5
+
6
+
7
+ class OnlyChart(_OC):
8
+ r"""
9
+ You can see the guidance document:
10
+ Korean: https://white.seolpyo.com/entry/147/?from=package
11
+ English: https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/README.md
12
+
13
+ Quick Start:
14
+ ```
15
+ import seolpyo_mplchart as mc
16
+ chart = mc.SliderChart() # Create instance
17
+ chart.set_data(df) # set stock price data
18
+ mc.show() # show chart(run ```matplotlib.pyplot.show()```)
19
+ mc.close() # run ```matplotlib.pyplot.close('close')```
20
+ ```
21
+
22
+ Class Variables:
23
+ watermark: watermark text.
24
+
25
+ df: stock data DataFrame.
26
+ key_date: date column key. default 'date'
27
+ key_open, key_high, key_low, key_close: price column key. default ('open', 'high', 'low', 'close')
28
+ key_volume: volume column key. default 'volume'. If ```if config.VOLUME.EDGECOLOR.volume``` is ```False```, the volume chart is not drawn.
29
+
30
+ cnadle_on_ma: if True: draw candle above ma. else: draw candle below ma lines.
31
+ limit_candle: If (`the number of candles to draw < limit_candle or not limit_candle`): draw candles, else: draw wicks.
32
+ limit_wick: If (`the number of candles to draw < limit_wick or not limit_wick`): draw wicks, else: draw line.
33
+ limit_volume: If (`the number of candles to draw < limit_volume or not limit_volume`): draw volumebar, else: draw wicks.
34
+ limit_ma: If (`the number of candles to draw < limit_ma or not limit_ma`): draw ma lines, else: don't draw ma lines.
35
+ fraction: if True and number has a fractional part, display it as a fraction.
36
+ """
37
+ key_date = 'date'
38
+ key_open, key_high, key_low, key_close = ('open', 'high', 'low', 'close')
39
+ key_volume = 'volume'
40
+
41
+ candle_on_ma = True
42
+ limit_candle = 400
43
+ limit_wick = 2_000
44
+ limit_volume = 200
45
+ limit_ma = None
46
+ watermark = 'seolpyo mplchart'
47
+
48
+
49
+ class CursorChart(_CC):
50
+ r"""
51
+ You can see the guidance document:
52
+ Korean: https://white.seolpyo.com/entry/147/?from=package
53
+ English: https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/README.md
54
+
55
+ Quick Start:
56
+ ```
57
+ import seolpyo_mplchart as mc
58
+ chart = mc.SliderChart() # Create instance
59
+ chart.set_data(df) # set stock price data
60
+ mc.show() # show chart(run ```matplotlib.pyplot.show()```)
61
+ mc.close() # run ```matplotlib.pyplot.close('close')```
62
+ ```
63
+
64
+ Class Variables:
65
+ watermark: watermark
66
+
67
+ df: stock data DataFrame.
68
+ key_date: date column key. default 'date'
69
+ key_open, key_high, key_low, key_close: price column key. default ('open', 'high', 'low', 'close')
70
+ key_volume: volume column key. default 'volume'. If ```if config.VOLUME.EDGECOLOR.volume``` is ```False```, the volume chart is not drawn.
71
+
72
+ cnadle_on_ma: if True: draw candle above ma. else: draw candle below ma lines.
73
+ limit_candle: If (`the number of candles to draw < limit_candle or not limit_candle`): draw candles, else: draw wicks.
74
+ limit_wick: If (`the number of candles to draw < limit_wick or not limit_wick`): draw wicks, else: draw line.
75
+ limit_volume: If (`the number of candles to draw < limit_volume or not limit_volume`): draw volumebar, else: draw wicks.
76
+ limit_ma: If (`the number of candles to draw < limit_ma or not limit_ma`): draw ma lines, else: don't draw ma lines.
77
+ fraction: if True and number has a fractional part, display it as a fraction.
78
+ """
79
+ key_date = 'date'
80
+ key_open, key_high, key_low, key_close = ('open', 'high', 'low', 'close')
81
+ key_volume = 'volume'
82
+
83
+ candle_on_ma = True
84
+ limit_candle = 400
85
+ limit_wick = 2_000
86
+ limit_volume = 200
87
+ limit_ma = None
88
+ watermark = 'seolpyo mplchart'
89
+ fraction = False
90
+
91
+
92
+ class SliderChart(_SC):
93
+ r"""
94
+ You can see the guidance document:
95
+ Korean: https://white.seolpyo.com/entry/147/?from=package
96
+ English: https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/README.md
97
+
98
+ Quick Start:
99
+ ```
100
+ import seolpyo_mplchart as mc
101
+ chart = mc.SliderChart() # Create instance
102
+ chart.set_data(df) # set stock price data
103
+ mc.show() # show chart(run ```matplotlib.pyplot.show()```)
104
+ mc.close() # run ```matplotlib.pyplot.close('close')```
105
+ ```
106
+
107
+ Class Variables:
108
+ watermark: watermark text.
109
+
110
+ df: stock data DataFrame.
111
+ key_date: date column key. default 'date'
112
+ key_open, key_high, key_low, key_close: price column key. default ('open', 'high', 'low', 'close')
113
+ key_volume: volume column key. default 'volume'. If ```if config.VOLUME.EDGECOLOR.volume``` is ```False```, the volume chart is not drawn.
114
+
115
+ cnadle_on_ma: if True: draw candle above ma. else: draw candle below ma lines.
116
+ limit_candle: If (`the number of candles to draw < limit_candle or not limit_candle`): draw candles, else: draw wicks.
117
+ limit_wick: If (`the number of candles to draw < limit_wick or not limit_wick`): draw wicks, else: draw line.
118
+ limit_volume: If (`the number of candles to draw < limit_volume or not limit_volume`): draw volumebar, else: draw wicks.
119
+ limit_ma: If (`the number of candles to draw < limit_ma or not limit_ma`): draw ma lines, else: don't draw ma lines.
120
+ fraction: if True and number has a fractional part, display it as a fraction.
121
+ slider_top: set slider position. if True: slider top. else: bottom
122
+ min_distance: the minimum number of candles displayed on the screen.
123
+ """
124
+ key_date = 'date'
125
+ key_open, key_high, key_low, key_close = ('open', 'high', 'low', 'close')
126
+ key_volume = 'volume'
127
+
128
+ candle_on_ma = True
129
+ limit_candle = 400
130
+ limit_wick = 2_000
131
+ limit_volume = 200
132
+ limit_ma = 8_000
133
+ watermark = 'seolpyo mplchart'
134
+ fraction = False
135
+ slider_top = True
136
+ min_distance = 5
137
+