Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Sell a specific completed buy order

    General Code/Help
    2
    2
    57
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bowguo
      bowguo last edited by

      Let's say I first place a buy order. After this order is completed, I now hold a long position.
      Then I place a sell order with the same size, and after the sell order is completed, will I hold both a long and a short positions, or my position is zero because the previous long position is now sold?

      If the sell order sells the previous long position, then I have a question. If I have two completed buy orders with different executed prices, now I place a sell order, which buy position will be sold exactly? How can I sell a specific buy order?

      vladisld 1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld @bowguo last edited by

        @bowguo You may think about the orders as instructions to change the current position. The order doesn't constitute the position itself.

        The position is maintained by the broker per data ( not per order ). So if you buy order has completed - your position for particular data has increased and vice versa for sell order.

        Regarding the multiple orders with different prices - once again the position is not maintained per order - so if you sell part of your position - the position will just decrease by the size of the sell order - regardless of any previous order history that brought your position to the current state.

        Diving a little bit deeper however, the real broker maintains the base price for every single share/unit of the entity you are holding in your position - for various purposes ( tax calculation, average price calculation, margin requirements and so on ). Some brokers even allow you to select the tax calculation policy if multiple lots of the same entity with different prices are part of your position.

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors