Skip to content

Commit

Permalink
Fix issues with latest python version
Browse files Browse the repository at this point in the history
Issue 1: Panda has depricated .append() function.  Fix this by using
	Dataframe's loc function

Issue 2: Label object in bokeh has depricated `render_mode` attribute,
	so remove that in object initilization

Issue 3: plot_width in figure objest is depricated, use width instead.

Issue 4: Dataframe.drop() has also attribute changes, fix this by only
	passing colomn name.

Signed-off-by: Wyes Karny <[email protected]>
  • Loading branch information
wkarny committed Oct 15, 2023
1 parent 64d5566 commit 61d2ced
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
51 changes: 25 additions & 26 deletions pytrendline/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,32 +344,31 @@ def detect_wrapped(tt):

score = config.get("scoring_function", DEFAULT_CONFIG["scoring_function"])(candlestick_data, err_distances, num_points, slope)

trends_df = trends_df.append({
'id': pointset_id,
'trendtype': tt,
'pointset_indeces':points_in_trendline,
'pointset_dates': [candlestick_data.df.iloc[pt].Date for pt in points_in_trendline],
'starts_at_index': points_in_trendline[0],
'starts_at_date': candlestick_data.df.iloc[points_in_trendline[0]].Date,
'ends_at_index': points_in_trendline[-1],
'ends_at_date': candlestick_data.df.iloc[points_in_trendline[-1]].Date,
'is_breakout': is_breakout,
'breakout_index': breakout_index,
'breakout_date': breakout_date,
'num_points': num_points,
'm': m,
'b': b,
'slope': slope,
'price_at_last_date': trend_price_at_last,
'score': score,
'global_maxs_or_mins': global_max_or_mins,
'includes_global_max_or_min': global_pt_found,
'price_at_next_future_date': trend_price_at_last + m,
'duplicate_group_id': None,
'is_best_from_duplicate_group': False,
'overall_rank': None,
'rank_within_group': 0
}, ignore_index=True)
trends_df.loc[len(trends_df.index)] = [
pointset_id,
tt,
points_in_trendline,
[candlestick_data.df.iloc[pt].Date for pt in points_in_trendline],
points_in_trendline[0],
candlestick_data.df.iloc[points_in_trendline[0]].Date,
points_in_trendline[-1],
candlestick_data.df.iloc[points_in_trendline[-1]].Date,
is_breakout,
breakout_index,
breakout_date,
num_points,
m,
b,
slope,
trend_price_at_last,
score,
global_pt_found,
global_max_or_mins,
trend_price_at_last + m,
None,
False,
None,
0]

# Mark which of the trendlines are duplicate
trends_df = _mark_duplicates(trends_df, candlestick_data, tt, config)
Expand Down
6 changes: 3 additions & 3 deletions pytrendline/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def plot_figure(self, p, candles_df, opts={}):
label_y_pos = tl_y_at_last_date + (2 * m)

label = Label(x=label_x_pos, y=label_y_pos,
text=label_text, render_mode='css',
text=label_text,
border_line_color=color, border_line_alpha=0.8,
background_fill_color='white', background_fill_alpha=1.0)
p.segment(
Expand Down Expand Up @@ -255,7 +255,7 @@ def plot_graph_bokeh(results):
p = figure(
x_axis_type="datetime",
tools="pan,wheel_zoom,tap,crosshair,hover,poly_draw,reset,save",
plot_width=1300,
width=1300,
title=site_title,
y_range=(y_range_top, y_range_bottom),
x_range=(x_range_left, x_range_right),
Expand Down Expand Up @@ -308,7 +308,7 @@ def plot_table_bokeh(results):
all_results = results['resistance_trendlines']

if len(all_results) > 0:
html_trends_table = all_results.drop('pointset_dates', 1).to_html(border=0, header=True, index=False, justify="left", float_format=lambda x: '%10.3f' % x)
html_trends_table = all_results.drop(columns='pointset_dates').to_html(border=0, header=True, index=False, justify="left", float_format=lambda x: '%10.3f' % x)
else:
html_trends_table = '<p>No trendlines found</p>'

Expand Down

0 comments on commit 61d2ced

Please sign in to comment.