The jtrader
command provides set of utilities to manage how you log in and interact with your broker’s account. The idea is that you should not use your credentials in the code ever. Additionally it may provide utilities to interact with your account from command line. Currently it support Zerodha only.
jtrader
is the root command, it will then have sub-commands for each of the brokers
$ jtrader
Usage: jtrader [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
zerodha Command line utilities for managin Zerodha account Get started
by...
Overview of utilties available with zerodha -
$ jtrader zerodha
Usage: jtrader zerodha [OPTIONS] COMMAND [ARGS]...
Command line utilities for managin Zerodha account Get started by creating
a session
$ jtrader zerodha startsession
Options:
--help Show this message and exit.
Commands:
configdir Print app config directory location
rm Delete stored credentials or sessions config To delete...
savecreds Saves your creds in the APP config directory
startsession Saves your login session in the app config folder
This is the preffered method for logging in to your Zerodha account
$ jtrader zerodha startsession
User ID >: USERID
Password >:
Pin >:
Logged in successfully as XYZ
Saved session successfully
This will save your session in the config folder.
Once you have done this in your code you can call set_access_token
or load_session
to use this session. Please note that like your browser login session expires after some time, same way this session will also expire but this is much safer than storing your credentials in code or plain text.
from jugaad_trader import Zerodha
kite = Zerodha()
kite.set_access_token() # loads the session from config folder
profile = kite.profile()
This methods saves credentials in your config folder in ini
format.
⚠️ Please note that you are storing your password in plain text
$ jtrader zerodha savecreds
Saves your creds in app config folder in file named .zcred
User ID >: USERID
Password >:
Pin >:
Saved credentials successfully
Once you have done this, you can call load_creds
followed by login
.
from jugaad_trader import Zerodha
kite = Zerodha()
kite.load_creds()
kite.login()
print(kite.profile())
jugaad-trader
uses python click for its CLI. Click provides get_app_dir
function to get config folder. Refer to documentation on how it works.
You can simple run below command to get the config folder location
$ jtrader zerodha configdir
In case you wish to delete configuration, you can delete using rm
command-
To delete SESSION
$ jtrader zerodha rm SESSION
To delete CREDENTIALS
$ jtrader zerodha rm CREDENTIALS
jugaad-trader
home