aplotly 1.1.14__tar.gz → 1.1.16__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.
- {aplotly-1.1.14/aplotly.egg-info → aplotly-1.1.16}/PKG-INFO +1 -1
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly/plots.py +41 -2
- {aplotly-1.1.14 → aplotly-1.1.16/aplotly.egg-info}/PKG-INFO +1 -1
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly.egg-info/SOURCES.txt +2 -0
- aplotly-1.1.16/examples/plot_correlation.py +22 -0
- aplotly-1.1.16/examples/plot_returns_breakdown.py +26 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/pyproject.toml +2 -2
- {aplotly-1.1.14 → aplotly-1.1.16}/LICENSE +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/MANIFEST.in +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/README.md +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly/__init__.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly/colors.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly/io.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly/style.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly/utils/return_breakdown.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly.egg-info/dependency_links.txt +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly.egg-info/requires.txt +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/aplotly.egg-info/top_level.txt +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_bars.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_exposure_tree.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_gauge.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_line.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_line_and_save.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_lines.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_multiple_performance.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_performance.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_performance_by_trade.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/examples/plot_returns_tree.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/setup.cfg +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/tests/test_colors.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/tests/test_io.py +0 -0
- {aplotly-1.1.14 → aplotly-1.1.16}/tests/test_style.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aplotly
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.16
|
|
4
4
|
License: MIT License
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
@@ -477,6 +477,7 @@ def plot_return_breakdown(
|
|
|
477
477
|
color_path: list = ["red", "grey", "green"],
|
|
478
478
|
color_bar: bool = False,
|
|
479
479
|
plot_title: str = "",
|
|
480
|
+
attribution_only: bool = False,
|
|
480
481
|
):
|
|
481
482
|
returns = calculate_return_breakdown(exposure, returns)
|
|
482
483
|
relative_returns = returns / returns.sum()
|
|
@@ -513,8 +514,13 @@ def plot_return_breakdown(
|
|
|
513
514
|
|
|
514
515
|
fig.update_layout(margin=dict(l=0, r=0, t=0, b=0), title_text=plot_title)
|
|
515
516
|
|
|
516
|
-
|
|
517
|
-
|
|
517
|
+
if attribution_only:
|
|
518
|
+
fig.data[0].customdata = [r for r in relative_returns]
|
|
519
|
+
fig.data[0].texttemplate = "%{label}<br>%{customdata:.2%}"
|
|
520
|
+
|
|
521
|
+
else:
|
|
522
|
+
fig.data[0].customdata = [(r, _r) for r, _r in zip(returns, relative_returns)]
|
|
523
|
+
fig.data[0].texttemplate = "%{label}<br>%{customdata[0]:.2%}<br><i>%{customdata[1]:.2%}</i>"
|
|
518
524
|
|
|
519
525
|
return fig
|
|
520
526
|
|
|
@@ -698,3 +704,36 @@ def plot_performance_by_trade(
|
|
|
698
704
|
fig.update_layout(title_text=plot_title)
|
|
699
705
|
|
|
700
706
|
return fig
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
def plot_correlation(
|
|
710
|
+
correlation: pd.DataFrame,
|
|
711
|
+
color_palette: str = "",
|
|
712
|
+
plot_title: str = "",
|
|
713
|
+
):
|
|
714
|
+
"""Plot a correlation matrix.
|
|
715
|
+
|
|
716
|
+
Args:
|
|
717
|
+
correlation (pd.DataFrame): correlation matrix.
|
|
718
|
+
color_palette (str, optional): name of the color palette to use. Defaults to "" (default color palette).
|
|
719
|
+
plot_title (str, optional): title for the plot. Defaults to "" (no title).
|
|
720
|
+
|
|
721
|
+
Returns:
|
|
722
|
+
go.Figure: plotly figure containing the correlation matrix.
|
|
723
|
+
"""
|
|
724
|
+
configure_plotly(subplots=1, color_palette=color_palette)
|
|
725
|
+
fig = go.Figure(
|
|
726
|
+
go.Heatmap(
|
|
727
|
+
z=correlation,
|
|
728
|
+
x=correlation.columns,
|
|
729
|
+
y=correlation.columns,
|
|
730
|
+
colorscale="RdBu",
|
|
731
|
+
zmin=-1,
|
|
732
|
+
zmax=1,
|
|
733
|
+
colorbar=dict(title="Correlation"),
|
|
734
|
+
)
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
fig.update_layout(title_text=plot_title, yaxis={"scaleanchor": "x", "scaleratio": 1})
|
|
738
|
+
|
|
739
|
+
return fig
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aplotly
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.16
|
|
4
4
|
License: MIT License
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
@@ -14,6 +14,7 @@ aplotly.egg-info/requires.txt
|
|
|
14
14
|
aplotly.egg-info/top_level.txt
|
|
15
15
|
aplotly/utils/return_breakdown.py
|
|
16
16
|
examples/plot_bars.py
|
|
17
|
+
examples/plot_correlation.py
|
|
17
18
|
examples/plot_exposure_tree.py
|
|
18
19
|
examples/plot_gauge.py
|
|
19
20
|
examples/plot_line.py
|
|
@@ -22,6 +23,7 @@ examples/plot_lines.py
|
|
|
22
23
|
examples/plot_multiple_performance.py
|
|
23
24
|
examples/plot_performance.py
|
|
24
25
|
examples/plot_performance_by_trade.py
|
|
26
|
+
examples/plot_returns_breakdown.py
|
|
25
27
|
examples/plot_returns_tree.py
|
|
26
28
|
tests/test_colors.py
|
|
27
29
|
tests/test_io.py
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
from aplotly.plots import plot_correlation
|
|
4
|
+
|
|
5
|
+
correlations = pd.DataFrame(
|
|
6
|
+
{
|
|
7
|
+
"a": [1.0, 0.2, 0.2, 0.4, 0.5],
|
|
8
|
+
"b": [0.6, 1.0, 0.8, 0.9, 1.0],
|
|
9
|
+
"c": [0.1, 0.2, 1.0, 0.4, 0.5],
|
|
10
|
+
"d": [0.6, 0.7, 0.8, 1.0, 1.0],
|
|
11
|
+
"e": [0.6, 0.7, 0.8, 1.0, 1.0],
|
|
12
|
+
},
|
|
13
|
+
index=["a", "b", "c", "d", "e"],
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
fig = plot_correlation(
|
|
17
|
+
correlations,
|
|
18
|
+
plot_title="Correlation",
|
|
19
|
+
color_palette="dark_mode",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
fig.show()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
from aplotly.plots import plot_return_breakdown
|
|
5
|
+
|
|
6
|
+
exposures = pd.DataFrame(
|
|
7
|
+
np.concatenate([np.ones((10, 3)), np.ones((10, 3)) * 0.5]), columns=["a", "b", "c"], index=np.arange(20)
|
|
8
|
+
)
|
|
9
|
+
exposures = exposures.div(exposures.sum(axis=1), axis=0)
|
|
10
|
+
|
|
11
|
+
returns = pd.DataFrame(
|
|
12
|
+
np.concatenate([np.ones((20, 1)) * 0.01, np.ones((20, 1)) * 0.02, np.ones((20, 1)) * 0.03], axis=1),
|
|
13
|
+
columns=["a", "b", "c"],
|
|
14
|
+
index=np.arange(20),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
fig = plot_return_breakdown(
|
|
18
|
+
returns,
|
|
19
|
+
exposures,
|
|
20
|
+
root_color="black",
|
|
21
|
+
color_path=["red", "grey", "green"],
|
|
22
|
+
color_bar=False,
|
|
23
|
+
plot_title="Returns Tree",
|
|
24
|
+
attribution_only=True,
|
|
25
|
+
)
|
|
26
|
+
fig.show()
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aplotly"
|
|
7
|
-
version = "1.1.
|
|
7
|
+
version = "1.1.16"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = { file = "LICENSE" }
|
|
10
10
|
classifiers = [
|
|
@@ -19,7 +19,7 @@ dependencies = [
|
|
|
19
19
|
requires-python = ">=3.10"
|
|
20
20
|
|
|
21
21
|
[tool.bumpver]
|
|
22
|
-
current_version = "1.1.
|
|
22
|
+
current_version = "1.1.16"
|
|
23
23
|
version_pattern = "MAJOR.MINOR.PATCH"
|
|
24
24
|
commit_message = "Bump version {old_version} -> {new_version}"
|
|
25
25
|
commit = true
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|