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/

    Newbie questions to use Backtrader in 'real world' scenarios.

    General Code/Help
    2
    2
    74
    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.
    • R
      rustyg last edited by

      Hi,

      I've been tinkering with Backtrader for the past week or two, and I've watched some YouTube videos as well, but I have a couple of questions which I can't find the answers to on the Backtrader site or here.

      I think they are some newbie questions that would really help me use Backtrader in a more 'real world' scenario for the hobbyist investor.

      Here are the questions (go easy on me):

      1. How do I invest a certain sum of money rather than a fixed stake each time? I think I need to access the current price prior to buying then calculate the number of shares I can purchase based on my cash reserve.

      2. How can I set the trade commission as a fixed amount rather than a percentage, e.g. $10? Here in the UK, the brokers tend to charge a fixed sum rather than commission.

      3. How do I reinvest all my cash each time rather than a fixed stake? Or reinvest only the profit? In real life this is something I do, I never invest based on a number of shares each time.

      4. How do I access user defined variables in my strategy class from the main script? I want to return particular information/results back, that I can then manipulate. For example with the optimization example I want to store each result in a list then analyse the list once each test case has been executed.

      Thanks in advance.

      run-out 1 Reply Last reply Reply Quote 0
      • run-out
        run-out @rustyg last edited by

        @rustyg said in Newbie questions to use Backtrader in 'real world' scenarios.:

        How do I invest a certain sum of money rather than a fixed stake each time? I think I need to access the current price prior to buying then calculate the number of shares I can purchase based on my cash reserve.

        You can create a custom sizer and the current cash info is available to then divide by your security price to get units.

        @rustyg said in Newbie questions to use Backtrader in 'real world' scenarios.:

        How can I set the trade commission as a fixed amount rather than a percentage, e.g. $10? Here in the UK, the brokers tend to charge a fixed sum rather than commission.
        Look here
        If margin is something else, it is considered the operations are happenning on a futures like intstrument and commission is a fixed price per size contracts

        @rustyg said in Newbie questions to use Backtrader in 'real world' scenarios.:

        How do I reinvest all my cash each time rather than a fixed stake? Or reinvest only the profit? In real life this is something I do, I never invest based on a number of shares each time.

        You can check cash value in the broker in each next and decide if it's enough to invest.

        @rustyg said in Newbie questions to use Backtrader in 'real world' scenarios.:

        How do I access user defined variables in my strategy class from the main script? I want to return particular information/results back, that I can then manipulate. For example with the optimization example I want to store each result in a list then analyse the list once each test case has been executed.

        Analyzers

        RunBacktest.com

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