askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.07k stars 3.94k forks source link

Backtesting profit calculation is not accurate #1315

Closed AidasK closed 6 years ago

AidasK commented 6 years ago

[x ] bug report [ ] feature request [ ] question about the decisions made in the repository

screen shot 2017-11-12 at 14 34 32
askmike commented 6 years ago

You had bitcoin in your start position and the price went down. This means your portfolio went down in value. dup of #883.

AidasK commented 6 years ago

No, not really. You are talking about buy and hold profit. This number is displayed on MARKET (you can see it in the screenshot -34.8%). Simulated profit should be 0%

AidasK commented 6 years ago

And why my start balance and end balance differs if I made no trades?

askmike commented 6 years ago

Read #883, it has an example going through how Gekko deals with a portfolio :)

askmike commented 6 years ago

To answer your specific questions:

This number is displayed on MARKET (you can see it in the screenshot -34.8%).

Market is whatever the market did during the duration of the backtest. If you were to have had 1 BTC and 0 USD in the beginning of the backtest, and did 0 trades during the backtest, your profit would have been -34.8% (since your portolio is now worth -34.8% less).

And why my start balance and end balance differs if I made no trades?

Because your start position included bitcoin, which changed in price.


It sounds like you want to configure the paper trader to not start out with any BTC, so that your portfolio is not impacted without any trades. You can do this by configuring the paper trader and setting asset (under simulationBalance) to 0.

AidasK commented 6 years ago

Oh, I have asset set to 1. I have changed it to 0 and it solved my problem. Asset keyword is new to me.
For exmaple, If I am backtesting BTC/ETH: [simulationBalance] asset = 100 currency = 0

Asset is ETH(100), and BTC is currency(0)?

askmike commented 6 years ago

yes, technically they are both currencies but we need a way to differentiate between the "main" and what you are trading. Kraken calls this the Base and the Quote currency.

AidasK commented 6 years ago

Can we add comments to paperTrader.toml:

feeMaker = 0.25
feeTaker = 0.25
feeUsing = 'maker'
slippage = 0.05

[simulationBalance]
# amount of primary currency
currency = 100
# amount of secondary currency
asset = 1
AidasK commented 6 years ago

and default asset amount should be changed to 0 imo to reduce confusion and bug reports like this