Backtrader Community

    • 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/

    how to only buy a certain percentage of the account balance and sell the quantity bought

    General Discussion
    2
    2
    265
    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
      sarah_james last edited by

      Hi, I have spend a while looking in the forum but cannot find anything which clearly shows how to only buy a certain percentage and only sell the amount bought from that percentage.

      My account balance is $10,000 when buying I want to buy 5% worth, which will be $500 and when selling I want to sell the amount of shares I bought for that $500. e.g if I Bought 100 shares for $500, I want to then sell that 100 shares when it's time to sell

      D 1 Reply Last reply Reply Quote 0
      • D
        davidavr @sarah_james last edited by

        @sarah_james You can use order_target_percent(data, target=0.05) to buy 5% of your current portfolio value. Then when you want to sell, you can use order_target_percent(data, target=0.0)

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