Closed binbap closed 2 years ago
yes. the documentation mentions truncation of the prices when they are passed around as floats.
to avoid this, just cast the value into a string and pass that string for the price. Don't worry about how a string is supposed to represent a numerical price.
so something like:
val = str(your_price_value)
# now you can pass the val into function calls
when you do that, prices will not be truncated and used as they are.
Thanks!
@alexgolec consider closing this
I am unclear if this is expected behavior but when creating an limit option order in which the price is under 1, the order sent has the limit is formatted to 4 digits. Recently when I tried to submit an order under 1, it was rejected (I believe it is because it of the 4 digits). The following is the code that appears to format prices under 1 to 4 digits. Is this intentional?
def truncate_float(flt): if abs(flt) < 1 and flt != 0.0: return '{:.4f}'.format(float(int(flt 10000)) / 10000.0) else: return '{:.2f}'.format(float(int(flt 100)) / 100.0)