-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
Hello guys, thank you for wonderful tool!
In my strategy I want to close trades by achievement certain conditions or modify "tp", "sl" into specific trade.
But every time in "next()" function in the list of trades I see only one single trade....
I expect to see "One order -> one Trade".
For demonstration, I take the sample from "backtesting.py" and print Orders and Trades:
def next(self):
if self.position:
print('Orders: ', [order for order in self.orders])
print('Trades: ', [trade for trade in self.trades])
print('----------------------------------------')
if crossover(self.sma1, self.sma2):
self.buy() # Order 1 - expect trade 1
self.buy(sl=self.data.Low[-1]) # Order 2 - expect trade 2
self.buy(stop=self.data.High[-1])` # Order 3 - expect trade 3
The output:
Orders: [<Order size=1.0, stop=181.06, contingent=0>]
Trades: [<Trade size=55 time=75- price=179.48826- pl=-176>]
----------------------------------------
Orders: [<Order size=1.0, stop=181.06, contingent=0>]
Trades: [<Trade size=55 time=75- price=179.48826- pl=-443>]
----------------------------------------
Orders: [<Order size=1.0, stop=181.06, contingent=0>]
Trades: [<Trade size=55 time=75- price=179.48826- pl=-523>]
Q: How can I obtain access to each trade?
Beta Was this translation helpful? Give feedback.
All reactions
By default, order size is ~1.0 meaning 100% of equity. Reduce size to 10% (self.buy(size=.1, ...)
) or 10 units (self.buy(size=10, ...)
) and you should see three trades.
Replies: 1 comment 1 reply
-
By default, order size is ~1.0 meaning 100% of equity. Reduce size to 10% (self.buy(size=.1, ...)
) or 10 units (self.buy(size=10, ...)
) and you should see three trades.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank You so much kernc!
Yes, you are right - my bad...
Beta Was this translation helpful? Give feedback.