seolpyo-mplchart 1.4.1__py3-none-any.whl → 2.1.0__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 (83) hide show
  1. seolpyo_mplchart/__init__.py +53 -333
  2. seolpyo_mplchart/_chart/__init__.py +145 -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/base/__init__.py +111 -0
  19. seolpyo_mplchart/_chart/base/a_canvas.py +250 -0
  20. seolpyo_mplchart/_chart/base/b_artist.py +143 -0
  21. seolpyo_mplchart/_chart/base/c_draw.py +100 -0
  22. seolpyo_mplchart/_chart/base/d_segment.py +262 -0
  23. seolpyo_mplchart/_chart/base/e_axis.py +267 -0
  24. seolpyo_mplchart/_chart/base/f_background.py +62 -0
  25. seolpyo_mplchart/_chart/base/g_event.py +66 -0
  26. seolpyo_mplchart/_chart/base/h_data.py +138 -0
  27. seolpyo_mplchart/_chart/base/test.py +58 -0
  28. seolpyo_mplchart/_chart/cursor/__init__.py +125 -0
  29. seolpyo_mplchart/_chart/cursor/b_artist.py +130 -0
  30. seolpyo_mplchart/_chart/cursor/c_draw.py +96 -0
  31. seolpyo_mplchart/_chart/cursor/d_segment.py +359 -0
  32. seolpyo_mplchart/_chart/cursor/e_axis.py +65 -0
  33. seolpyo_mplchart/_chart/cursor/g_event.py +233 -0
  34. seolpyo_mplchart/_chart/cursor/h_data.py +61 -0
  35. seolpyo_mplchart/_chart/cursor/test.py +69 -0
  36. seolpyo_mplchart/_chart/slider/__init__.py +169 -0
  37. seolpyo_mplchart/_chart/slider/a_canvas.py +260 -0
  38. seolpyo_mplchart/_chart/slider/b_artist.py +91 -0
  39. seolpyo_mplchart/_chart/slider/c_draw.py +54 -0
  40. seolpyo_mplchart/_chart/slider/d_segment.py +166 -0
  41. seolpyo_mplchart/_chart/slider/e_axis.py +70 -0
  42. seolpyo_mplchart/_chart/slider/f_background.py +37 -0
  43. seolpyo_mplchart/_chart/slider/g_event.py +353 -0
  44. seolpyo_mplchart/_chart/slider/h_data.py +102 -0
  45. seolpyo_mplchart/_chart/slider/test.py +71 -0
  46. seolpyo_mplchart/_chart/test.py +121 -0
  47. seolpyo_mplchart/_config/__init__.py +3 -0
  48. seolpyo_mplchart/_config/ax.py +28 -0
  49. seolpyo_mplchart/_config/candle.py +31 -0
  50. seolpyo_mplchart/_config/config.py +21 -0
  51. seolpyo_mplchart/_config/cursor.py +49 -0
  52. seolpyo_mplchart/_config/figure.py +40 -0
  53. seolpyo_mplchart/_config/format.py +51 -0
  54. seolpyo_mplchart/_config/ma.py +17 -0
  55. seolpyo_mplchart/_config/slider/__init__.py +2 -0
  56. seolpyo_mplchart/_config/slider/config.py +24 -0
  57. seolpyo_mplchart/_config/slider/figure.py +19 -0
  58. seolpyo_mplchart/_config/slider/nav.py +10 -0
  59. seolpyo_mplchart/_config/unit.py +19 -0
  60. seolpyo_mplchart/_config/utils.py +67 -0
  61. seolpyo_mplchart/_config/volume.py +27 -0
  62. seolpyo_mplchart/_cursor.py +27 -25
  63. seolpyo_mplchart/_draw.py +7 -18
  64. seolpyo_mplchart/_slider.py +26 -20
  65. seolpyo_mplchart/_utils/__init__.py +10 -0
  66. seolpyo_mplchart/_utils/nums.py +67 -0
  67. seolpyo_mplchart/_utils/theme/__init__.py +15 -0
  68. seolpyo_mplchart/_utils/theme/dark.py +57 -0
  69. seolpyo_mplchart/_utils/theme/light.py +56 -0
  70. seolpyo_mplchart/_utils/utils.py +28 -0
  71. seolpyo_mplchart/_utils/xl/__init__.py +15 -0
  72. seolpyo_mplchart/_utils/xl/csv.py +46 -0
  73. seolpyo_mplchart/_utils/xl/xlsx.py +49 -0
  74. seolpyo_mplchart/sample/apple.txt +6058 -0
  75. seolpyo_mplchart/sample/samsung.txt +5938 -0
  76. seolpyo_mplchart/test.py +172 -56
  77. seolpyo_mplchart/xl_to_dict.py +47 -0
  78. seolpyo_mplchart-2.1.0.dist-info/METADATA +718 -0
  79. seolpyo_mplchart-2.1.0.dist-info/RECORD +89 -0
  80. {seolpyo_mplchart-1.4.1.dist-info → seolpyo_mplchart-2.1.0.dist-info}/WHEEL +1 -1
  81. seolpyo_mplchart-1.4.1.dist-info/METADATA +0 -57
  82. seolpyo_mplchart-1.4.1.dist-info/RECORD +0 -17
  83. {seolpyo_mplchart-1.4.1.dist-info → seolpyo_mplchart-2.1.0.dist-info}/top_level.txt +0 -0
