shareconnectpython 1.0.0.9
Sharekhan Data Feed Trading Api Server

# SHARECONNECT-PYTHON

    Sharekhan-Python is a Python library that provides a set of tools and functionalities for interacting with the Sharekhan trading platform. 
    With Sharekhan-Python, users can access a variety of trading-related information such as stock prices, market trends, historical data,
    stream live market data (WebSockets), and more.It also provides the ability to execute trades and orders in real time.

# Installation 
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install shareconnectpython
    
    pip install shareconnectpython
    pip install websocket

# Usage
    
    # package import statement
    from SharekhanApi.sharekhanConnect import SharekhanConnect
    
    # Make a object call
    
    api_key = "Your API KEY"
    """ version_id="Version Value """
    login = SharekhanConnect(api_key)
    
    # Print the login url
    
    """ Pass version_id if it is needed """
    print(login.login_url(version_id))
    
    # Pass the required parameters for decryption and encryption
    
    """ After Successfully Login You will receive the request token value
        then you have to decrypt the token value by using secret key and 
        then swap the request token which is a combination of RequestId and CustomerId
        Then after that decrypt the request token value. """
    
    request_token = "Valid Request Token Value"
    secret_key = "Your Secret Key value"
    session = login.generate_session(request_token, secret_key)
    
    # Generate access token
    
    """ You have to pass the encrypted request token after manipulation """
    
    requestToken="After encrypt the request token pass valid reques_token value"
    access_token=login.get_access_token(apiKey=api_key,requestToken,userId=12345,versionId=1005)
    print(access_token)
    
    # Make a object for SharekhanConnect class
    
    sharekhan = SharekhanConnect(access_token=access_token)
    
    # Place order history
    
     orderparams={
      "customerId": XXXXXX,
     "scripCode": 251731,
     "tradingSymbol": "GOLDPETAL",
     "exchange": "MX",
     "transactionType": "B",
    "quantity": 1,
     "disclosedQty": 0,
     "price": "0",
     "triggerPrice": "0",
     "rmsCode": "ANY",
     "afterHour": "N",
     "orderType": "NORMAL",
     "channelUser": "XXXXXX",
     "validity": "GFD",
     "requestType": "NEW",
     "productType": "INVESTMENT",
     "instrumentType": "FS",
     "strikePrice": -1,
     "expiry": "28/04/2023",
     "optionType": "XX"
     }
     order=sharekhan.placeOrder(orderparams)
     print("PlaceOrder: {}".format(order))
    
    # Retrieves all positions
    
    customerId="customerId < int data type>"
    order=sharekhan.trades(customerId)
    print("Postion Reports: {}".format(order))
    
    # Retrieve history of an given order
    
    exchange="exchange value <string>"
    customerId="customerId <int data type>"
    orderId="orderId <int data type>"
    order=sharekhan.exchange(exchange, customerId, orderId)
    print("Order Details: {}".format(order))
    
    # Retrieves the trade  generated by an order
    
    exchange="exchange value <string>"
    customerId="customerId <int data type>"
    orderId="orderId <int data type>"
    order=sharekhan.exchangetrades(exchange, customerId, orderId)
    print("Trade Generated By an Order : {}".format(order))
    
    
    # services Holdings
    
    customerId="customerId <int data type>"
    order=sharekhan.holdings(customerId)
    print("Holdings : {}".format(order))
    
    # Script Master
    
    exchange="exchange value <string>"
    order=sharekhan.master(exchange)
    print("Script Master : {}".format(order))
    
    
    # Historical Data
    
    exchange="exchange value <string>"
    scripcode="Unique scripcode provided by the broker <int>"
    interval="Available Intervals <string>"
    order=sharekhan.historicaldata(exchange, scripcode, interval)
    print("Holdings Data: {}".format(order))


 # websocket Programming Testing

    from SharekhanApi.sharekhanWebsocket import SharekhanWebSocket
    
     access_token = "Your Access-Token" 
    
     params={
         "access_token": access_token
     }
    
     action = 1
     mode = 1
    
     token_list = {"action":"subscribe","key":["feed"],"value":[""]}
     feed={"action":"feed","key":["ltp"],"value":["NC22,NF37833,NF37834,MX253461,RN7719"]}
    
     sws = SharekhanWebSocket(access_token)

     def on_data(wsapp, message):
         print("Ticks: {}".format(message))
    
    
     def on_open(wsapp):
         print("on open")
         # sws.subscribe(token_list)
         # sws.fetchData(feed)
         # sws.unsubscribe(feed)
    
    
     def on_error(wsapp, error):
         print(error)
    
    
     def on_close(wsapp):
         print("Close")
    
    # 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()