For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

How to assign a market order execution price different than open

  • I know that might be weird for most traders, but my idea is to backtest a daily execution scheme where @ day "d" a signal is generated to buy/sell a quantity "x" for some asset, which will be sent as a VWAP or TWAP order to my broker @ the next pre-open day ("d+1") .

    Thus, since my actual broker (not backtrader's) has his own algorithm to execute the order throughout the day, it will be executed close enough to the realized TWAP/VWAP price. Finally, this is why I want to simulate a market order at some pre-set price (yeah I know I'm looking ahead for that, but this is intentional!).

    Thank you guys!

  • Market order is executed by the price available in the market, it can not be specified. Use limit order if want the order to be executed at certain price or better.

  • Thanks for your reply @ab_trader but I want the order to be executed at the TWAP/VWAP price, however if I set a limit order, it will be executed at the best price (i.e. the open price, if my limit price is the next day's TWAP price).

  • so StopLimit order with the small difference between Stop and Limit prices will help.

  • @ab_trader great call, dude! I didn't know about this StopLimit order

    Thank you very much!

Log in to reply