@@ -2,348 +2,68 @@ import json
2
2
  from typing import Literal
3
3
  from pathlib import Path
4
4
 
5
- import matplotlib.pyplot as plt
6
- import pandas as pd
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
11
-
12
-
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
- ]
21
-
22
-
23
- path_samsung = Path(__file__).parent / 'sample/samsung.txt'
24
- path_apple = Path(__file__).parent / 'sample/apple.txt'
5
+ from ._chart import OnlyChart, CursorChart, SliderChart
6
+ from ._config import (
7
+ ConfigData, DEFAULTCONFIG, DEFAULTCONFIG_EN,
8
+ SliderConfigData, SLIDERCONFIG, SLIDERCONFIG_EN,
9
+ )
10
+ from ._utils import (
11
+ float_to_str,
12
+ xl_to_dataList,
13
+ convert_num,
14
+ float_to_str,
15
+ convert_unit, convert_unit_en,
16
+ data_unit_ko, data_unit_en,
17
+ list_to_DataFrame,
18
+ show, close,
19
+ switch_backend,
20
+ )
21
+
22
+
23
+ # __all__ = [
24
+ # 'path_samsung', 'path_apple',
25
+ # 'format_candleinfo_ko', 'format_volumeinfo_ko',
26
+ # 'format_candleinfo_en', 'format_volumeinfo_en',
27
+ # 'sample', 'switch_backend', 'show', 'close',
28
+ # 'OnlyChart', 'CursorChart', 'SliderChart',
29
+ # 'set_theme',
30
+ # ]
31
+
32
+
33
+ pkg_name = 'seolpyo_mplchart'
34
+ path_pkg = Path(__file__)
35
+ while path_pkg.name != pkg_name:
36
+ path_pkg = path_pkg.parent
37
+ path_samsung = path_pkg / 'sample' / 'samsung.txt'
38
+ path_apple = path_pkg / 'sample' / 'apple.txt'
25
39
 
26
40
  def sample(stock: Literal['samsung', 'apple']='samsung', chart: Literal['Chart', 'CursorChart', 'SliderChart']='SliderChart'):
27
- C: _BaseSliderChart = {'Chart': _BaseChart, 'CursorChart': _BaseCursorChart, 'SliderChart': _BaseSliderChart}[chart]()
41
+ d = {
42
+ 'Chart': OnlyChart,
43
+ 'CursorChart': CursorChart,
44
+ 'SliderChart': SliderChart,
45
+ }
46
+ C = d[chart]
28
47
  path_file = path_samsung if stock == 'samsung' else path_apple
29
48
  if stock == 'samsung':
30
- C.format_candleinfo = format_candleinfo_ko
31
- C.format_volumeinfo = format_volumeinfo_ko
49
+ if chart == 'SliderChart':
50
+ config = SLIDERCONFIG
51
+ else:
52
+ config = DEFAULTCONFIG
32
53
  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{}'
54
+ if chart == 'SliderChart':
55
+ config = SLIDERCONFIG_EN
56
+ else:
57
+ config = DEFAULTCONFIG_EN
58
+
59
+ CHART: SliderChart = C(config)
39
60
 
40
61
  with open(path_file, 'r', encoding='utf-8') as txt:
41
62
  data = json.load(txt)
42
- df = pd.DataFrame(data)
43
-
44
- C.set_data(df)
45
-
46
- show()
47
- close()
48
- return
49
-
63
+ df = list_to_DataFrame(data)
50
64
 
51
- def switch_backend(newbackend='TkAgg'):
52
- "call matplotlib.pyplot.switch_backend(newbackend)"
53
- return plt.switch_backend(newbackend)
65
+ CHART.set_data(df)
54
66
 
55
-
56
- def show(Close=False):
57
- """
58
- call matplotlib.pyplot.show()
59
- ```if Close``` if True, run matplotlib.pyplot.close('all') after window closee.
60
- """
61
- plt.show()
62
- if Close: close()
67
+ show(Close=True)
63
68
  return
64
69
 
