Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. usrikanth
    U
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    usrikanth

    @usrikanth

    0
    Reputation
    2
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    usrikanth Follow

    Best posts made by usrikanth

    This user hasn't posted anything yet.

    Latest posts made by usrikanth

    • RE: Kill or reset sws connection

      I assume your deployed strategy is running while you redeploy a new strategy, and this is leaving the websocket in previous deployment still alive, causing a leak.

      One simple way is to handle keyboard interrupt.
      https://stackoverflow.com/questions/4205317/capture-keyboardinterrupt-in-python-without-try-except

      Make sure you do the websocket connection inside a new thread. Use the main thread for the signal handler as shown in above url. Perform cleanup (unsubscribe+disconnect) in the signal handler function.

      posted in Python SDK
      U
      usrikanth
    • RE: Exit position using SmartAPI?

      @aniket I just started using the api recently, and this is what I do. To exit a position, I just create the 'transaction type' of the exit order based on whether 'qty' value in my position is +ve or -ve. The piece of code in my system that does this. Hope this helps.

      def createExitOrders(self):
          orders = []
          for leg in self.position:
              orders.append((leg['symbol'], leg['symboltoken'], abs(leg['qty']), 'buy' if leg['qty'] < 0 else 'sell'))
          return orders
      
      posted in Python SDK
      U
      usrikanth