seolpyo-mplchart 1.1.0__tar.gz → 1.2.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 (17) hide show
  1. {seolpyo_mplchart-1.1.0/seolpyo_mplchart.egg-info → seolpyo_mplchart-1.2.0}/PKG-INFO +1 -1
  2. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/pyproject.toml +1 -1
  3. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/seolpyo_mplchart/__init__.py +11 -11
  4. seolpyo_mplchart-1.1.0/seolpyo_mplchart/cursor.py → seolpyo_mplchart-1.2.0/seolpyo_mplchart/_cursor.py +10 -5
  5. seolpyo_mplchart-1.1.0/seolpyo_mplchart/draw.py → seolpyo_mplchart-1.2.0/seolpyo_mplchart/_draw.py +24 -16
  6. seolpyo_mplchart-1.1.0/seolpyo_mplchart/slider.py → seolpyo_mplchart-1.2.0/seolpyo_mplchart/_slider.py +7 -4
  7. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0/seolpyo_mplchart.egg-info}/PKG-INFO +1 -1
  8. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/seolpyo_mplchart.egg-info/SOURCES.txt +4 -4
  9. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/MANIFEST.in +0 -0
  10. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/README.md +0 -0
  11. /seolpyo_mplchart-1.1.0/seolpyo_mplchart/base.py → /seolpyo_mplchart-1.2.0/seolpyo_mplchart/_base.py +0 -0
  12. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/seolpyo_mplchart/test.py +0 -0
  13. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/seolpyo_mplchart/utils.py +0 -0
  14. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/seolpyo_mplchart.egg-info/dependency_links.txt +0 -0
  15. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/seolpyo_mplchart.egg-info/requires.txt +0 -0
  16. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/seolpyo_mplchart.egg-info/top_level.txt +0 -0
  17. {seolpyo_mplchart-1.1.0 → seolpyo_mplchart-1.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: seolpyo-mplchart
3
- Version: 1.1.0
3
+ Version: 1.2.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
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "seolpyo-mplchart"
11
- version = "1.1.0"
11
+ version = "1.2.0"
12
12
  dependencies = [
13
13
  "matplotlib >= 3.7.0",
14
14
  "pandas >= 2.0.0",
@@ -5,9 +5,9 @@ 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 ._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
11
 
12
12
 
13
13
  __all__ = [
@@ -24,7 +24,7 @@ path_samsung = Path(__file__).parent / 'sample/samsung.txt'
24
24
  path_apple = Path(__file__).parent / 'sample/apple.txt'
25
25
 
26
26
  def sample(stock: Literal['samsung', 'apple']='samsung', chart: Literal['Chart', 'CursorChart', 'SliderChart']='SliderChart'):
27
- C: BaseSliderChart = {'Chart': BaseChart, 'CursorChart': BaseCursorChart, 'SliderChart': BaseSliderChart}[chart]()
27
+ C: _BaseSliderChart = {'Chart': _BaseChart, 'CursorChart': _BaseCursorChart, 'SliderChart': _BaseSliderChart}[chart]()
28
28
  path_file = path_samsung if stock == 'samsung' else path_apple
29
29
  if stock == 'samsung':
30
30
  C.format_candleinfo = format_candleinfo_ko
@@ -68,7 +68,7 @@ def close(fig='all'):
68
68
  return plt.close(fig)
69
69
 
70
70
 
71
- class OnlyChart(BaseChart):
71
+ class OnlyChart(_BaseChart):
72
72
  r"""
73
73
  You can see the guidance document:
74
74
  Korean: https://white.seolpyo.com/entry/147/
@@ -129,7 +129,7 @@ class OnlyChart(BaseChart):
129
129
  pass
130
130
 
131
131
 
132
- class CursorChart(BaseCursorChart):
132
+ class CursorChart(_BaseCursorChart):
133
133
  r"""
134
134
  You can see the guidance document:
135
135
  Korean: https://white.seolpyo.com/entry/147/
@@ -193,7 +193,7 @@ class CursorChart(BaseCursorChart):
193
193
 
194
194
  fraction: Decide whether to express information as a fraction. default False
195
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}'
196
+ format_volumeinfo: Volume information text format. default '{dt}\n\n거래량:    {volume}\n거래량증가율: {rate_volume}\n대비:     {compare}'
197
197
 
198
198
  limit_candle: Maximum number of candles to draw. default 800
199
199
  limit_wick: Maximum number of candle wicks to draw. default 4,000
@@ -201,7 +201,7 @@ class CursorChart(BaseCursorChart):
201
201
  pass
202
202
 
203
203
 
204
- class SliderChart(BaseSliderChart):
204
+ class SliderChart(_BaseSliderChart):
205
205
  r"""
206
206
  You can see the guidance document:
207
207
  Korean: https://white.seolpyo.com/entry/147/
@@ -267,12 +267,12 @@ class SliderChart(BaseSliderChart):
267
267
 
268
268
  fraction: Decide whether to express information as a fraction. default False
269
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}'
270
+ format_volumeinfo: Volume information text format. default '{dt}\n\n거래량:    {volume}\n거래량증가율: {rate_volume}\n대비:     {compare}'
271
271
 
272
272
  min_distance: Minimum number of candles that can be selected with the slider. default 30
273
273
  limit_candle: Maximum number of candles to draw. default 800
274
274
  limit_wick: Maximum number of candle wicks to draw. default 4,000
275
- limit_volume: Maximum number of volume bars to draw. default 800. Applies only to drawing candle wicks or price line.
275
+ limit_volume: Maximum number of volume bars to draw. default 200. Applies only to drawing candle wicks or price line.
276
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
277
 
278
278
  color_navigator_line: Navigator divider color. default '#1e78ff'
@@ -303,7 +303,7 @@ def set_theme(chart: OnlyChart|CursorChart|SliderChart, theme: Literal['light',
303
303
  chart.color_box = 'w'
304
304
  chart.textboxKwargs = {'facecolor': 'k', 'edgecolor': 'w'}
305
305
  chart.textKwargs = {'color': 'w'}
306
- chart.color_navigator_cover, chart.color_navigator_line = ('w', '#00FFFF')
306
+ chart.color_navigator_cover, chart.color_navigator_line = ('w', '#FF2400')
307
307
 
308
308
  if initialized:
309
309
  chart.change_background_color('k')
@@ -6,7 +6,7 @@ from matplotlib.collections import LineCollection
6
6
  from matplotlib.text import Text
7
7
  import pandas as pd
8
8
 
9
- from .draw import BaseMixin as BM, Mixin as M
9
+ from ._draw import BaseMixin as BM, Mixin as M
10
10
  from .utils import float_to_str
11
11
 
12
12
 
@@ -129,7 +129,9 @@ class DataMixin(CollectionMixin):
129
129
  self.df['rate_open'] = ((self.df[self.Open] - self.df['_pre']) / self.df[self.close] * 100).__round__(2).fillna(0)
130
130
  self.df['rate_high'] = ((self.df[self.high] - self.df['_pre']) / self.df[self.close] * 100).__round__(2).fillna(0)
131
131
  self.df['rate_low'] = ((self.df[self.low] - self.df['_pre']) / self.df[self.close] * 100).__round__(2).fillna(0)
132
- if self.volume: self.df['rate_volume'] = ((self.df[self.volume] - self.df[self.volume].shift(1)) / self.df[self.volume].shift(1) * 100).__round__(2).fillna(0)
132
+ if self.volume:
133
+ self.df['compare_volume'] = (self.df[self.volume] - self.df[self.volume].shift(1)).fillna(0)
134
+ self.df['rate_volume'] = (self.df['compare_volume'] / self.df[self.volume].shift(1) * 100).__round__(2).fillna(0)
133
135
 
134
136
  self.df['_boxheight'] = (self.df[self.high] - self.df[self.low]) / 5
135
137
  self.df['_boxmin'] = self.df[self.low] - self.df['_boxheight']
@@ -305,9 +307,9 @@ class LineMixin(EventMixin):
305
307
 
306
308
 
307
309
  format_candleinfo_ko = '{dt}\n\n종가:  {close}\n등락률: {rate}\n대비:  {compare}\n시가:  {open}({rate_open})\n고가:  {high}({rate_high})\n저가:  {low}({rate_low})\n거래량: {volume}({rate_volume})'
308
- format_volumeinfo_ko = '{dt}\n\n거래량   : {volume}\n거래량증가율: {rate_volume}'
310
+ format_volumeinfo_ko = '{dt}\n\n거래량:    {volume}\n거래량증가율: {rate_volume}\n대비:     {compare}'
309
311
  format_candleinfo_en = '{dt}\n\nclose: {close}\nrate: {rate}\ncompare: {compare}\nopen: {open}({rate_open})\nhigh: {high}({rate_high})\nlow: {low}({rate_low})\nvolume: {volume}({rate_volume})'
310
- format_volumeinfo_en = '{dt}\n\nvolume: {volume}\nvolume rate: {rate_volume}'
312
+ format_volumeinfo_en = '{dt}\n\nvolume: {volume}\nvolume rate: {rate_volume}\ncompare: {compare}'
311
313
 
312
314
  class InfoMixin(LineMixin):
313
315
  fraction = False
@@ -425,10 +427,13 @@ class InfoMixin(LineMixin):
425
427
  volume=f'{v:>{self._length_text}}{self.unit_volume}', rate_volume=vr,
426
428
  )
427
429
  elif self.volume:
430
+ compare = self.df['compare_volume'][index]
431
+ com = float_to_str(compare, self.digit_volume, plus=True)
428
432
  text = self.format_volumeinfo.format(
429
433
  dt=dt,
430
434
  volume=f'{v:>{self._length_text}}{self.unit_volume}',
431
435
  rate_volume=f'{vr:>{self._length_text}}%',
436
+ compare=f'{com:>{self._length_text}}{self.unit_volume}',
432
437
  )
433
438
  else: text = ''
434
439
  return text
@@ -441,7 +446,7 @@ class BaseMixin(InfoMixin):
441
446
  class Chart(BaseMixin, Mixin):
442
447
  def _add_collection(self):
443
448
  super()._add_collection()
444
- return self.add_collection()
449
+ return self.add_artist()
445
450
 
446
451
  def _draw_artist(self):
447
452
  super()._draw_artist()
@@ -6,11 +6,11 @@ import numpy as np
6
6
  import pandas as pd
7
7
 
8
8
 
9
- from .base import Base
9
+ from ._base import Base
10
10
 
11
11
 
12
12
  class Mixin:
13
- def add_collection(self):
13
+ def add_artist(self):
14
14
  "This method work when ```__init__()``` run."
15
15
  return
16
16
 
@@ -182,7 +182,7 @@ class SegmentMixin(DataMixin):
182
182
 
183
183
  limit_candle = 800
184
184
  limit_wick = 4_000
185
- limit_volume = 800
185
+ limit_volume = 200
186
186
 
187
187
  color_priceline = 'k'
188
188
  format_ma = '{}일선'
@@ -348,15 +348,19 @@ class SegmentMixin(DataMixin):
348
348
  self.collection_candle.set_edgecolor(self.edgecolor_candle[index_start:index_end])
349
349
 
350
350
  if self.volume:
351
- seg = self.segment_volume_wick[index_start:index_end]
351
+ seg_volume = self.segment_volume_wick[index_start:index_end]
352
+ seg_facecolor_volume = self.facecolor_volume[index_start:index_end]
353
+ seg_edgecolor_volume = self.edgecolor_volume[index_start:index_end]
352
354
  if simpler:
353
- values = seg[:, 1, 1]
355
+ values = seg_volume[:, 1, 1]
354
356
  top_index = np.argsort(-values)[:self.limit_volume]
355
- seg = seg[top_index]
356
- self.collection_volume.set_segments(seg)
357
+ seg_volume = seg_volume[top_index]
358
+ seg_facecolor_volume = seg_facecolor_volume[top_index]
359
+ seg_edgecolor_volume = seg_edgecolor_volume[top_index]
360
+ self.collection_volume.set_segments(seg_volume)
357
361
  self.collection_volume.set_linewidth(1.3)
358
- self.collection_volume.set_facecolor(self.facecolor_volume[index_start:index_end])
359
- self.collection_volume.set_edgecolor(self.facecolor_volume[index_start:index_end])
362
+ self.collection_volume.set_facecolor(seg_facecolor_volume)
363
+ self.collection_volume.set_edgecolor(seg_edgecolor_volume)
360
364
 
361
365
  self.collection_ma.set_segments(self.segment_ma[:, index_start:index_end])
362
366
  self.collection_ma.set_edgecolor(self.edgecolor_ma)
@@ -368,15 +372,19 @@ class SegmentMixin(DataMixin):
368
372
  self.collection_candle.set_edgecolor(self.color_priceline)
369
373
 
370
374
  if self.volume:
371
- seg = self.segment_volume_wick[index_start:index_end]
375
+ seg_volume = self.segment_volume_wick[index_start:index_end]
376
+ seg_facecolor_volume = self.facecolor_volume[index_start:index_end]
377
+ seg_edgecolor_volume = self.edgecolor_volume[index_start:index_end]
372
378
  if simpler:
373
- values = seg[:, 1, 1]
379
+ values = seg_volume[:, 1, 1]
374
380
  top_index = np.argsort(-values)[:self.limit_volume]
375
- seg = seg[top_index]
376
- self.collection_volume.set_segments(seg)
381
+ seg_volume = seg_volume[top_index]
382
+ seg_facecolor_volume = seg_facecolor_volume[top_index]
383
+ seg_edgecolor_volume = seg_edgecolor_volume[top_index]
384
+ self.collection_volume.set_segments(seg_volume)
377
385
  self.collection_volume.set_linewidth(1.3)
378
- self.collection_volume.set_facecolor(self.facecolor_volume[index_start:index_end])
379
- self.collection_volume.set_edgecolor(self.facecolor_volume[index_start:index_end])
386
+ self.collection_volume.set_facecolor(seg_facecolor_volume)
387
+ self.collection_volume.set_edgecolor(seg_edgecolor_volume)
380
388
 
381
389
  if not set_ma: self.collection_ma.set_segments([])
382
390
  else:
@@ -548,7 +556,7 @@ class BaseMixin(BackgroundMixin):
548
556
  class Chart(BaseMixin, Mixin):
549
557
  def _add_collection(self):
550
558
  super()._add_collection()
551
- return self.add_collection()
559
+ return self.add_artist()
552
560
 
553
561
  def _draw_artist(self):
554
562
  super()._draw_artist()
@@ -5,8 +5,8 @@ from matplotlib.text import Text
5
5
  from matplotlib.backend_bases import MouseEvent, MouseButton, cursors
6
6
  import pandas as pd
7
7
 
8
- from .base import convert_unit
9
- from .cursor import BaseMixin as BM, Mixin as M
8
+ from ._base import convert_unit
9
+ from ._cursor import BaseMixin as BM, Mixin as M
10
10
 
11
11
 
12
12
  class Mixin(M):
@@ -163,6 +163,7 @@ class CollectionMixin(PlotMixin):
163
163
  super().change_line_color(color)
164
164
 
165
165
  self.text_slider.get_bbox_patch().set_edgecolor(color)
166
+ self.slider_vline.set_edgecolor(color)
166
167
  return
167
168
 
168
169
 
@@ -239,7 +240,9 @@ class DataMixin(NavigatorMixin):
239
240
 
240
241
  def get_default_lim(self):
241
242
  xmax = self.list_index[-1]
242
- return (xmax-120, xmax)
243
+ xmin = xmax - 120
244
+ if xmin < 0: xmin = 0
245
+ return (xmin, xmax)
243
246
 
244
247
 
245
248
  class BackgroundMixin(DataMixin):
@@ -558,7 +561,7 @@ class BaseMixin(ChartClickMixin):
558
561
  class Chart(BaseMixin, Mixin):
559
562
  def _add_collection(self):
560
563
  super()._add_collection()
561
- return self.add_collection()
564
+ return self.add_artist()
562
565
 
563
566
  def _draw_artist(self):
564
567
  super()._draw_artist()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: seolpyo-mplchart
3
- Version: 1.1.0
3
+ Version: 1.2.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
@@ -2,10 +2,10 @@ MANIFEST.in
2
2
  README.md
3
3
  pyproject.toml
4
4
  seolpyo_mplchart/__init__.py
5
- seolpyo_mplchart/base.py
6
- seolpyo_mplchart/cursor.py
7
- seolpyo_mplchart/draw.py
8
- seolpyo_mplchart/slider.py
5
+ seolpyo_mplchart/_base.py
6
+ seolpyo_mplchart/_cursor.py
7
+ seolpyo_mplchart/_draw.py
8
+ seolpyo_mplchart/_slider.py
9
9
  seolpyo_mplchart/test.py
10
10
  seolpyo_mplchart/utils.py
11
11
  seolpyo_mplchart.egg-info/PKG-INFO