Hello everyone,

I am trying to work with Forex data. I would like to do operations on prices. I am still new at Python, and learned that floating numbers give strange results. I am trying to use Decimal to avoid this, but am still getting strange results. At the top of my code I have:

from decimal import Decimal

class myAlgo(QCAlgorithm):
...

And within OnData I have: 

def OnData(self, data):

self.bid = Decimal(data["EURUSD"].Bid.Close)
self.ask = Decimal(data["EURUSD"].Ask.Close)

self.resultOne = Decimal(self.ask - self.bid)
self.resultTwo = Decimal(self.bid + 0.001)

But these are my results:

bid: 1.0868
ask: 1.08694

resultOne: 0.000140000000000029
resultTwo: 1.0877999999999999

As if I'm still using floats. I am trying to get results of 0.00014 and 1.0878 respectively. 

Any help is appreciated.