fix
This commit is contained in:
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='ttools',
|
name='ttools',
|
||||||
version='0.3.8',
|
version='0.3.9',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'vectorbtpro',
|
'vectorbtpro',
|
||||||
|
|||||||
@ -5,14 +5,17 @@ from typing import Any
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
def trades2entries_exits(pf):
|
def trades2entries_exits(pf, notext=False):
|
||||||
"""
|
"""
|
||||||
Convert trades from Portfolio to entries and exits DataFrame for use in lw plot
|
Convert trades from Portfolio to entries and exits DataFrame for use in lw plot
|
||||||
|
|
||||||
For each trade exit type is fetched from orders.
|
For each trade exit type is fetched from orders and transformed for markers to use.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
pf Portfolio object: trades and orders
|
pf Portfolio object: trades and orders
|
||||||
|
notext (bool): if True, no text is added
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
tuple: (entries DataFrame, exits DataFrame)
|
tuple: (entries DataFrame, exits DataFrame)
|
||||||
@ -20,6 +23,11 @@ def trades2entries_exits(pf):
|
|||||||
trades = pf.trades.readable
|
trades = pf.trades.readable
|
||||||
orders = pf.orders.readable
|
orders = pf.orders.readable
|
||||||
|
|
||||||
|
if notext:
|
||||||
|
trade_entries = pd.Series(index=trades["Entry Index"], dtype=bool, data=True)
|
||||||
|
trade_exits = pd.Series(index=trades["Exit Index"], dtype=bool, data=True)
|
||||||
|
return trade_entries, trade_exits
|
||||||
|
|
||||||
# Merge the dataframes on 'order_id'
|
# Merge the dataframes on 'order_id'
|
||||||
trades = trades.merge(orders[['Order Id', 'Stop Type']], left_on='Exit Order Id', right_on='Order Id', how='left').drop(columns=['Order Id'])
|
trades = trades.merge(orders[['Order Id', 'Stop Type']], left_on='Exit Order Id', right_on='Order Id', how='left').drop(columns=['Order Id'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user