For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Question regarding trade prices
-
Hello,
I am having a problem with the trade prices for the example below.
The line before order begins shows the datetime and the price at that candle. the order begins in the next candle and in the first line after--ORDER BEGIN
you can see the ohlc of that candle.The buy occurs at price
1.01643
, which is the opening price of the next candle as expected.
According to the log the sell price is1.01643
, though I was expecting to sell for1.0144
which is the opening price of that candle. What might have gone wrong here?I am buying with
self.buy()
and selling withself.sell()
.2017-04-26 22:35:00 2017-04-26 22:35:00 entry: 1.01635 -------------------------------------------------- ORDER BEGIN 2017-04-26 22:36:00 1.01643 1.01695 1.01594 1.01597 Ref: 1 OrdType: 0 OrdType: Buy Status: 4 Status: Completed Size: 10 Price: None Price Limit: None TrailAmount: None TrailPercent: None ExecType: 0 ExecType: Market CommInfo: <backtrader.comminfo.CommInfoBase object at 0x113c64be0> End of Session: 736445.9999999999 Info: AutoOrderedDict() Broker: None Alive: False -------------------------------------------------- ORDER END -------------------------------------------------- TRADE BEGIN 2017-04-26 22:36:00 1.01643 1.01695 1.01594 1.01597 ref:1 data:<utils.customcsv.HistData object at 0x113c1a630> tradeid:0 size:10 price:1.01643 value:10.164299999999999 commission:0.0 pnl:0.0 pnlcomm:0.0 justopened:True isopen:True isclosed:False baropen:18462 dtopen:736445.9416666667 barclose:0 dtclose:0.0 barlen:0 historyon:False history:[] status:1 -------------------------------------------------- TRADE END 2017-04-26 23:01:00 2017-04-26 23:01:00 stop loss: 1.01438 -------------------------------------------------- ORDER BEGIN 2017-04-26 23:02:00 1.0144 1.01446 1.01384 1.01417 Ref: 2 OrdType: 1 OrdType: Sell Status: 4 Status: Completed Size: -10 Price: None Price Limit: None TrailAmount: None TrailPercent: None ExecType: 0 ExecType: Market CommInfo: <backtrader.comminfo.CommInfoBase object at 0x113c64be0> End of Session: 736445.9999999999 Info: AutoOrderedDict() Broker: None Alive: False -------------------------------------------------- ORDER END -------------------------------------------------- TRADE BEGIN 2017-04-26 23:02:00 1.0144 1.01446 1.01384 1.01417 ref:1 data:<utils.customcsv.HistData object at 0x113c1a630> tradeid:0 size:0 price:1.01643 value:0.0 commission:0.0 pnl:-0.020299999999999763 pnlcomm:-0.020299999999999763 justopened:False isopen:False isclosed:True baropen:18462 dtopen:736445.9416666667 barclose:18488 dtclose:736445.9597222222 barlen:26 historyon:False history:[] status:2 -------------------------------------------------- TRADE END
-
You are not printing order execution prices. That's what's wrong. Use the available information in
order.executed
-
@backtrader thanks :)