plotguy 2.1.9__tar.gz → 2.2.1__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.1.9 → plotguy-2.2.1}/PKG-INFO +2 -2
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy/__init__.py +41 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy/components.py +71 -68
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy.egg-info/PKG-INFO +2 -2
- {plotguy-2.1.9 → plotguy-2.2.1}/setup.py +2 -2
- {plotguy-2.1.9 → plotguy-2.2.1}/README.md +0 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy/aggregate.py +0 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy/equity_curves.py +0 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy/signals.py +0 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy.egg-info/SOURCES.txt +0 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy.egg-info/dependency_links.txt +0 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy.egg-info/requires.txt +1 -1
- {plotguy-2.1.9 → plotguy-2.2.1}/plotguy.egg-info/top_level.txt +0 -0
- {plotguy-2.1.9 → plotguy-2.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotguy
|
|
3
|
-
Version: 2.1
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Plotguy
|
|
5
5
|
Home-page: https://pypi.org/project/plotguy/
|
|
6
6
|
Author: Plotguy Team
|
|
@@ -15,9 +15,9 @@ Requires-Dist: hkfdb
|
|
|
15
15
|
Requires-Dist: pyarrow==23.0.0
|
|
16
16
|
Requires-Dist: fastparquet
|
|
17
17
|
Requires-Dist: polars==0.18.15
|
|
18
|
+
Requires-Dist: dash==2.9.3
|
|
18
19
|
Requires-Dist: plotly==5.18.0
|
|
19
20
|
Requires-Dist: lxml
|
|
20
|
-
Requires-Dist: dash==2.9.3
|
|
21
21
|
Requires-Dist: dash_bootstrap_components
|
|
22
22
|
Requires-Dist: dash_daq
|
|
23
23
|
Requires-Dist: dash_dangerously_set_inner_html
|
|
@@ -443,3 +443,44 @@ def get_geometric_mean_of_yearly_rate_backup(start_year, end_year):
|
|
|
443
443
|
|
|
444
444
|
return fed_fund_rate_geometric_mean
|
|
445
445
|
|
|
446
|
+
def su_table_converter():
|
|
447
|
+
all_str_dir = []
|
|
448
|
+
for folder_name in os.listdir():
|
|
449
|
+
if os.path.isfile(os.path.join(folder_name, 'saved_strategies.parquet')):
|
|
450
|
+
all_str_dir.append(folder_name)
|
|
451
|
+
|
|
452
|
+
su_dict = {'backtest_name': [], 'code': [], 'freq': [], 'para_items_str': [], 'initial_capital': [],
|
|
453
|
+
'equity_mdd_pct': []}
|
|
454
|
+
|
|
455
|
+
for str_dir in all_str_dir:
|
|
456
|
+
saved_strategies_path = os.path.join(str_dir, 'saved_strategies.parquet')
|
|
457
|
+
saved_strategies_df = pd.read_parquet(saved_strategies_path)
|
|
458
|
+
saved_strategies_df = saved_strategies_df.reset_index(drop=True)
|
|
459
|
+
|
|
460
|
+
if len(saved_strategies_df.columns) > 1:
|
|
461
|
+
for i, row in saved_strategies_df.iterrows():
|
|
462
|
+
backtest_name = row['backtest_name']
|
|
463
|
+
freq = row['freq']
|
|
464
|
+
para_keys_str = row['para_keys_str']
|
|
465
|
+
equity_mdd_pct = row['equity_mdd_pct']
|
|
466
|
+
initial_capital = row['initial_capital']
|
|
467
|
+
|
|
468
|
+
para_items_str = ''
|
|
469
|
+
para_keys_str_list = para_keys_str.split('|')
|
|
470
|
+
for para_key in para_keys_str_list:
|
|
471
|
+
para_value = str(saved_strategies_df.at[i, para_key])
|
|
472
|
+
if para_key == 'code':
|
|
473
|
+
code = para_value
|
|
474
|
+
else:
|
|
475
|
+
para_items_str += para_key + '=' + para_value + '|'
|
|
476
|
+
para_items_str = para_items_str[:-1]
|
|
477
|
+
|
|
478
|
+
su_dict['backtest_name'].append(backtest_name)
|
|
479
|
+
su_dict['code'].append(code)
|
|
480
|
+
su_dict['freq'].append(freq)
|
|
481
|
+
su_dict['para_items_str'].append(para_items_str)
|
|
482
|
+
su_dict['equity_mdd_pct'].append(equity_mdd_pct)
|
|
483
|
+
su_dict['initial_capital'].append(initial_capital)
|
|
484
|
+
|
|
485
|
+
su_table = pd.DataFrame(su_dict)
|
|
486
|
+
return su_table
|
|
@@ -630,7 +630,9 @@ class Components:
|
|
|
630
630
|
fig_line.add_trace(go.Scatter(mode='lines', hovertemplate=hovertemplate,
|
|
631
631
|
x=df_daily.index.date, y=df_daily['equity_value'],
|
|
632
632
|
line=dict(color=line_colour, width=1.5), name=''), )
|
|
633
|
-
|
|
633
|
+
fig_line.update_layout(
|
|
634
|
+
hoverlabel=dict(align="left", font_size=12, bgcolor="white")
|
|
635
|
+
)
|
|
634
636
|
|
|
635
637
|
return fig_line
|
|
636
638
|
|
|
@@ -791,6 +793,7 @@ class Components:
|
|
|
791
793
|
for folder_name in os.listdir():
|
|
792
794
|
if os.path.isfile(os.path.join(folder_name, 'saved_strategies.parquet')):
|
|
793
795
|
all_str_dir.append(folder_name)
|
|
796
|
+
|
|
794
797
|
all_str_dir.sort()
|
|
795
798
|
equity_curves_dict_list = []
|
|
796
799
|
|
|
@@ -798,73 +801,73 @@ class Components:
|
|
|
798
801
|
saved_strategies_path = os.path.join(str_dir, 'saved_strategies.parquet')
|
|
799
802
|
saved_strategies_df = pd.read_parquet(saved_strategies_path)
|
|
800
803
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
804
|
+
if len(saved_strategies_df.columns) > 1:
|
|
805
|
+
for i, row in saved_strategies_df.iterrows():
|
|
806
|
+
equity_path = os.path.join(str_dir, row['equity_curve_folder'], str(row['ref_code']) + '.parquet')
|
|
807
|
+
|
|
808
|
+
yearly_stats_string = row['yearly_stats_string']
|
|
809
|
+
para_keys_str = row['para_keys_str']
|
|
810
|
+
para_keys_list = para_keys_str.split('|')
|
|
811
|
+
|
|
812
|
+
parameters = {}
|
|
813
|
+
for para_keys in para_keys_list:
|
|
814
|
+
parameters[para_keys] = str(row[para_keys])
|
|
815
|
+
|
|
816
|
+
equity_curve_dict = {}
|
|
817
|
+
|
|
818
|
+
equity_curve_dict['folder'] = str_dir
|
|
819
|
+
equity_curve_dict['backtest_name'] = row['backtest_name']
|
|
820
|
+
equity_curve_dict['equity_path'] = equity_path
|
|
821
|
+
equity_curve_dict['parameters'] = parameters
|
|
822
|
+
|
|
823
|
+
equity_curve_dict['performance'] = {
|
|
824
|
+
'initial_capital': row['initial_capital'],
|
|
825
|
+
'sharpe_ratio': row['equity_annualized_sr'],
|
|
826
|
+
'annualized_return': row['equity_annualized_return'],
|
|
827
|
+
'net_profit_to_mdd': row['equity_net_profit_to_mdd'],
|
|
828
|
+
'net_profit': row['equity_net_profit'],
|
|
829
|
+
'mdd_dollar': row['equity_mdd_dollar'],
|
|
830
|
+
'mdd_pct': row['equity_mdd_pct'],
|
|
831
|
+
'num_of_trade': row['num_of_trade'],
|
|
832
|
+
'num_of_win': row['num_of_win'],
|
|
833
|
+
'return_on_capital': row['equity_return_on_capital'],
|
|
834
|
+
'total_commission': row['total_commission'],
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
ref_code = str(row['ref_code'])
|
|
838
|
+
equity_curve_dict['ref_code'] = ref_code
|
|
839
|
+
|
|
840
|
+
yearly_stats_dict = {}
|
|
841
|
+
years_data = yearly_stats_string.split("|")
|
|
842
|
+
|
|
843
|
+
for year_data in years_data:
|
|
844
|
+
parts = year_data.split(",")
|
|
845
|
+
year = parts[0]
|
|
846
|
+
yearly_stats_dict[year] = {}
|
|
847
|
+
|
|
848
|
+
for item in parts[1:]:
|
|
849
|
+
key, value = item.split(":")
|
|
850
|
+
yearly_stats_dict[year][key] = float(value)
|
|
851
|
+
|
|
852
|
+
for idx, (year, value) in enumerate(yearly_stats_dict.items()):
|
|
853
|
+
year_trade_count = value['year_trade_count']
|
|
854
|
+
year_win_rate = value['year_win_rate']
|
|
855
|
+
year_return = value['year_return']
|
|
856
|
+
|
|
857
|
+
year_win_count = year_trade_count * year_win_rate * 0.01
|
|
858
|
+
|
|
859
|
+
### dont remove ###
|
|
860
|
+
# year_trade_count = "{:d}".format(int(year_trade_count))
|
|
861
|
+
# year_win_count = "{:d}".format(int(year_win_count))
|
|
862
|
+
# year_win_rate = "{:d}%".format(int(year_win_rate))
|
|
863
|
+
# year_return = "{:.2f} %".format(int(year_return))
|
|
864
|
+
|
|
865
|
+
equity_curve_dict['performance'][f'{year} Count'] = year_trade_count
|
|
866
|
+
equity_curve_dict['performance'][f'{year} Win Rate'] = year_win_rate
|
|
867
|
+
equity_curve_dict['performance'][f'{year} Win Count'] = year_win_count
|
|
868
|
+
equity_curve_dict['performance'][f'{year} Return'] = year_return
|
|
869
|
+
|
|
870
|
+
equity_curves_dict_list.append(equity_curve_dict)
|
|
868
871
|
|
|
869
872
|
line_colour = []
|
|
870
873
|
for c in range(len(equity_curves_dict_list)):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotguy
|
|
3
|
-
Version: 2.1
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Plotguy
|
|
5
5
|
Home-page: https://pypi.org/project/plotguy/
|
|
6
6
|
Author: Plotguy Team
|
|
@@ -15,9 +15,9 @@ Requires-Dist: hkfdb
|
|
|
15
15
|
Requires-Dist: pyarrow==23.0.0
|
|
16
16
|
Requires-Dist: fastparquet
|
|
17
17
|
Requires-Dist: polars==0.18.15
|
|
18
|
+
Requires-Dist: dash==2.9.3
|
|
18
19
|
Requires-Dist: plotly==5.18.0
|
|
19
20
|
Requires-Dist: lxml
|
|
20
|
-
Requires-Dist: dash==2.9.3
|
|
21
21
|
Requires-Dist: dash_bootstrap_components
|
|
22
22
|
Requires-Dist: dash_daq
|
|
23
23
|
Requires-Dist: dash_dangerously_set_inner_html
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="plotguy",
|
|
8
|
-
version="2.1
|
|
8
|
+
version="2.2.1",
|
|
9
9
|
author="Plotguy Team",
|
|
10
10
|
author_email="plotguy.info@gmail.com",
|
|
11
11
|
description="Plotguy",
|
|
@@ -19,9 +19,9 @@ setuptools.setup(
|
|
|
19
19
|
'pyarrow==23.0.0',
|
|
20
20
|
'fastparquet',
|
|
21
21
|
'polars==0.18.15',
|
|
22
|
+
'dash==2.9.3',
|
|
22
23
|
'plotly==5.18.0',
|
|
23
24
|
'lxml',
|
|
24
|
-
'dash==2.9.3',
|
|
25
25
|
'dash_bootstrap_components',
|
|
26
26
|
'dash_daq',
|
|
27
27
|
'dash_dangerously_set_inner_html',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|