65
-
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'
125
-
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,145 @@
1
+ import pandas as pd
2
+
3
+ from .cursor import Chart as _CC, BaseChart as _OC
4
+ from .slider import Chart as _SC
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
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
+ df: stock data DataFrame.
24
+ key_date: date column key. default 'date'
25
+ key_open, key_high, key_low, key_close: price column key. default ('open', 'high', 'low', 'close')
26
+ key_volume: volume column key. default 'volume'. If ```if config.VOLUME.EDGECOLOR.volume``` is ```False```, the volume chart is not drawn.
27
+
28
+ candle_on_ma: if True: draw candle above ma. else: draw candle below ma lines.
29
+
30
+ limit_candle: If (`the number of candles to draw < limit_candle or not limit_candle`): draw candles, else: draw wicks.
31
+ limit_wick: If (`the number of candles to draw < limit_wick or not limit_wick`): draw wicks, else: draw line.
32
+
33
+ watermark: watermark text.
34
+ """
35
+ df: pd.DataFrame
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
+
43
+ watermark = 'seolpyo mplchart'
44
+
45
+ limit_candle = 400
46
+ limit_wick = 2_000
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
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
+ df: stock data DataFrame.
66
+ key_date: date column key. default 'date'
67
+ key_open, key_high, key_low, key_close: price column key. default ('open', 'high', 'low', 'close')
68
+ key_volume: volume column key. default 'volume'. If ```if config.VOLUME.EDGECOLOR.volume``` is ```False```, the volume chart is not drawn.
69
+
70
+ candle_on_ma: if True: draw candle above ma. else: draw candle below ma lines.
71
+ fraction: if True and number has a fractional part, display it as a fraction.
72
+
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
+
76
+ watermark: watermark
77
+ """
78
+ df: pd.DataFrame
79
+
80
+ key_date = 'date'
81
+ key_open, key_high, key_low, key_close = ('open', 'high', 'low', 'close')
82
+ key_volume = 'volume'
83
+
84
+ candle_on_ma = True
85
+ fraction = False
86
+
87
+ watermark = 'seolpyo mplchart'
88
+
89
+ limit_candle = 400
90
+ limit_wick = 2_000
91
+
92
+
93
+ class SliderChart(_SC):
94
+ r"""
95
+ You can see the guidance document:
96
+ Korean: https://white.seolpyo.com/entry/147/?from=package
97
+ English: https://github.com/white-seolpyo/seolpyo-mplchart
98
+
99
+ Quick Start:
100
+ ```
101
+ import seolpyo_mplchart as mc
102
+ chart = mc.SliderChart() # Create instance
103
+ chart.set_data(df) # set stock price data
104
+ mc.show() # show chart(run ```matplotlib.pyplot.show()```)
105
+ mc.close() # run ```matplotlib.pyplot.close('close')```
106
+ ```
107
+
108
+ Class Variables:
109
+ watermark: watermark text.
110
+
111
+ df: stock data DataFrame.
112
+ key_date: date column key. default 'date'
113
+ key_open, key_high, key_low, key_close: price column key. default ('open', 'high', 'low', 'close')
114
+ key_volume: volume column key. default 'volume'. If ```if config.VOLUME.EDGECOLOR.volume``` is ```False```, the volume chart is not drawn.
115
+
116
+ candle_on_ma: if True: draw candle above ma. else: draw candle below ma lines.
117
+ fraction: if True and number has a fractional part, display it as a fraction.
118
+ slider_top: set slider position. if True: slider top. else: bottom
119
+
120
+ limit_candle: If (`the number of candles to draw < limit_candle or not limit_candle`): draw candles, else: draw wicks.
121
+ limit_wick: If (`the number of candles to draw < limit_wick or not limit_wick`): draw wicks, else: draw line.
122
+ limit_volume: If (`the number of candles to draw < limit_volume or not limit_volume`): draw volumebar, else: draw wicks.
123
+ limit_ma: If (`the number of candles to draw < limit_ma or not limit_ma`): draw ma lines, else: don't draw ma lines.
124
+
125
+ min_distance: the minimum number of candles displayed on the screen.
126
+ """
127
+ df: pd.DataFrame
128
+
129
+ key_date = 'date'
130
+ key_open, key_high, key_low, key_close = ('open', 'high', 'low', 'close')
131
+ key_volume = 'volume'
132
+
133
+ candle_on_ma = True
134
+ fraction = False
135
+ slider_top = True
136
+
137
+ watermark = 'seolpyo mplchart'
138
+
139
+ limit_candle = 400
140
+ limit_wick = 2_000
141
+ limit_volume = 200
142
+ limit_ma = 8_000
143
+
144
+ min_distance = 5
145
+