plotguy 2.0.1__tar.gz → 2.0.4__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.
- {plotguy-2.0.1 → plotguy-2.0.4}/PKG-INFO +2 -2
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy/__init__.py +4 -1
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy/components.py +1 -101
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy/equity_curves.py +0 -1
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy.egg-info/PKG-INFO +2 -2
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy.egg-info/requires.txt +1 -1
- {plotguy-2.0.1 → plotguy-2.0.4}/setup.py +2 -2
- {plotguy-2.0.1 → plotguy-2.0.4}/README.md +0 -0
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy/aggregate.py +0 -0
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy/signals.py +0 -0
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy.egg-info/SOURCES.txt +0 -0
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy.egg-info/dependency_links.txt +0 -0
- {plotguy-2.0.1 → plotguy-2.0.4}/plotguy.egg-info/top_level.txt +0 -0
- {plotguy-2.0.1 → plotguy-2.0.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotguy
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Plotguy
|
|
5
5
|
Home-page: https://pypi.org/project/plotguy/
|
|
6
6
|
Author: Plotguy Team
|
|
@@ -9,7 +9,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
9
9
|
Classifier: Operating System :: OS Independent
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
Requires-Dist: pandas==2.3.3
|
|
12
|
-
Requires-Dist:
|
|
12
|
+
Requires-Dist: stepuptools
|
|
13
13
|
Requires-Dist: numpy==2.4.2
|
|
14
14
|
Requires-Dist: hkfdb
|
|
15
15
|
Requires-Dist: pyarrow==23.0.0
|
|
@@ -10,7 +10,6 @@ import time
|
|
|
10
10
|
import zlib
|
|
11
11
|
import requests
|
|
12
12
|
import pandas as pd
|
|
13
|
-
import polars as pl
|
|
14
13
|
import numpy as np
|
|
15
14
|
|
|
16
15
|
from .equity_curves import *
|
|
@@ -161,6 +160,8 @@ def save_backtest_result(df, para_combination_item):
|
|
|
161
160
|
|
|
162
161
|
if len(df_count) == 0:
|
|
163
162
|
num_of_trade = 0
|
|
163
|
+
|
|
164
|
+
equity_net_profit = 0
|
|
164
165
|
equity_return_on_capital = 0
|
|
165
166
|
equity_annualized_return = 0
|
|
166
167
|
equity_annualized_std = 0
|
|
@@ -278,6 +279,7 @@ def save_backtest_result(df, para_combination_item):
|
|
|
278
279
|
'equity_annualized_std': equity_annualized_std,
|
|
279
280
|
'equity_annualized_sr': equity_annualized_sr,
|
|
280
281
|
'equity_net_profit_to_mdd': equity_net_profit_to_mdd,
|
|
282
|
+
|
|
281
283
|
'equity_mdd_dollar': equity_mdd_dollar,
|
|
282
284
|
'equity_mdd_pct': equity_mdd_pct,
|
|
283
285
|
|
|
@@ -287,6 +289,7 @@ def save_backtest_result(df, para_combination_item):
|
|
|
287
289
|
'price_annualized_std': price_annualized_std,
|
|
288
290
|
'price_annualized_sr': price_annualized_sr,
|
|
289
291
|
'price_net_profit_to_mdd': price_net_profit_to_mdd,
|
|
292
|
+
|
|
290
293
|
'price_mdd_dollar': price_mdd_dollar,
|
|
291
294
|
'price_mdd_pct': price_mdd_pct,
|
|
292
295
|
|
|
@@ -9,7 +9,6 @@ import datetime
|
|
|
9
9
|
|
|
10
10
|
import pandas as pd
|
|
11
11
|
import numpy as np
|
|
12
|
-
import polars as pl
|
|
13
12
|
|
|
14
13
|
import math
|
|
15
14
|
import json
|
|
@@ -22,7 +21,7 @@ import plotly.express as px
|
|
|
22
21
|
import plotly.graph_objs as go
|
|
23
22
|
from plotly.subplots import make_subplots
|
|
24
23
|
|
|
25
|
-
import plotguy
|
|
24
|
+
#import plotguy
|
|
26
25
|
#import dash_dangerously_set_inner_html # for all Plot Class
|
|
27
26
|
|
|
28
27
|
|
|
@@ -105,7 +104,6 @@ class Components:
|
|
|
105
104
|
|
|
106
105
|
return fig_line
|
|
107
106
|
|
|
108
|
-
|
|
109
107
|
def update_checkbox_div(self, para_keys, backtest_result_df):
|
|
110
108
|
checkbox_values = {}
|
|
111
109
|
|
|
@@ -221,7 +219,6 @@ class Components:
|
|
|
221
219
|
|
|
222
220
|
return div
|
|
223
221
|
|
|
224
|
-
|
|
225
222
|
def generate_radioitems(self, para_dict):
|
|
226
223
|
radioitems_div = []
|
|
227
224
|
|
|
@@ -252,7 +249,6 @@ class Components:
|
|
|
252
249
|
|
|
253
250
|
return title
|
|
254
251
|
|
|
255
|
-
|
|
256
252
|
def update_performance_matrix(self, init_chart, para_keys_list, result_df, line_selected = 0):
|
|
257
253
|
|
|
258
254
|
if init_chart:
|
|
@@ -490,7 +486,6 @@ class Components:
|
|
|
490
486
|
|
|
491
487
|
return matrix_div
|
|
492
488
|
|
|
493
|
-
|
|
494
489
|
filter_options = {
|
|
495
490
|
'num_of_trade':'Number of Trade',
|
|
496
491
|
'equity_return_on_capital': 'Return on Capital',
|
|
@@ -527,7 +522,6 @@ class Components:
|
|
|
527
522
|
|
|
528
523
|
return filter_btn
|
|
529
524
|
|
|
530
|
-
|
|
531
525
|
def generate_sorted_df(self, sort_method, df_checked, number_of_curves):
|
|
532
526
|
|
|
533
527
|
if sort_method == 'Top Sharpe Ratio':
|
|
@@ -551,7 +545,6 @@ class Components:
|
|
|
551
545
|
|
|
552
546
|
return df_checked
|
|
553
547
|
|
|
554
|
-
|
|
555
548
|
def assign_colour(self, profile, degree):
|
|
556
549
|
if profile == 0: rgb = (0, int(252 - 252 * degree), 252)
|
|
557
550
|
elif profile == 1: rgb = (int(252 - 252 * degree), 252, 0)
|
|
@@ -561,94 +554,6 @@ class Components:
|
|
|
561
554
|
elif profile == 5: rgb = (int(252 * degree), 0, 252)
|
|
562
555
|
return 'rgb' + str(rgb)
|
|
563
556
|
|
|
564
|
-
def generate_chart_3(self, para_combination, chart3_start, chart3_end, freq):
|
|
565
|
-
|
|
566
|
-
data_folder = para_combination['data_folder']
|
|
567
|
-
code = para_combination['code']
|
|
568
|
-
start_date = para_combination['start_date']
|
|
569
|
-
end_date = para_combination['end_date']
|
|
570
|
-
data_path = os.path.join(data_folder, f'{code}_{freq}.parquet')
|
|
571
|
-
|
|
572
|
-
df = pd.read_parquet(data_path) # Daraframe that may not be daily
|
|
573
|
-
|
|
574
|
-
df = df.reset_index(drop=False)
|
|
575
|
-
|
|
576
|
-
df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d')
|
|
577
|
-
df['datetime'] = pd.to_datetime(df['datetime'], format='%Y-%m-%d %H:%M:%S')
|
|
578
|
-
df = df.loc[(df['date'] >= chart3_start) & (df['date'] <= chart3_end)]
|
|
579
|
-
|
|
580
|
-
# grab first and last observations from df.date and make a continuous date range from that
|
|
581
|
-
dt_all = pd.date_range(start=df['datetime'].iloc[0], end=df['datetime'].iloc[-1], freq=freq)
|
|
582
|
-
# check which dates from your source that also accur in the continuous date range
|
|
583
|
-
dt_obs = [d.strftime("%Y-%m-%d %H:%M:%S") for d in df['datetime']]
|
|
584
|
-
# isolate missing timestamps
|
|
585
|
-
dt_breaks = [d for d in dt_all.strftime("%Y-%m-%d %H:%M:%S").tolist() if not d in dt_obs]
|
|
586
|
-
|
|
587
|
-
###### chagne ######
|
|
588
|
-
save_path = plotguy.generate_save_path(para_combination=para_combination)
|
|
589
|
-
df_signal_list = plotguy.read_daily_df(save_path, start_date, end_date, freq)
|
|
590
|
-
####################
|
|
591
|
-
|
|
592
|
-
df_signal_list = df_signal_list.loc[
|
|
593
|
-
(df_signal_list['date'] >= chart3_start) & (df_signal_list['date'] <= chart3_end)]
|
|
594
|
-
|
|
595
|
-
df_open = df_signal_list.loc[df_signal_list['action'] == 'open']
|
|
596
|
-
df_profit = df_signal_list.loc[df_signal_list['action'] == 'profit_target']
|
|
597
|
-
df_stop_loss = df_signal_list.loc[df_signal_list['action'] == 'stop_loss']
|
|
598
|
-
df_close = df_signal_list.loc[df_signal_list['action'] == 'close_logic']
|
|
599
|
-
df_close = df_signal_list.loc[df_signal_list['action'] == 'close_logic']
|
|
600
|
-
|
|
601
|
-
fig = go.Figure(data=[go.Candlestick(x=df['datetime'],
|
|
602
|
-
open=df['open'],
|
|
603
|
-
high=df['high'],
|
|
604
|
-
low=df['low'],
|
|
605
|
-
close=df['close'],
|
|
606
|
-
increasing_line_color='white')
|
|
607
|
-
])
|
|
608
|
-
|
|
609
|
-
fig.update_layout(title = {'text': 'Candlestick Chart' , 'font': {'size': 12 } })
|
|
610
|
-
|
|
611
|
-
fig.update_xaxes(rangebreaks=[dict(dvalue=15 * 60 * 1000, values=dt_breaks)])
|
|
612
|
-
|
|
613
|
-
fig.add_trace(go.Scatter(mode='markers',
|
|
614
|
-
#x=df_open['datetime'], y=df_open['close'], # visible='legendonly',
|
|
615
|
-
x=df_open.index, y=df_open['close'], # visible='legendonly',
|
|
616
|
-
marker=dict(color='rgba(0, 0, 0, 0)', size=18,
|
|
617
|
-
line=dict(color='yellow', width=2.5)), name='Open'))
|
|
618
|
-
fig.add_trace(go.Scatter(mode='markers',
|
|
619
|
-
#x=df_profit['datetime'], y=df_profit['close'], # visible='legendonly',
|
|
620
|
-
x=df_profit.index, y=df_profit['close'], # visible='legendonly',
|
|
621
|
-
marker=dict(color='rgba(0, 0, 0, 0)', size=18,
|
|
622
|
-
line=dict(color='Cyan', width=2.5)), name='Profit Target'))
|
|
623
|
-
fig.add_trace(go.Scatter(mode='markers',
|
|
624
|
-
#x=df_stop_loss['datetime'], y=df_stop_loss['close'], # visible='legendonly',
|
|
625
|
-
x=df_stop_loss.index, y=df_stop_loss['close'], # visible='legendonly',
|
|
626
|
-
marker=dict(color='rgba(0, 0, 0, 0)', size=18,
|
|
627
|
-
line=dict(color='Cyan', width=2.5)), name='Stop Loss'))
|
|
628
|
-
fig.add_trace(go.Scatter(mode='markers',
|
|
629
|
-
#x=df_close['datetime'], y=df_close['close'], # visible='legendonly',
|
|
630
|
-
x=df_close.index, y=df_close['close'], # visible='legendonly',
|
|
631
|
-
marker=dict(color='rgba(0, 0, 0, 0)', size=18,
|
|
632
|
-
line=dict(color='Cyan', width=2.5)), name='Close Logic'))
|
|
633
|
-
|
|
634
|
-
fig.update_layout(xaxis_rangeslider_visible=True)
|
|
635
|
-
|
|
636
|
-
chart_bg = '#1f2c56'
|
|
637
|
-
fig.update_layout(plot_bgcolor=chart_bg, paper_bgcolor=chart_bg, height=500,
|
|
638
|
-
margin=dict(l=85, r=25, t=60, b=0),
|
|
639
|
-
showlegend=True,
|
|
640
|
-
font={"color": "white", 'size': 10.5}, yaxis={'title': 'Equity'},
|
|
641
|
-
xaxis={'title': ''}
|
|
642
|
-
)
|
|
643
|
-
fig.update_xaxes(showline=True, zeroline=False, linecolor='#979A9A', gridcolor=chart_bg)
|
|
644
|
-
fig.update_yaxes(showline=True, zeroline=False, linecolor='#979A9A', gridcolor=chart_bg)
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
return fig
|
|
650
|
-
|
|
651
|
-
|
|
652
557
|
def generate_main_chart(self, graph_df, backtest_name, equity_curve_folder, para_keys_list):
|
|
653
558
|
|
|
654
559
|
|
|
@@ -719,8 +624,6 @@ class Components:
|
|
|
719
624
|
|
|
720
625
|
return fig_line
|
|
721
626
|
|
|
722
|
-
|
|
723
|
-
|
|
724
627
|
def generate_stra_alys_chart(self, intraday, graph_df, line_selected,
|
|
725
628
|
para_keys_list, backtest_result_dict):
|
|
726
629
|
|
|
@@ -850,7 +753,6 @@ class Components:
|
|
|
850
753
|
|
|
851
754
|
return fig_line
|
|
852
755
|
|
|
853
|
-
|
|
854
756
|
### for class signal ###
|
|
855
757
|
def generate_df_stat(self, df, period):
|
|
856
758
|
col_pct = 'pct_change_' + str(period)
|
|
@@ -874,7 +776,6 @@ class Components:
|
|
|
874
776
|
|
|
875
777
|
return round(df_his[col_pct].mean(), 2), round(df_his[col_rise].mean(), 2), round(df_his[col_fall].mean(), 2)
|
|
876
778
|
|
|
877
|
-
|
|
878
779
|
def aggregate_df(self):
|
|
879
780
|
all_str_dir = []
|
|
880
781
|
for folder_name in os.listdir():
|
|
@@ -1119,7 +1020,6 @@ class Components:
|
|
|
1119
1020
|
|
|
1120
1021
|
return df_show_agg, row
|
|
1121
1022
|
|
|
1122
|
-
|
|
1123
1023
|
def aggregate_performance(self, total_dict, year_list, risk_free_rate):
|
|
1124
1024
|
num_of_trade = "{:,}".format(int(total_dict['num_of_trade']))
|
|
1125
1025
|
net_profit = "{:,}".format(int(round(total_dict['net_profit'],0)) )
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotguy
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Plotguy
|
|
5
5
|
Home-page: https://pypi.org/project/plotguy/
|
|
6
6
|
Author: Plotguy Team
|
|
@@ -9,7 +9,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
9
9
|
Classifier: Operating System :: OS Independent
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
Requires-Dist: pandas==2.3.3
|
|
12
|
-
Requires-Dist:
|
|
12
|
+
Requires-Dist: stepuptools
|
|
13
13
|
Requires-Dist: numpy==2.4.2
|
|
14
14
|
Requires-Dist: hkfdb
|
|
15
15
|
Requires-Dist: pyarrow==23.0.0
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="plotguy",
|
|
8
|
-
version="2.0.
|
|
8
|
+
version="2.0.4",
|
|
9
9
|
author="Plotguy Team",
|
|
10
10
|
author_email="plotguy.info@gmail.com",
|
|
11
11
|
description="Plotguy",
|
|
@@ -13,7 +13,7 @@ setuptools.setup(
|
|
|
13
13
|
long_description_content_type="text/markdown",
|
|
14
14
|
install_requires=[
|
|
15
15
|
'pandas==2.3.3',
|
|
16
|
-
'
|
|
16
|
+
'stepuptools',
|
|
17
17
|
'numpy==2.4.2',
|
|
18
18
|
'hkfdb',
|
|
19
19
|
'pyarrow==23.0.0',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|