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/

    Is it possible to buy and sell for the same amount of value at the same bar with no cash in account?

    General Discussion
    3
    3
    361
    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.
    • S
      seedds last edited by

      Say I have 0 cash in my account, and I would like to buy A stock for 100 and sell B stock for 100 at the next bar. Only the sell order will be executed, and the buy order status will be 'Margin' and I will end up with 100 cash sitting in my account at the end of the next bar.

      I have to create additional bars to get both the sell and buy orders executed.

      Is there any other way to solve this?

      Thank you.

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        Yes, first sell order will be executed, then buy order. You should be confident that you are selling and buying stocks with the same value.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 1
        • B
          backtrader administrators last edited by

          Yes. do as @ab_trader points out. You cannot buy if you haven't got any cash. You need to sell first to inject cash into your account.

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