Navigation

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

    Best posts made by projectSB

    • AngelOne RMS is unable to quickly adjust margins for spreads!

      @admin @Moderator_1 @Moderator_2

      Hi folks,

      Please explain in which way the RMS system in AngelOne works?

      Consider a simple Calendar spread - a near PUT sell, a far PUT buy.
      Approx margin required is Rs.30000 for the whole spread.

      Situation 1:
      When I want to sell the near PUT, if I have already bought the far PUT, do I get the margin benefit?
      That is will the order execute if I have 30000 in funds, instead of the naked PUT sell margin of RS 1,20,000 approx.

      or Situation 2:
      When I want to sell the near PUT, I MUST have the full margin available (Rs. 1,20, 000 approx), regardless of the the previous far PUT (hedge) being bought or not?

      Please confirm!

      Note: In Zerodha, this margin benefit is automatic. That is, it happens like in situation 1. If I have bought my hedge beforehand, I get full margin benefit during my sell leg.

      posted in General Discussion
      P
      projectSB
    • RE: Websocket2.0 just stops after running for 1 min without any errors etc.

      @af I'm using the Websocket version 2.0 code as provided in this Github link:

      https://github.com/angel-one/smartapi-python

      This portion:

      ####### Websocket V2 sample code #######

      from SmartApi.smartWebSocketV2 import SmartWebSocketV2
      from logzero import logger

      AUTH_TOKEN = "Your Auth_Token"
      API_KEY = "Your Api_Key"
      CLIENT_CODE = "Your Client Code"
      FEED_TOKEN = "Your Feed_Token"
      correlation_id = "abc123"
      action = 1
      mode = 1
      token_list = [
      {
      "exchangeType": 1,
      "tokens": ["26009"]
      }
      ]
      sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN)

      def on_data(wsapp, message):
      logger.info("Ticks: {}".format(message))
      # close_connection()

      def on_open(wsapp):
      logger.info("on open")
      sws.subscribe(correlation_id, mode, token_list)

      def on_error(wsapp, error):
      logger.error(error)

      def on_close(wsapp):
      logger.info("Close")

      def close_connection():
      sws.close_connection()

      Assign the callbacks.

      sws.on_open = on_open
      sws.on_data = on_data
      sws.on_error = on_error
      sws.on_close = on_close

      sws.connect()

      posted in Python SDK
      P
      projectSB
    • Websocket2.0 just stops after running for 1 min without any errors etc.

      @admin - Please look into this. I'm trying to run the WebSocket 2.0. The App starts fine, tokens were subscribed, and I start getting feed properly.
      But after around 30 seconds, I see a message Attempting to Reconnect.. feed still goes fine. After, this around 20-30 seconds later the App just exits, WITHOUT any errors. This is becoming a real pain!

      Here is the log:
      2023-08-30 14:32:42,571 [{'exchangeType': 2, 'tokens': ['35048']}]
      2023-08-30 14:32:42,714 Websocket connected
      2023-08-30 14:32:42,714 Connection opened, subscriptions done
      2023-08-30 14:33:02,774 error from callback <bound method SmartWebSocketV2._on_pong of <SmartApi.smartWebSocketV2.SmartWebSocketV2 object at 0x000001AB63A9FFD0>>: byte indices must be integers or slices, not str
      2023-08-30 14:33:02,962 Websocket connected
      2023-08-30 14:33:02,962 Connection opened, subscriptions done
      2023-08-30 14:33:23,056 error from callback <bound method SmartWebSocketV2._on_pong of <SmartApi.smartWebSocketV2.SmartWebSocketV2 object at 0x000001AB63A9FFD0>>: byte indices must be integers or slices, not str
      2023-08-30 14:33:23,103 error from callback <bound method SmartWebSocketV2._on_close of <SmartApi.smartWebSocketV2.SmartWebSocketV2 object at 0x000001AB63A9FFD0>>: SmartWebSocketV2._on_close() takes 2 positional arguments but 4 were given
      2023-08-30 14:33:23,103 error from callback <bound method SmartWebSocketV2._on_close of <SmartApi.smartWebSocketV2.SmartWebSocketV2 object at 0x000001AB63A9FFD0>>: SmartWebSocketV2._on_close() takes 2 positional arguments but 4 were given

      posted in Python SDK
      P
      projectSB
    • This is how a profitable position ends up losing due to unreliable SmartAPIs: Max retries exceeded with url: /rest/secure/angelbroking/order/v1/placeOrder (Caused by ConnectTimeoutError

      @admin @Moderator_1 @Moderator_2

      Could someone please explain why I got this error while placing orders today?

      Sequence of events:
      1 order was placed and it was Completed
      LOG entry: 2024-02-16 15:04:40,330 BUY avgPrice of BANKNIFTY29FEB2446600CE: 623.45 order_ID: 240216001663375 complete

      The second order got the following error:

      LOG entry: 2024-02-16 15:04:47,346 HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Max retries exceeded with url: /rest/secure/angelbroking/order/v1/placeOrder (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0F5F12C8>, 'Connection to apiconnect.angelbroking.com timed out. (connect timeout=7)'))

      Client code: S382492

      Note:

      1. The failed order did not reach the portal at all. Had to exit remaining ones manually, with loss!

      2. I have been using the same code block for last few days, and it was working fine, so its NOT a code issue.

      3. It was only the 2nd order, thus rate limit could NOT have exceeded.

      Please provide a proper explanation, and how to rectify it. Else I will have to switch back to Zerodha. Also, try answering my previous queries, which are still open without replies.

      posted in Python SDK
      P
      projectSB