oanda-bot-python icon indicating copy to clipboard operation
oanda-bot-python copied to clipboard

Calculation precision

Open pavleprica opened this issue 4 years ago • 0 comments

Hey team, I hope all of you are doing well in these times.

So I have a question, related to calculation precision. I am not that knowledgeable with Python, so I cannot propose a concrete solution.

The issue is that for calculation as a type float is being used as a type, which leads to unstable calculations because of decimals. I think this can pose a really big issue and is a no-go for us to use this. When decimals are being calculated and everything depends on the floating-point, something else should be used. Because it really depends on which CPU is the machine using, and what is the state of that CPU.

In the Java world, the solution is BigDecimal or a custom implementation.

For an example

bot = Bot(
    account_id='account-id',
    access_token='access-token',
    granularity='D',
    instrument='EUR_USD',
    environment='practice'
)
print(bot._candles(count='6'))

print(bot.rsi(period=5))

Prints a different result every time.

Is there a plan to resolve this in the near future?

EDIT: Also, this would apply to all calculations inside the app with float as a type

pavleprica avatar Apr 29 '21 10:04 pavleprica