Skip to content

IMPROVEMENT: Make backtesting applicable to the Forex data. #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Pilipets opened this issue May 9, 2021 · 3 comments
Closed

IMPROVEMENT: Make backtesting applicable to the Forex data. #351

Pilipets opened this issue May 9, 2021 · 3 comments
Labels
invalid This is not a (valid) bug report

Comments

@Pilipets
Copy link

Pilipets commented May 9, 2021

This library is a gem for stock exchange markets - however, it doesn't work correctly for forex.

The improvement might involve several steps and issues, but here are some of them:

  1. Take profit calculation for forex isn't simply self.__size * (price - self.__entry_price) as we already have in Trade.pl - it must involve pip, position margin values as well.
  2. Trade.value isn't correct in the case of using Forex portfolio.

I would appreciate receiving any comments, how to use this package for the Forex strategy backtesting.

@Pilipets
Copy link
Author

Pilipets commented May 9, 2021

I found this discussion but didn't get how to do that - #8.

  1. Let's say I am buying 10 points of EUR/USD pairs on the Forex market today, which results in a 35$ margin(or Trade.value) on the FXCM, but If I specify size=10 in Strategy.buy method, that will produce abs(self.__size) * price Trade.value, which isn't correct. How should I change that?
  2. Assuming each position size is different, how could I adjust the calculation of the final stats for Forex data?
    Speaking of this example, https://github.com/kernc/backtesting.py/blob/master/doc/examples/Multiple%20Time%20Frames.ipynb.
    What stats calculation needs to be changed?
        s.loc['Equity Final [$]'] = equity[-1]
        s.loc['Equity Peak [$]'] = equity.max()
  1. How can I adjust the package to display correct profit/loss on the graphs?

I don't need the results in pips, but $ as it's now, though adjusted to the Forex.

@kernc
Copy link
Owner

kernc commented May 9, 2021

Have you seen Backtest(margin=)? I think it's what you're looking for.

@Pilipets
Copy link
Author

Pilipets commented May 9, 2021

Have you seen Backtest(margin=)? I think it's what you're looking for.

Yeah, sorry for this - good job with an awesome plotting library :)

@Pilipets Pilipets closed this as completed May 9, 2021
@kernc kernc added the invalid This is not a (valid) bug report label May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This is not a (valid) bug report
Projects
None yet
Development

No branches or pull requests

2 participants