update
This commit is contained in:
15
README.md
15
README.md
@ -44,6 +44,21 @@ exits = exits | forced_exits_window
|
||||
|
||||
exits.tail(20)
|
||||
```
|
||||
## display plotly figs in single ntb cells
|
||||
|
||||
`figs2cell(figlist)`
|
||||
|
||||
Example usage:
|
||||
|
||||
```python
|
||||
figs = []
|
||||
fig1 = df.groupby([df['Exit Index'].dt.day_name(), 'Direction'])['PnL'].sum().unstack().vbt.barplot()
|
||||
fig2 = df.groupby([df['Exit Index'].dt.day_name(), 'Direction'])['PnL'].sum().unstack().vbt.barplot()
|
||||
figs.append(fig1)
|
||||
figs.append(fig2)
|
||||
display_figs_side_by_side(figs)
|
||||
```
|
||||
|
||||
## is rising/is falling
|
||||
`isrising(series,n)`,`isfalling(series, n)` - returns mask where the condition is satisfied of rising or falling elements including equal values
|
||||
|
||||
|
||||
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='ttools',
|
||||
version='0.3.9',
|
||||
version='0.4.0',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'vectorbtpro',
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
from .vbtutils import AnchoredIndicator, create_mask_from_window, isrising, isfalling, isrisingc, isfallingc, trades2entries_exits
|
||||
from .vbtutils import AnchoredIndicator, create_mask_from_window, isrising, isfalling, isrisingc, isfallingc, trades2entries_exits, figs2cell
|
||||
from .vbtindicators import register_custom_inds
|
||||
@ -3,8 +3,41 @@ import vectorbtpro as vbt
|
||||
import pandas_market_calendars as mcal
|
||||
from typing import Any
|
||||
import datetime
|
||||
import plotly.graph_objects as go
|
||||
import ipywidgets as widgets
|
||||
from IPython.display import display
|
||||
|
||||
|
||||
def figs2cell(fig_list):
|
||||
"""
|
||||
Display a list of plotly figures side by side in a notebook.
|
||||
Allows to display multiple plots in a single cell.
|
||||
Args:
|
||||
fig_list (list): list of figures
|
||||
|
||||
Example usage:
|
||||
|
||||
```python
|
||||
figs = []
|
||||
fig1 = df.groupby([df['Exit Index'].dt.day_name(), 'Direction'])['PnL'].sum().unstack().vbt.barplot()
|
||||
fig2 = df.groupby([df['Exit Index'].dt.day_name(), 'Direction'])['PnL'].sum().unstack().vbt.barplot()
|
||||
figs.append(fig1)
|
||||
figs.append(fig2)
|
||||
display_figs_side_by_side(figs)
|
||||
```
|
||||
"""
|
||||
# Create output widgets for each figure
|
||||
output_widgets = []
|
||||
for fig in fig_list:
|
||||
out = widgets.Output()
|
||||
with out:
|
||||
fig.show()
|
||||
output_widgets.append(out)
|
||||
|
||||
# Create an HBox to display the widgets side by side
|
||||
hbox = widgets.HBox(output_widgets)
|
||||
display(hbox)
|
||||
|
||||
def trades2entries_exits(pf, notext=False):
|
||||
"""
|
||||
Convert trades from Portfolio to entries and exits DataFrame for use in lw plot
|
||||
|
||||
Reference in New Issue
Block a user