aplotly 1.0.4__tar.gz → 1.1.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.
- {aplotly-1.0.4/aplotly.egg-info → aplotly-1.1.1}/PKG-INFO +1 -1
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly/plots.py +4 -2
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly/utils/return_breakdown.py +8 -1
- {aplotly-1.0.4 → aplotly-1.1.1/aplotly.egg-info}/PKG-INFO +1 -1
- {aplotly-1.0.4 → aplotly-1.1.1}/pyproject.toml +2 -2
- {aplotly-1.0.4 → aplotly-1.1.1}/LICENSE +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/MANIFEST.in +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/README.md +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly/__init__.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly/colors.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly/io.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly/style.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly.egg-info/SOURCES.txt +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly.egg-info/dependency_links.txt +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly.egg-info/requires.txt +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/aplotly.egg-info/top_level.txt +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_bars.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_exposure_tree.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_line.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_line_and_save.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_lines.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_multiple_performance.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_performance.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/examples/plot_returns_tree.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/setup.cfg +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/tests/test_colors.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/tests/test_io.py +0 -0
- {aplotly-1.0.4 → aplotly-1.1.1}/tests/test_style.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aplotly
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
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:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import List
|
|
2
2
|
|
|
3
|
+
import numpy as np
|
|
3
4
|
import pandas as pd
|
|
4
5
|
import plotly.graph_objects as go
|
|
5
6
|
from plotly.subplots import make_subplots
|
|
@@ -421,6 +422,7 @@ def plot_return_breakdown(
|
|
|
421
422
|
plot_title: str = "",
|
|
422
423
|
):
|
|
423
424
|
returns = calculate_return_breakdown(exposure, returns)
|
|
425
|
+
relative_returns = returns / returns.sum()
|
|
424
426
|
|
|
425
427
|
labels = returns.index
|
|
426
428
|
sizes = returns.abs()
|
|
@@ -454,8 +456,8 @@ def plot_return_breakdown(
|
|
|
454
456
|
|
|
455
457
|
fig.update_layout(margin=dict(l=0, r=0, t=0, b=0), title_text=plot_title)
|
|
456
458
|
|
|
457
|
-
fig.data[0].customdata =
|
|
458
|
-
fig.data[0].texttemplate = "%{label}<br>%{customdata:.2%}"
|
|
459
|
+
fig.data[0].customdata = [(r, _r) for r, _r in zip(returns, relative_returns)]
|
|
460
|
+
fig.data[0].texttemplate = "%{label}<br>%{customdata[0]:.2%}<br><i>%{customdata[1]:.2%}</i>"
|
|
459
461
|
|
|
460
462
|
return fig
|
|
461
463
|
|
|
@@ -3,14 +3,21 @@ import pandas as pd
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def separate_exposures_and_returns(exposures, returns):
|
|
6
|
+
# if the indicies are not the same raise an error
|
|
7
|
+
if not exposures.index.equals(returns.index):
|
|
8
|
+
raise ValueError("The indicies of exposures and returns must be the same")
|
|
9
|
+
|
|
6
10
|
indices = np.where(exposures.diff().abs().sum(axis=1) != 0)[0]
|
|
7
11
|
|
|
8
|
-
return np.split(exposures, indices), np.split(returns, indices)
|
|
12
|
+
return np.split(exposures, exposures.index[indices]), np.split(returns, exposures.index[indices])
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
def get_sequence_returns(separated_exposures, separated_returns):
|
|
12
16
|
sequence_returns = []
|
|
13
17
|
for _exposures, _returns in zip(separated_exposures, separated_returns):
|
|
18
|
+
if _exposures.empty or _returns.empty:
|
|
19
|
+
continue
|
|
20
|
+
|
|
14
21
|
# calculate the cumulative returns for each sequence
|
|
15
22
|
_sequence_returns = (_returns + 1).cumprod() - 1
|
|
16
23
|
_sequence_returns = _sequence_returns.iloc[-1]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aplotly
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
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:
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aplotly"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.1.1"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = { file = "LICENSE" }
|
|
10
10
|
classifiers = [
|
|
@@ -19,7 +19,7 @@ dependencies = [
|
|
|
19
19
|
requires-python = ">=3.10.6"
|
|
20
20
|
|
|
21
21
|
[tool.bumpver]
|
|
22
|
-
current_version = "1.
|
|
22
|
+
current_version = "1.1.1"
|
|
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
|