For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Multi-currency portfolio with Futures markets

  • My portfolio (a single strategy with multiple data series) contains global markets with multiple different quote currencies (JPY, EUR, USD, CAD, etc). Is hacking/extending Broker's _execute(...) and _get_value(...) methods the proper way to apply FX conversions?

    If you have a plan to implement this or a working example, could you share with us? Thanks!

  • administrators

    The broker is, so to say, a single currency broker. A possible approach:

    • Subclass a CommissionInfo. Each instance which operates in a different currency gets assigned a different instance via:

      def addcommissioninfo(self, comminfo, name=None):

      which is in the broker

    When the CommissionInfo gets a request like getvalue(position, price), you may want to return a value in the main currency after adjusting internally for the foreign exchange rate of the currency the asset operates in.

    You probably need to override all methods (i.e.: go directly to the source and look at each method)

    The entry point in the documentation: Docs - Commissions: Stocks vs Futures (there are some other chapters following this one)