From 7b4e9bcb15e8ca10558f3e7f75fbb65518ea5924 Mon Sep 17 00:00:00 2001 From: Beni Bienz Date: Thu, 1 Jul 2021 20:44:32 -0600 Subject: [PATCH 1/2] Add limit_price arg to stop orders --- cbpro/authenticated_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cbpro/authenticated_client.py b/cbpro/authenticated_client.py index f330377f..f8e2aaae 100644 --- a/cbpro/authenticated_client.py +++ b/cbpro/authenticated_client.py @@ -419,7 +419,8 @@ def place_market_order(self, product_id, side, size=None, funds=None, return self.place_order(**params) - def place_stop_order(self, product_id, stop_type, price, size=None, funds=None, + def place_stop_order(self, product_id, stop_type, price, limit_price=None, + size=None, funds=None, client_oid=None, stp=None, overdraft_enabled=None, @@ -432,6 +433,7 @@ def place_stop_order(self, product_id, stop_type, price, size=None, funds=None, loss: Triggers when the last trade price changes to a value at or below the stop_price. entry: Triggers when the last trade price changes to a value at or above the stop_price price (Decimal): Desired price at which the stop order triggers. + limit_price (Decimal): Limit price when stop order is triggered (defaults to stop price) size (Optional[Decimal]): Desired amount in crypto. Specify this or `funds`. funds (Optional[Decimal]): Desired amount of quote currency to use. @@ -463,7 +465,7 @@ def place_stop_order(self, product_id, stop_type, price, size=None, funds=None, 'price': price, 'order_type': None, 'stop': stop_type, - 'stop_price': price, + 'stop_price': price if limit_price is None else limit_price, 'size': size, 'funds': funds, 'client_oid': client_oid, From ccecdc67edc8326648f0696da92b1defff7bc05f Mon Sep 17 00:00:00 2001 From: Beni Bienz Date: Thu, 1 Jul 2021 20:49:48 -0600 Subject: [PATCH 2/2] get the price params the right way round --- cbpro/authenticated_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cbpro/authenticated_client.py b/cbpro/authenticated_client.py index f8e2aaae..fbd2d836 100644 --- a/cbpro/authenticated_client.py +++ b/cbpro/authenticated_client.py @@ -462,10 +462,10 @@ def place_stop_order(self, product_id, stop_type, price, limit_price=None, params = {'product_id': product_id, 'side': side, - 'price': price, + 'price': price if limit_price is None else limit_price, 'order_type': None, 'stop': stop_type, - 'stop_price': price if limit_price is None else limit_price, + 'stop_price': price, 'size': size, 'funds': funds, 'client_oid': client_oid,