π Add to Chrome β Itβs Free - YouTube Summarizer
Category: N/A
No summary available.
00:00
hello guys welcome back to another video today we'll look into how we can have multiple login sessions in finia where we can do all the actions like placing orders getting positions getting order book and More in both the sessions before that I want to explain a little on why finia has this model like if you
00:16
compare with zeroda zeroda has an access token which is valid for the whole day but in finvasia it's based on session token which is valid for only that session that means if he close the program or if he log out that session will be termin and we have to create a
00:31
new session to trade now that we have covered the part let's see what are the credentials we need to log into API we need user ID password top token API key vendor code and IMEI number all these credentials I believe will be available in prism website of invia once you have
00:47
copied all the credentials we'll go to login. py I've imported some necessary packages we need the norin API is the official python sare Apper by Shia I've also imported logging which is used to keep track of events in the code and I've also imported PP which will use to
01:03
generate top to log in I also imported time and credentials as Keys now let's create the entry point for the code that is if name is equal to Main and we'll call the main function now let's create the main function in the main function I'll
01:18
copied some code from the API documentation which creates a global instance of the API which will let us use the methods from the SDK rapper once the API Global instance is created we can call login function which is login status is equal to api. login and if you
01:34
can see this login function accepts multiple parameters like user ID password 2fa vendor code API secret and IMI number we'll pass all these credentials to this login function the first credential we need is user ID we'll say user ID is equal to keys do
01:51
user ID and we'll import all the other credentials in the same way once the API login function is called we'll get the response back let's see what is the response structure in API documentation if you see the response structure we can see there's s user token element we want to extract this from the response in our
02:08
code we can do that by creating a new variable called s user token and we'll get the response get the S user token once we have extracted the S user token we'll save this in a token. txt file the reason we are doing this is because
02:24
we'll create a new instance using this user token now let's print the login status with some details once that is done let's create a while loop while true we will get the sensex ltp which is api. get code and we'll print this ltp after this is done we'll give time do
02:40
sleep for a second what this is doing is the V Loop will run continuously for every second until the program is stopped the main functionality of login is done now let's run this program and confirm everything is working fine I'll open the new terminal and run this
02:55
file once I run the program we can see user token is printed and sensex ltp data is printed every second and we can also see there was a new token. txt file created if you go to the file we can see our user token is Sav now let's go to the second file where we will create a
03:12
new instance of our current running session and run the same V Loop and print the ltp the goal here is to have both the instances running in the second login file I'll just paste the code here and explain it as almost all the code is same as the parent login file I pasted the code the difference in this file is
03:28
that we are reading the user token from token. txt file which was created in login.
py file and instead of using ap. login we are using api.
session which will extend the parent session essentially creating two successful instances we have the same V Loop to
03:45
show both instances are running successfully now let's go to terminal I'll split the terminal to show you guys how both login. pii file and second login.
P I run I'll run the first file now I'll run the second
04:01
file as you guys can see both the instances are running successfully a thing to keep in mind we have to run the login. py file first because that's where we are creating the session token and that session is consumed in the second file we can also create as sessions as we want but keep in mind
04:17
creating each instance May essentially slow down the response time thank you so much for watching the video I hope you guys like it see you guys in the next one