seolpyo-mplchart 2.0.0__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 (70) hide show
  1. seolpyo_mplchart-2.1.0/MANIFEST.in +1 -0
  2. {seolpyo_mplchart-2.0.0/seolpyo_mplchart.egg-info → seolpyo_mplchart-2.1.0}/PKG-INFO +22 -14
  3. {seolpyo_mplchart-2.0.0 → seolpyo_mplchart-2.1.0}/README.md +21 -13
  4. {seolpyo_mplchart-2.0.0 → seolpyo_mplchart-2.1.0}/pyproject.toml +4 -2
  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.0.0/seolpyo_mplchart/xl_to_dict.py → seolpyo_mplchart-2.1.0/seolpyo_mplchart/_utils/xl/xlsx.py +4 -2
  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.0.0 → seolpyo_mplchart-2.1.0}/seolpyo_mplchart/test.py +5 -5
  62. {seolpyo_mplchart-2.0.0 → seolpyo_mplchart-2.1.0/seolpyo_mplchart.egg-info}/PKG-INFO +22 -14
  63. seolpyo_mplchart-2.1.0/seolpyo_mplchart.egg-info/SOURCES.txt +65 -0
  64. seolpyo_mplchart-2.0.0/MANIFEST.in +0 -1
  65. seolpyo_mplchart-2.0.0/seolpyo_mplchart/__init__.py +0 -185
  66. seolpyo_mplchart-2.0.0/seolpyo_mplchart.egg-info/SOURCES.txt +0 -11
  67. {seolpyo_mplchart-2.0.0 → seolpyo_mplchart-2.1.0}/seolpyo_mplchart.egg-info/dependency_links.txt +0 -0
  68. {seolpyo_mplchart-2.0.0 → seolpyo_mplchart-2.1.0}/seolpyo_mplchart.egg-info/requires.txt +0 -0
  69. {seolpyo_mplchart-2.0.0 → seolpyo_mplchart-2.1.0}/seolpyo_mplchart.egg-info/top_level.txt +0 -0
  70. {seolpyo_mplchart-2.0.0 → seolpyo_mplchart-2.1.0}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ recursive-include seolpyo_mplchart *
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seolpyo-mplchart
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: Fast candlestick chart using Python. Includes navigator, slider, navigation, and text information display functions
5
5
  Author-email: white-seolpyo <white-seolpyo@naver.com>
6
6
  License: MIT License
@@ -32,7 +32,7 @@ Ethereum: 0x1c5fb8a5e0b1153cd4116c91736bd16fabf83520
32
32
 
33
33
 
34
34
  # Document
