Navigation

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

    Learner

    @Learner

    0
    Reputation
    5
    Posts
    3
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Learner Follow

    Best posts made by Learner

    This user hasn't posted anything yet.

    Latest posts made by Learner

    • RE: python error

      @admin Hello Sir, I know my question isn't relevant in this thread. Please excuse me because I'm unable find a link or button to ask a new question in this forum.

      Sir, I'm able stream data from websocket(python). Now how to use this live data to create a strategy. I already have the required charts and indicator codes which I have tested on historicaldata api and working as intended. Please tell me how to use the data that gets printed from websocket API.

      Thanks.

      posted in General Discussion
      L
      Learner
    • RE: how to Convert LTP to OHLC

      @admin how to get in touch with your software team? Please provide link.

      posted in Python SDK
      L
      Learner
    • RE: how to Convert LTP to OHLC

      @admin Sir, forgive me. I have a limited understanding of how python works. From whatever I have understood from your reply, I have searched online for datetime script and modified it accordingly.

      Below is the python script which fetches current date time.

      import time
      from datetime import datetime
      import pytz

      Asia time zone

      IST = pytz.timezone('Asia/Kolkata')
      datetime_ist = datetime.now(IST)
      print("Datetime:",
      datetime_ist.strftime('%Y/%m/%d %H:%M:%S'))

      I have merged the time script with LTP API and I'm getting the below response.

      Datetime: 2021/10/14 11:23:25
      {'data': {'close': 481.7,
      'exchange': 'NSE',
      'high': 491.9,
      'low': 482.0,
      'ltp': 489.25,
      'open': 482.0,
      'symboltoken': '3045',
      'tradingsymbol': 'SBIN-EQ'},
      'errorcode': '',
      'message': 'SUCCESS',
      'status': True}

      Can you please tell me how to create DataFrame that has datetime, open high low close values?

      Thank you

      posted in Python SDK
      L
      Learner
    • RE: how to Convert LTP to OHLC

      @admin Hello Sir, thanks for replying. I have searched the forum and found the below code:

      from smartapi import SmartConnect
      SmartApi =SmartConnect(api_key=apikey)
      login = SmartApi.generateSession(username, pwd)

      exchange = "NSE"
      tradingsymbol = "SBIN-EQ"
      symboltoken = 3045
      SmartApi.ltpData("NSE", "SBIN-EQ", "3045")

      I've used it and got below output:

      {'data': {'close': 469.25,
      'exchange': 'NSE',
      'high': 478.5,
      'low': 468.1,
      'ltp': 471.4,
      'open': 470.0,
      'symboltoken': '3045',
      'tradingsymbol': 'SBIN-EQ'},
      'errorcode': '',
      'message': 'SUCCESS',
      'status': True}

      Can you please tell me how to load the above output into a DataFrame along with date and time. Thank you.

      posted in Python SDK
      L
      Learner
    • RE: how to Convert LTP to OHLC

      @admin Hello Sir, I'm getting response like this. It is not showing open high low close values. Please tell me how to get ohlc values.

      __on_open################
      {'task': 'cn', 'channel': 'NONLM', 'token': '0972771668', 'user': 'V314538', 'acctid': 'V314538'}
      2021-10-11 08:12:27.072680 : Start task in the background
      {'task': 'hb', 'channel': '', 'token': '0972771668', 'user': 'V314538', 'acctid': 'V314538'}
      on open
      Ticks: [{'ak': 'ok', 'msg': 'connected', 'task': 'cn'}]
      Ticks: [{'ak': 'ok', 'msg': 'heartbeat', 'task': 'hb'}]
      Ticks: [{'e': 'nse_cm', 'ltp': '2684.80', 'ltq': '13', 'ltt': 'NA', 'name': 'sf', 'tk': '2885'}]
      Ticks: [{'ap': '2694.39', 'bp': '2684.80', 'bq': '7', 'bs': '69', 'c': '2671.25', 'cng': '13.55', 'e': 'nse_cm', 'lo': '2676.55', 'ltp': '2684.80', 'ltq': '13', 'ltt': '11/10/2021 13:42:27', 'name': 'sf', 'nc': '00.5073', 'sp': '2684.95', 'tbq': '187430', 'tk': '2885', 'to': '11683209144.36', 'tsq': '526331', 'v': '4336124'}]
      Ticks: [{'name': 'tm', 'tvalue': '11/10/2021 13:42:28'}]
      2021-10-11 08:12:28.395460 : Start task in the background
      {'task': 'hb', 'channel': '', 'token': '0972771668', 'user': 'V314538', 'acctid': 'V314538'}

      posted in Python SDK
      L
      Learner