krishnavelu / alice_blue

Official Python library for Alice Blue API trading
GNU General Public License v3.0
134 stars 82 forks source link

Basket order of StopLossLimit orders is placing with price 0 #345

Closed dheeruasdf closed 2 years ago

dheeruasdf commented 3 years ago

Hi @krishnavelu,

When i am trying to place an order of StopLossLimit, then the order is being placed with price 0.0 value and it is not respecting the value I have given.

krishnavelu commented 3 years ago

Read this and follow before creating a new issue...

dheeruasdf commented 3 years ago

This is the sample code which am using

def place_basket_order():
    print('placed basket order')
    order1 = {"instrument": ce_script,
              "order_type": OrderType.StopLossLimit,
              "quantity": quantity,
              "price": ce_ltp - 10,
              "trigger_price": ce_ltp,
              "transaction_type": TransactionType.Sell,
              "product_type": ProductType.Intraday}
    order2 = {"instrument": pe_script,
              "order_type": OrderType.StopLossLimit,
              "quantity": quantity,
              "price": pe_ltp - 10,
              "trigger_price": pe_ltp,
              "transaction_type": TransactionType.Sell,
              "product_type": ProductType.Intraday}
    orders = [order1, order2]
    return alice.place_basket_order(orders)

Here although I have passed the price, the order is being placed with price 0.0 image

krishnavelu commented 3 years ago

The error message shown above and the fix you've done and the problem you are facing, doesn't have any relationship with your fix. Also it shows multiple merge pull request in the PR.

image

tdheeraj333 commented 3 years ago

Hi @krishnavelu ,

The problem is recently NSE has disabled Stoploss Market for F&O orders and thus when i place an order with trigger price and no price i.e; price : 0.0 it is failing with that error.

This is the explanation I have received from alice_blue.

and when I have checked the code I have noticed that the if logic of checking Order.StoplossLimit comes after the Order.Limit but as I am placing an order for Order.StoplossLimit it is going to the else block of Order.Limit and making the price to 0.0

I have tested this change in my local and its working fine.

I am sorry about the commits. I didn't noticed the other commits. I shall send the updated pull request.

krishnavelu commented 2 years ago

@dheeruasdf fixed in develop, Closing this.