Skip to content

Commit 07684af

Browse files
committed
add comments and remove unneeded variable
1 parent 5e9152b commit 07684af

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/mplfinance/_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,12 @@ def _construct_pf_collections(dates, highs, lows, volumes, config_tip_params, cl
499499
new_dates = [] # holds the dates corresponding with the index
500500
new_volumes = [] # holds the volumes corresponding with the index. If more than one index for the same day then they all have the same volume.
501501
box_values = [] # y values for the boxes
502-
circle_patches = []
502+
circle_patches = [] # list of circle patches to be used to create the cirCollection
503503
line_seg = [] # line segments that make up the Xs
504504

505505
volume_cache = 0 # holds the volumes for the dates that were skipped
506-
index = -1
507-
last_trend_positive = True
506+
index = -1 # only incremented when difference > 0
507+
508508
for diff_index, difference in enumerate(cdiff):
509509
diff = abs(int(round(difference, 0)))
510510
if volumes is not None: # only adds volumes if there are volume values when volume=True
@@ -522,8 +522,7 @@ def _construct_pf_collections(dates, highs, lows, volumes, config_tip_params, cl
522522

523523

524524
sign = (difference / abs(difference)) # -1 or 1
525-
start_iteration = 0 if sign > 0 else 1
526-
start_iteration += 0 if (last_trend_positive and sign > 0) or (not last_trend_positive and sign < 0) else 1
525+
start_iteration = 0 if sign > 0 else 2
527526

528527
x = [index] * (diff)
529528
y = [(curr_price + ((i+(box_size * 0.005)) * box_size * sign)) for i in range(start_iteration, diff+start_iteration)]
@@ -549,6 +548,7 @@ def _construct_pf_collections(dates, highs, lows, volumes, config_tip_params, cl
549548
cirCollection = PatchCollection(circle_patches)
550549
cirCollection.set_facecolor([tfc] * len(circle_patches))
551550
cirCollection.set_edgecolor([dc] * len(circle_patches))
551+
552552
xCollection = LineCollection(line_seg,
553553
colors=[uc] * len(line_seg),
554554
linewidths=lw,

0 commit comments

Comments
 (0)