In the above example we are sending the Loginrequest,this method takes three arguments
Callback: this is the function where the application will be handling the response
Endpoint: NorenOMS address
MessageData: parameters of the request being made.
The Callback is of signature
public delegate void OnResponse(NorenResponseMsg Response,bool ok)
A Typical callback will be handled as below
public static voidOnAppLoginResponse(NorenResponseMsg Response, bool ok)
{
LoginResponse loginResp= Response as LoginResponse;
if(loginResp.stat=="Ok")
{
//do all work here
}
}
The Response is casted to expected DataType ie in this example being LoginResponse, stat is checked to see if the request was successful.
Login and Session
Login
public bool SendLogin(OnResponse response,string endPoint,LoginMessage login)
connect to the broker, only once this function has returned successfully can any other operations be performed
session id, avilable subsequently on login success with method UserToken
lastaccesstime
lastaccesstime
spasswordreset
Y
If Y Mandatory password reset to be enforced. Otherwise the field will be absent.
exarr
array of strings with enabled exchange names
uname
User name
prarr
array of Product Obj with enabled products, as defined below
actid
Account Id
email
Email Id
brkid
Broker Id
emsg
This will be present only if Login fails.(Redirect to force change password if message is “Invalid Input : Password Expired” or “Invalid Input : Change Password”)
UserDetails
public bool SendGetUserDetails(OnResponse response)
RequestDetails:NoParams
ResponseDetails:UserDetailsResponse
Json Fields
Possible value
Description
exarr
list of exchanges enabled
orarr
ordertypes enabled for the user
prarr
list of product object
brkname
Region Category
brnchid
Branch Category
actid
Account Id
email
Email Id
Logout
public bool SendLogout(OnResponse response)
Closes the session opened with the server.
RequestDetails:NoParams
napi.SendLogout();
ResponseDetails:LogoutResponse
Json Fields
Possible value
Description
stat
Ok or Not_Ok
Login Success Or failure status
ForgotPassword
public bool SendForgotPassword(OnResponse response,string endpoint,string user,string pan,string dob)
RequestDetails: As Arguments
Json Fields
Possible value
Description
uid*
User Id
pan*
pan of the user
dob*
Date of birth
ResponseDetails:ForgotPasswordResponse
Json Fields
Possible value
Description
stat
Ok or Not_Ok
Success Or failure status
emsg
This will be present only if request fails.
ChangePassword
public bool Changepwd(OnResponse response,Changepwd changepwd)
RequestDetails:Changepwd
Json Fields
Possible value
Description
uid*
User Id
oldpwd*
old password of the user
pwd*
new password of the user
ResponseDetails:ChangepwdResponse
Json Fields
Possible value
Description
stat
Ok or Not_Ok
Success Or failure status
emsg
This will be present only if request fails.
SetSession
This method initializes the api with an existing session instead of creating a new session with SendLogin.
public bool SetSession(string endpoint, string uid, string pwd, string usertoken)
RequestDetails:
endpoint : server endpoint
uid : user
pwd : password
usertoken: session id from loginresponse.
ResponseDetails:True/False
WatchLists
GetWatchListNames
public boolSendGetMWList(OnResponseresponse)
Request Details : No Params
ResponseDetails:MWListResponse
GetWatchList
public bool SendGetMarketWatch(OnResponse response,string wlname)
RequestDetails:NoParams
ResponseDetails:MarketWatchResponse
AddScriptoWatchList
public bool SendAddMultiScripsToMW(OnResponse response,string watchlist,string scrips)
RequestDetails: As Arguments
ResponseDetails:StandardResponse
DeleteScriptoWatchList
public bool SendDeleteMultiMWScrips( OnResponse response,string watchlist,string scrips)
RequestDetails: As Arguments
ResponseDetails:StandardResponse
SearchScrips
public bool SendSearchScrip(OnResponse response,string exch,string searchtxt)
The call can be made to get the exchange provided token for a scrip or alternately can search for a partial string to get a list of matching scrips
Multiple criteria can be specified for the search with space
Trading Symbol:
SymbolName + ExpDate + 'F' for all data having InstrumentName starting with FUT
SymbolName + ExpDate + 'P' + StrikePrice for all data having InstrumentName starting with OPT and with OptionType PE
SymbolName + ExpDate + 'C' + StrikePrice for all data having InstrumentName starting with OPT and with OptionType C
public bool ConnectWatcher(string uri,OnFeed marketdata Handler,OnOrderFeed orderHandler)
starts the websocket, WebSocket feed has 2 types of ticks( t=touchline d=depth)and 2 stages (k=acknowledgement, f=further change in tick).
SubscribeMarketData
public bool SubscribeToken(string exch,string token)
t='tk' is sent once on subscription for each instrument. this will have all the fields with the most recent value
thereon t='tf' is sent for fields that have changed.
in the example above we see first message t='tk' with all the values, 2nd message has lasttradeprice avg price and few other fields with value changed.. note bp1 isnt sent as its still 118.45
in the next tick ( 3rd message) only last price is changed to 118.6
Request:
Fields
Possible value
Description
exch
NSE,BSE,NFO...
Exchange
token
ScripToken
MarketDataUpdates:
Accept for t, e,and tk other fields may/may not be present.
Fields
Possible value
Description
t
tf
tf represents touchline feed
e
NSE,BSE,NFO..
Exchangename
tk
22
ScripToken
lp
LTP
pc
Percentagechange
v
volume
o
Openprice
h
Highprice
l
Lowprice
c
Closeprice
ap
Averagetradeprice
oi
Open interest
poi
Previous day closing Open Interest
to1
Total open interest for underlying
bq1
Best Buy Quantity 1
bp1
Best Buy Price 1
sq1
Best Sell Quantity 1
sp1
Best Sell Price 1
UnSubscribeMarketData
public bool UnSubscribeToken(string exch,string token)