order.execute.price vs order.execute.value
-
Taking the QuickStart section as an example, assuming the a stake size of 1, how is order.executed.price different from order.executed.value? In the Quickstart section it logs order.executed.value as 'cost'.
When I use it in work of my own in the same way, order.executed.value ('cost') is sometimes the same value as order.executed.price ('price'), and other times it differs slightly...
-
@maxpaton said in order.execute.price vs order.execute.value:
and other times it differs slightly
How? What are you expecting? Can you give us a code example?
-
@backtrader Sorry, I have realised the mistake I was making. But, would it be possible just to tell me how order.execute.value is calculated in the notify trade() method?
Here is the code:
def notify_order(self, order): if order.status in [order.Submitted, order.Accepted]: return if order.status in [order.Completed]: if order.isbuy(): self.log('BUY EXECUTED, Price: %.2f, Cost: %.2f, Comm: %.2f' % (order.executed.price, order.executed.value, order.executed.comm)) self.buyprice = order.executed.price self.buycomm = order.executed.comm else: self.log('SELL EXECUTED, Price: %.2f, Cost: %.2f, Comm: %.2f' % (order.executed.price, order.executed.value, order.executed.comm)) self.bar_executed = len(self) elif order.status in [order.Cancelled, order.Margin, order.Rejected]: self.log('Order Cancelled/Margin/Rejected')
-
@maxpaton said in order.execute.price vs order.execute.value:
how order.execute.value is calculated in the notify trade() method?
Let's assume you mean
notify_order
. Thevalue
is calculated by the commission scheme which is assigned for the given asset and takes into consideration if you are using stock-like assets or future-like assets. You can customize it if you wish by adding your own commission schemes.The default is just the
size * price
for stocks.See for example: Docs - Extending Commissions
There are some other pages on the topic
P.S.
That code doesn't help. You are not telling us nothing, but that you are printing things out and not what the problem is. -
@backtrader Yes I did mean notify_order, thanks. I agree, not sure why I added the code, as all I wanted to know was how order.executed.value is calculated.
Cheers