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

Forex Exchange Rate Locations



  • Hello,

    I am currently working the FX data and I have put in my logic for the buying and selling. However, I am having trouble with Trade Value, the net profit and loss calculations, and exchange rate locations. I just don't understand what section of the backtrader code I would put these three sections.

    1. For the Trade Value, would this value be placed under the order or the commissions code for the back testing? The trade value would be important to make sure the margin is calculated correctly.

    2. What would be the correct method to change the net P/L calculation for forex? Would this be under the strategy itself or under the order and execution stage? This method currently calculates correctly when the USD is the quote price.
      (Equation: Profit/Loss = 0.0001 * Trade Value / Exchange Rate * Change in Pips.)

    3. Where would the code for changing the exchange rate for USD and cross pairs be placed?

    Thank you for your assistance.



});