Jump to content

WebSocket Help for beginner


Recommended Posts

Hello ,

I am trying to use Websockets in AutoIt.
It is to fetch live stock market prices , API is provided and documentation available for python language.

The link for the code snippet is :
https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Introduction
https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Instruments/paths/~1instruments~1subscription/post

 

https://github.com/symphonyfintech/xts-pythonclient-api-sdk

 

Second Link is to subscribe to a list of ExchangeInstruments.

Now I would like to get live stock ltp (LastTradedPrice) for a few stocks whose "ExchangeInstrumentID" I know.
I am able to use the WinHttp object to perform actions using simple codes like below :
I have the secretKey and appkey and can generate the needed token. And get the unique ExchangeInstrumentID.

Below code is just for example of how I am using WinHttp. Unrelated to socket part.

Global $InteractiveAPItoken = IniRead(@ScriptDir & "\Config.ini", "token", "InteractiveAPItoken", "NA")
    $baseurl = "https://brokerlink.com/interactive/"
    $functionurl = "orders"

    $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    $oHTTP.Open("POST", $baseurl & $functionurl, False)
    $oHTTP.SetRequestHeader("Content-Type", "application/json;charset=UTF-8")
    $oHTTP.SetRequestHeader("authorization", $InteractiveAPItoken)
    
    $pD = '{  "exchangeSegment": "NSEFO",  "exchangeInstrumentID": ' & $exchangeInstrumentID & ',  "productType": "' & $producttype & '",  "orderType": "MARKET",  "orderSide": "' & $orderside & '",  "timeInForce": "DAY",  "disclosedQuantity": 0,  "orderQuantity": ' & $qty & ',  "limitPrice": 0,  "stopPrice": 0,  "orderUniqueIdentifier": "' & $orderidentifier & '"}'
    
    $oHTTP.Send($pD)
    $oReceived = $oHTTP.ResponseText
    $oStatusCode = $oHTTP.Status


    
    
But am struggling to understand and use socket.
Would be of great help if you can have a look at the link mentioned above and help with the code sample for AutoIt.
To connect and listen to a socket.

Thanks a lot
 

Edited by adityaparakh
Link to comment
Share on other sites

  • 3 weeks later...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...