diff --git a/integrate/orders.py b/integrate/orders.py index fa323ff..d694937 100644 --- a/integrate/orders.py +++ b/integrate/orders.py @@ -97,6 +97,7 @@ def place_order( # noqa: C901 product_type: str, quantity: int, tradingsymbol: str, + algo_id: str, amo: Union[str, None] = None, book_loss_price: Union[float, None] = None, book_profit_price: Union[float, None] = None, @@ -117,6 +118,7 @@ def place_order( # noqa: C901 :param `product_type`: Product type. Valid values are CNC, INTRADAY, NORMAL. :param `quantity`: Quantity to transact. :param `tradingsymbol`: Trading symbol of security to transact. + :param `algo_id`: Algo Id for the order. :param `amo`: If set to True, AMO order will be placed. Defaults to False. :param `book_loss_price`: Book loss price (Applicable only for Bracket orders). :param `book_profit_price`: Book profit price (Applicable only for Bracket orders). @@ -133,6 +135,7 @@ def place_order( # noqa: C901 :type `product_type`: `str` :type `quantity`: `int` :type `tradingsymbol`: `str` + :type `algo_id`:`str` :type `amo`: `str` :type `book_loss_price`: `float` :type `book_profit_price`: `float` @@ -177,6 +180,9 @@ def place_order( # noqa: C901 if quantity == 0: raise ValueError("Quantity cannot be 0") + if algo_id == "": + raise ValueError("Algo id cannot be blank") + json_params: dict[str, Any] = locals() for k in list(json_params.keys()): if k == "self" or json_params[k] is None: diff --git a/tests/integration/orders_test.py b/tests/integration/orders_test.py index 414fefd..a36742e 100644 --- a/tests/integration/orders_test.py +++ b/tests/integration/orders_test.py @@ -49,6 +49,7 @@ def custom_order_placement( product_type: str, quantity: int, tradingsymbol: str, + algo_id:str, price: str = "ltp", trigger_price: str = "ltp", ) -> dict[str, Any]: @@ -96,6 +97,7 @@ def custom_order_placement( product_type=product_type, quantity=quantity, tradingsymbol=tradingsymbol, + algo_id=algo_id, ) elif price_type == c2i.PRICE_TYPE_LIMIT: price_value: float = ( @@ -111,6 +113,7 @@ def custom_order_placement( product_type=product_type, quantity=quantity, tradingsymbol=tradingsymbol, + algo_id=algo_id, ) elif price_type == c2i.PRICE_TYPE_SL_MKT: trigger_price_value: float = ( @@ -127,6 +130,7 @@ def custom_order_placement( quantity=quantity, tradingsymbol=tradingsymbol, trigger_price=trigger_price_value, + algo_id=algo_id, ) elif price_type == c2i.PRICE_TYPE_SL_LMT: trigger_price_value = ( @@ -148,6 +152,7 @@ def custom_order_placement( quantity=quantity, tradingsymbol=tradingsymbol, trigger_price=trigger_price_value, + algo_id=algo_id, ) assert isinstance(order, dict) diff --git a/tests/unit/orders_test.py b/tests/unit/orders_test.py index f1673b4..c536640 100644 --- a/tests/unit/orders_test.py +++ b/tests/unit/orders_test.py @@ -64,6 +64,7 @@ def test_placing_order(c2i: ConnectToIntegrate, io: IntegrateOrders) -> None: product_type=c2i.PRODUCT_TYPE_NORMAL, quantity=50, tradingsymbol="NIFTY23FEB23F", + algo_id="99999", ) # Assert that the response is a dict and contains the required keys assert isinstance(order, dict)