35
- [English Document](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/README.md)
35
+ [English Document](https://github.com/white-seolpyo/seolpyo-mplchart/tree/maind)
36
36
 
37
37
  [한글 설명서](https://white.seolpyo.com/entry/147/?from=pypi)
38
38
 
@@ -43,14 +43,14 @@ Ethereum: 0x1c5fb8a5e0b1153cd4116c91736bd16fabf83520
43
43
  reference version
44
44
  ----
45
45
 
46
- 2.0.0
46
+ 2.1.0
47
47
 
48
48
  Package Introduction
49
49
  ------
50
50
 
51
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
52
 
53
- Sample Charts with Over 40,000 Stock Price Data Points
53
+ Sample Charts with Over 40,000 Stock Price Data Points, with Intel i5 4690
54
54
 
55
55
  seolpyo-mplchart is a Python package built on top of matplotlib.
56
56
 
@@ -70,7 +70,7 @@ While libraries like finplot and plotly are commonly used to draw candlestick ch
70
70
 
71
71
  You can check out a sample of drawing candlestick charts integrated with tkinter at the following link:
72
72
 
73
- [View tkinter sample code](https://white.seolpyo.com//entry/214/)
73
+ [View tkinter sample code](https://white.seolpyo.com/entry/214/)
74
74
 
75
75
  ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/with%20tkinter.gif?raw=true)
76
76
 
@@ -144,10 +144,10 @@ If not provided, the predefined CONFIG\* settings will be used.
144
144
  \* CONFIG: mc.DEFAULTCONFIG(OnlyChart, CursorChart) 또는 mc.SLIDERCONFIG(SliderChart)
145
145
 
146
146
 
147
- #### wartermark
147
+ #### watermark
148
148
 
149
149
  Watermark text displayed at the center of the chart.
150
- If if not self.wartermark evaluates to true, the watermark will not be rendered.
150
+ If if not self.watermark evaluates to true, the watermark will not be rendered.
151
151
 
152
152
 
153
153
  #### candle\_on\_ma
@@ -283,14 +283,20 @@ Determines whether the mouse cursor is located within the volume chart area.
283
283
 
284
284
  Creates a chart object.
285
285
 
286
- #### Chart.set\_data(df)
286
+ #### Chart.set_data(df, change_xlim=True)
287
287
 
288
288
  Passes stock price data to the chart object.
289
289
  The chart object generates chart data based on the received input.
290
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
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.
292
293
 
293
294
 
295
+
296
+ #### Chart.get_default_xlim()
297
+
298
+ It retrieves the xlim values set when Chart.set_data() is called.
299
+
294
300
  #### Chart.refresh()
295
301
 
296
302
  Refreshes the chart.
@@ -416,8 +422,8 @@ Predefined keyword arguments are passed via **kwargs.
416
422
 
417
423
  def get_info_kwargs(self, is_price, **kwargs):
418
424
  if is_price:
419
- kwargs['ci'] = 'You can add Custom text Info or Change text info.'
420
- kwargs['close'] = 'You can Change close price info.'
425
+ kwargs['ci'] = 'this is custom add info kwargs'
426
+ kwargs['close'] = 'Cusotom close value'
421
427
  return kwargs
422
428
 
423
429
  C = Chart()
@@ -428,6 +434,8 @@ Predefined keyword arguments are passed via **kwargs.
428
434
 
429
435
  mc.show()
430
436
 
437
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/change%20text%20info.png?raw=true)
438
+
431
439
  #### Chart.on\_draw(e)
432
440
 
433
441
  Method called when the draw event is triggered.
@@ -487,7 +495,7 @@ CONFIG applied to SliderChart.
487
495
 
488
496
  CONFIG applied to SliderChart, with the price unit set to $, the volume unit set to Vol, and the formatting based on English conventions.
489
497
 
490
-
498
+ ```
491
499
  # seolpyo_mplchart/_config/slider/config.py
492
500
 
493
501
  from .. import config
@@ -513,9 +521,9 @@ CONFIG applied to SliderChart, with the price unit set to $, the volume unit set
513
521
  SLIDERCONFIG_EN: SliderConfigData = config.DEFAULTCONFIG_EN
514
522
  SLIDERCONFIG_EN.FIGURE = FIGURE
515
523
  SLIDERCONFIG_EN.SLIDER = SLIDER
516
-
517
-
524
+ ```
518
525
 
526
+ ```
519
527
  # seolpyo_mplchart/_config/config.py
520
528
 
521
529
  from . import figure, ax, candle, volume, ma, unit, cursor, format
@@ -538,7 +546,7 @@ CONFIG applied to SliderChart, with the price unit set to $, the volume unit set
538
546
  DEFAULTCONFIG_EN.UNIT = unit.UNIT_EN
539
547
  DEFAULTCONFIG_EN.MA = ma.MA_EN
540
548
  DEFAULTCONFIG_EN.FORMAT = format.FORMAT_EN
541
-
549
+ ```
542
550
 
543
551
 
544
552
  # Others
@@ -5,7 +5,7 @@ Ethereum: 0x1c5fb8a5e0b1153cd4116c91736bd16fabf83520
5
5
 
6
6
 
7
7
  # Document
8
- [English Document](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/README.md)
8
+ [English Document](https://github.com/white-seolpyo/seolpyo-mplchart/tree/maind)
9
9
 
10
10
  [한글 설명서](https://white.seolpyo.com/entry/147/?from=pypi)
11
11
 
@@ -16,14 +16,14 @@ Ethereum: 0x1c5fb8a5e0b1153cd4116c91736bd16fabf83520
16
16
  reference version
17
17
  ----
18
18
 
19
- 2.0.0
19
+ 2.1.0
20
20
 
21
21
  Package Introduction
22
22
  ------
23
23
 
24
24
  ![](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)
25
25
 
26
- Sample Charts with Over 40,000 Stock Price Data Points
26
+ Sample Charts with Over 40,000 Stock Price Data Points, with Intel i5 4690
27
27
 
28
28
  seolpyo-mplchart is a Python package built on top of matplotlib.
29
29
 
@@ -43,7 +43,7 @@ While libraries like finplot and plotly are commonly used to draw candlestick ch
43
43
 
44
44
  You can check out a sample of drawing candlestick charts integrated with tkinter at the following link:
45
45
 
46
- [View tkinter sample code](https://white.seolpyo.com//entry/214/)
46
+ [View tkinter sample code](https://white.seolpyo.com/entry/214/)
47
47
 
48
48
  ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/with%20tkinter.gif?raw=true)
49
49
 
@@ -117,10 +117,10 @@ If not provided, the predefined CONFIG\* settings will be used.
117
117
  \* CONFIG: mc.DEFAULTCONFIG(OnlyChart, CursorChart) 또는 mc.SLIDERCONFIG(SliderChart)
118
118
 
119
119
 
120
- #### wartermark
120
+ #### watermark
121
121
 
122
122
  Watermark text displayed at the center of the chart.
123
- If if not self.wartermark evaluates to true, the watermark will not be rendered.
123
+ If if not self.watermark evaluates to true, the watermark will not be rendered.
124
124
 
125
125
 
126
126
  #### candle\_on\_ma
@@ -256,14 +256,20 @@ Determines whether the mouse cursor is located within the volume chart area.
256
256
 
257
257
  Creates a chart object.
258
258
 
259
- #### Chart.set\_data(df)
259
+ #### Chart.set_data(df, change_xlim=True)
260
260
 
261
261
  Passes stock price data to the chart object.
262
262
  The chart object generates chart data based on the received input.
263
263
  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.
264
264
  Therefore, these keys should be properly set before calling set\_data.
265
+ `if change_lim is True`, it retrieves the values from Chart.get_default_lim() and updates the xlim accordingly.
265
266
 
266
267
 
268
+
269
+ #### Chart.get_default_xlim()
270
+
271
+ It retrieves the xlim values set when Chart.set_data() is called.
272
+
267
273
  #### Chart.refresh()
268
274
 
269
275
  Refreshes the chart.
@@ -389,8 +395,8 @@ Predefined keyword arguments are passed via **kwargs.
389
395
 
390
396
  def get_info_kwargs(self, is_price, **kwargs):
391
397
  if is_price:
392
- kwargs['ci'] = 'You can add Custom text Info or Change text info.'
393
- kwargs['close'] = 'You can Change close price info.'
398
+ kwargs['ci'] = 'this is custom add info kwargs'
399
+ kwargs['close'] = 'Cusotom close value'
394
400
  return kwargs
395
401
 
396
402
  C = Chart()
@@ -401,6 +407,8 @@ Predefined keyword arguments are passed via **kwargs.
401
407
 
402
408
  mc.show()
403
409
 
410
+ ![](https://github.com/white-seolpyo/seolpyo-mplchart/blob/main/images/change%20text%20info.png?raw=true)
411
+
404
412
  #### Chart.on\_draw(e)
405
413
 
406
414
  Method called when the draw event is triggered.
@@ -460,7 +468,7 @@ CONFIG applied to SliderChart.
460
468
 
461
469
  CONFIG applied to SliderChart, with the price unit set to $, the volume unit set to Vol, and the formatting based on English conventions.
462
470
 
463
-
471
+ ```
464
472
  # seolpyo_mplchart/_config/slider/config.py
465
473
 
466
474
  from .. import config
@@ -486,9 +494,9 @@ CONFIG applied to SliderChart, with the price unit set to $, the volume unit set
486
494
  SLIDERCONFIG_EN: SliderConfigData = config.DEFAULTCONFIG_EN
487
495
  SLIDERCONFIG_EN.FIGURE = FIGURE
488
496
  SLIDERCONFIG_EN.SLIDER = SLIDER
489
-
490
-
497
+ ```
491
498
 
499
+ ```
492
500
  # seolpyo_mplchart/_config/config.py
493
501
 
494
502
  from . import figure, ax, candle, volume, ma, unit, cursor, format
@@ -511,7 +519,7 @@ CONFIG applied to SliderChart, with the price unit set to $, the volume unit set
511
519
  DEFAULTCONFIG_EN.UNIT = unit.UNIT_EN
512
520
  DEFAULTCONFIG_EN.MA = ma.MA_EN
513
521
  DEFAULTCONFIG_EN.FORMAT = format.FORMAT_EN
514
-
522
+ ```
515
523
 
516
524
 
517
525
  # Others
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "seolpyo-mplchart"
11
- version = "2.0.0"
11
+ version = "2.1.0"
12
12
  dependencies = [
13
13
  "matplotlib >= 3.7.0",
14
14
  "pandas >= 2.0.0",
@@ -49,6 +49,8 @@ Issues = "https://github.com/white-seolpyo/seolpyo-mplchart/issues"
49
49
  [tool.setuptools]
50
50
  packages = [
51
51
  "seolpyo_mplchart",
52
- "seolpyo_mplchart.sample",
52
+ "seolpyo_mplchart._chart",
53
+ "seolpyo_mplchart._config",
54
+ "seolpyo_mplchart._utils",
53
55
  ]
54
56
 
@@ -0,0 +1,69 @@
1
+ import json
2
+ from typing import Literal
3
+ from pathlib import Path
4
+
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'
39
+
40
+ def sample(stock: Literal['samsung', 'apple']='samsung', chart: Literal['Chart', 'CursorChart', 'SliderChart']='SliderChart'):
41
+ d = {
42
+ 'Chart': OnlyChart,
43
+ 'CursorChart': CursorChart,
44
+ 'SliderChart': SliderChart,
45
+ }
46
+ C = d[chart]
47
+ path_file = path_samsung if stock == 'samsung' else path_apple
48
+ if stock == 'samsung':
49
+ if chart == 'SliderChart':
50
+ config = SLIDERCONFIG
51
+ else:
52
+ config = DEFAULTCONFIG
53
+ else:
54
+ if chart == 'SliderChart':
55
+ config = SLIDERCONFIG_EN
56
+ else:
57
+ config = DEFAULTCONFIG_EN
58
+
59
+ CHART: SliderChart = C(config)
60
+
61
+ with open(path_file, 'r', encoding='utf-8') as txt:
62
+ data = json.load(txt)
63
+ df = list_to_DataFrame(data)
64
+
65
+ CHART.set_data(df)
66
+
67
+ show(Close=True)
68
+ return
69
+
@@ -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
+
@@ -0,0 +1,111 @@
1
+ from matplotlib.axes import Axes
2
+ from matplotlib.collections import LineCollection
3
+ from matplotlib.text import Text
4
+ from matplotlib.axes import Axes
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ from ..._config import DEFAULTCONFIG, ConfigData
9
+
10
+ from .a_canvas import CanvasMixin, Figure
11
+ from .b_artist import ArtistMixin
12
+ from .c_draw import DrawMixin
13
+ from .d_segment import SegmentMixin
14
+ from .e_axis import AxisMixin
15
+ from .f_background import BackgroundMixin
16
+ from .g_event import EventMixin
17
+ from .h_data import DataMixin
18
+
19
+
20
+ class Chart(
21
+ CanvasMixin,
22
+ ArtistMixin,
23
+ DrawMixin,
24
+ SegmentMixin,
25
+ AxisMixin,
26
+ BackgroundMixin,
27
+ EventMixin,
28
+ DataMixin,
29
+ ):
30
+ limit_candle = 400
31
+ limit_wick = 2_000
32
+ candle_on_ma = True
33
+
34
+ key_date = 'date'
35
+ key_open, key_high, key_low, key_close = ('open', 'high', 'low', 'close')
36
+ key_volume = 'volume'
37
+
38
+ index_list: list[int] = []
39
+
40
+ df: pd.DataFrame
41
+
42
+ CONFIG: ConfigData
43
+
44
+ figure: Figure
45
+ ax_legend: Axes
46
+ ax_price: Axes
47
+ ax_volume: Axes
48
+
49
+ artist_watermark: Text
50
+ collection_candle: LineCollection
51
+ collection_volume: LineCollection
52
+ collection_ma: LineCollection
53
+
54
+ ###
55
+
56
+ segment_volume: np.ndarray
57
+ segment_volume_wick: np.ndarray
58
+ facecolor_volume: np.ndarray
59
+ edgecolor_volume: np.ndarray
60
+
61
+ segment_candle: np.ndarray
62
+ segment_candle_wick: np.ndarray
63
+ segment_priceline: np.ndarray
64
+ facecolor_candle: np.ndarray
65
+ edgecolor_candle: np.ndarray
66
+
67
+ segment_ma: np.ndarray
68
+ edgecolor_ma: np.ndarray
69
+
70
+ price_ymin: int
71
+ price_ymax: int
72
+ volume_ymax: int
73
+
74
+ chart_price_ymax: float
75
+ chart_volume_ymax: float
76
+
77
+ vxmin: int
78
+ vxmax: int
79
+
80
+ ###
81
+
82
+ _visible_ma: set[int] = set()
83
+
84
+ _background = None
85
+ _background_background = None
86
+ _creating_background = False
87
+
88
+ def __init__(self, config=DEFAULTCONFIG):
89
+ self.CONFIG = config
90
+ super().__init__()
91
+
92
+ self.add_artists()
93
+ self.connect_events()
94
+ return
95
+
96
+ def refresh(self):
97
+ self.set_artists()
98
+
99
+ self.set_candle_segments()
100
+ self.set_color_segments()
101
+ ma_alpha = self.collection_ma.get_alpha()
102
+ # print(f'{ma_alpha=}')
103
+ if ma_alpha is not None:
104
+ self.collection_ma.set_alpha([1 for _ in ma_alpha])
105
+
106
+ self.axis(self.vxmin, xmax=self.vxmax-1)
107
+
108
+ self.set_canvas()
109
+ self.figure.canvas.draw()
110
+ return
111
+