fix
This commit is contained in:
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='ttools',
|
||||
version='0.3.8',
|
||||
version='0.3.9',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'vectorbtpro',
|
||||
|
||||
@ -5,14 +5,17 @@ from typing import Any
|
||||
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
|
||||
|
||||
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:
|
||||
pf Portfolio object: trades and orders
|
||||
notext (bool): if True, no text is added
|
||||
|
||||
Returns:
|
||||
tuple: (entries DataFrame, exits DataFrame)
|
||||
@ -20,6 +23,11 @@ def trades2entries_exits(pf):
|
||||
trades = pf.trades.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'
|
||||
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