Skip to content

Commit

Permalink
add price rounding everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Jul 15, 2020
1 parent 7d3ece4 commit fd41ae9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions binance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ async def create_order(
params["newClientOrderId"] = new_client_order_id

if stop_price:
if self.loaded:
stop_price = round(stop_price, self.base_asset_precision)
params["stopPrice"] = stop_price
elif order_type in [
OrderType.STOP_LOSS.value,
Expand Down Expand Up @@ -447,6 +449,9 @@ async def create_oco(
if not stop_price:
raise ValueError("This query requires a stop_price.")

if self.loaded:
price = round(price, self.base_asset_precision)

params = {
"symbol": symbol,
"side": side,
Expand All @@ -460,6 +465,8 @@ async def create_oco(
if limit_iceberg_quantity:
params["limitIcebergQty"] = limit_iceberg_quantity
if stop_client_order_id:
if self.loaded:
stop_client_order_id = round(stop_client_order_id, self.base_asset_precision)
params["stopLimitPrice"] = stop_client_order_id
if stop_iceberg_quantity:
params["stopIcebergQty"] = stop_iceberg_quantity
Expand Down

0 comments on commit fd41ae9

Please sign in to comment.