Skip to content

Commit 1a646d4

Browse files
Add a validation check to prevent positive quantity
Signed-off-by: camille-bouvy-frequenz <[email protected]>
1 parent 0e6198d commit 1a646d4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/frequenz/client/electricity_trading/_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ def validate_params(
404404
validate_decimal_places(price.amount, PRECISION_DECIMAL_PRICE, "price")
405405
if not isinstance(quantity, _Sentinel) and quantity is not None:
406406
validate_decimal_places(quantity.mw, PRECISION_DECIMAL_QUANTITY, "quantity")
407+
if quantity.mw <= 0:
408+
raise ValueError("Quantity must be positive")
407409
if not isinstance(stop_price, _Sentinel) and stop_price is not None:
408410
raise NotImplementedError(
409411
"STOP_LIMIT orders are not supported yet, so stop_price cannot be set."

0 commit comments

Comments
 (0)