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/

    Creating a Custom Broker

    General Code/Help
    2
    3
    740
    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.
    • Jacob
      Jacob last edited by

      I'm in the process of creating a custom broker that has a use case that I am not sure if it can be supported in backtrader.
      The account balance potentially could have more then one type of currency that is not easily interchangeable.

      meaning for example, I could have 2 type of currencies. each one can buy/sell different shares. I can convert between the two currencies for a fee,
      but Ideally I would like to have 2 different accounts that only on special cases convert currency between the two.

      my question regards the following broker methods:
      getcash, getvalue and getposition.

      will it make sense to return from the broker a list of cash/value instead of a simple double?

      I could, with some effort, convert between the two and then aggregate which is nice for seeing the balance of the whole portfolio. but for trading this information is less valuable.

      I looked over the code and it seem to be more or less possible but I'm not sure.
      the 'cash' object seem to be past around the system without any arithmetics operating on it (except in CommInfoBase and specifics implementations)
      the rest seem to be waiting for a user implementations to decide what to do with 'cash'

      *still need to do more investigation on value and positions

      thoughts/suggestions?

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

        Why not to split backtest into 2 different runs with two separate brokers each has its own currency?

        1 Reply Last reply Reply Quote 0
        • Jacob
          Jacob last edited by

          I didn't describe it competently but there is a connection in the logic and strategy between the shares

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }