Can't understand the code in get_price_offset
Opened this issue · 1 comments
Jay54520 commented
The code is return math.toNearest(start_position * (1 + settings.INTERVAL) ** index, self.instrument['tickSize'])
in get_price_offset
.
Why there are different results?
start_position * (1 + settings.INTERVAL) ** 0 = 9522.6475
9570.260737499999 ** 0 = 1
.
We know that **
means pow in Python, so 2 is expected but not 1.
kicksent commented
(1 + settings.INTERVAL) ** 0
evaluates to 1 before being multiplied with start_position
because the order of operations in python is pow before mult.
If you put parenthesis around the first part it will evaluate the same:
(start_position * (1 + settings.INTERVAL)) ** 0