Skip to main content

There is a new major feature has been released in the websockets where now the developers can run the websokcets in background on a thread.

Without Thread

from thefirstock import thefirstock


handler = thefirstock.WebSocketHandler("{userId}")
listOfTradingSymbol = ["Nifty Bank", "Nifty 50"]


def subscribe_feed_data(data):
    print(data)


# Modify the websocket_connection function to accept the handler as an argument
thread = thefirstock.websocket_connection(
    handler,
    listOfTradingSymbol,
    socket_connection=1,
    activate_sub_feed=True,
    callback_sub_feed=subscribe_feed_data
)

Running in background

from thefirstock import thefirstock


handler = thefirstock.WebSocketHandler("PV0013")
listOfTradingSymbol = ["Nifty Bank", "Nifty 50"]


def subscribe_feed_data(data):
    print(data)


# Modify the websocket_connection function to accept the handler as an argument
thread = thefirstock.websocket_connection(
    handler,
    listOfTradingSymbol,
    socket_connection=1,
    activate_sub_feed=True,
    callback_sub_feed=subscribe_feed_data,
    run_in_background=True
)

if thread:
    thread.join()

curl updates

  • New parameters have been added to the Get Quotes API
{
    "VWAP": "520.75",
    "totalSellQuantity": "6300",
    "totalBuyQuantity": "5150",
    "openInterest": "24050"
}
{
    "freezeQuantity": "1500"
}

Link Updates

The following Trade files links has been updated with new parameter Freeze Quantity:

  • The Python package has been updated to automatically convert passwords into SHA256 hashes prior to submission to the login URL.
  • The package now includes a multi-login feature, enabling simultaneous login for multiple users, with each user's session being individually stored.
  • For all APIs, it is now required to pass the userId. The corresponding jKey session linked to the userId will be utilized for executing the API.
  • The following methods have been updated to require trading symbols instead of tokens:
    • Get Multi Quotes LTP
    • Get Multi Quotes
    • Day Interval Time Price Series
    • Time Price Series
    • Security Info
    • Get Quotes
  • The method for accessing the websocket has been entirely revamped. Detailed information will be available in an upcoming blog post. Additionally, sample code illustrating the new method can be found in the examples section.
  • In current version for the login api the password needs to be hashed using SHA256 and then passed.
  • Recent modifications to various APIs now require the use of 'trading symbol' in place of the previously used 'token' parameter. This change affects the following APIs:
    • Get Multi Quotes LTP
    • Get Multi Quotes
    • Day Interval Time Price Series
    • Time Price Series
    • Security Info
    • Get Quotes
  • The subscription format has been completely changed for websocket and there will be shortly blogs on how to use websockets.