Jugad trader is an algorithmic trade execution library written in python for Zerodha and Upstox. You can programatically execute trades, retrieve your order and trade books, holdings, margins among other things using Jugaad-trader.
PLEASE USE THIS LIBRARY AT YOUR OWN RISK, THERE ARE NO GURANTEES ASSOCIATED WITH THIS LIBRARY. PLEASE USE OFFICIAL API SUBSCRIPTION FOR ALL SERIOUS USAGE.
pip install jugaad-trader
Library provides a CLI to manage your session/credentials. It is not recommended to use the credentials directly in the code.
Step 1 - Start session with jtrader
CLI using your zerodha credentials
$ jtrader zerodha startsession
User ID >: Zerodha User Id
Password >:
Pin >:
Logged in successfully
Above command stores the session object in pickle format in your app directory. (Run jtrader zerodha configdir
to find out the config directory.)
Please read CLI reference for more details
Step 2 - Instantiate Zerodha
and issue commands
from jugaad_trader import Zerodha
kite = Zerodha()
# Set access token loads the stored session.
# Name chosen to keep it compatible with kiteconnect.
kite.set_access_token()
# Get profile
profile = kite.full_profile()
print(profile)
# Get margin
margins = kite.margins()
print(margins)
# Get holdings
holdings = kite.holdings()
print(holdings)
# Get today's positions
positions = kite.positions()
print(positions)
# Get today's orders
orders = kite.orders()
print(orders)
# Finally placing an order
order_resp = kite.place_order(variety=z.VARIETY_REGULAR,
tradingsymbol="INFY",
exchange=kite.EXCHANGE_NSE,
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=1,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_CNC)
print(order_resp)
This class is mostly compatible with official KiteConnect class. There are some methods that are not supported thru browser (for example ‘instruments’), I would request community to report which methods are working and which are not.
Step 1 Save your credentials configuration using jtrader
CLI
$ jtrader upstox savecreds
Saves your creds in app config folder in file named .ucred
User ID >: USERID
Password >:
Pin >:
Saved credentials successfully
Step 2 - Instantiate Upstox
and issue commands
from jugaad_trader import Upstox
user_id = "USERID"
password = "PASSWORD"
twofa = "TWOFA"
u = Upstox(user_id, password, twofa)
# Login
u.login()
# Get profile information
profile = u.get_client_info()
# More documentation to follow
Please note that Upstox support is still work in progress. Upstox websites uses websockets for all server interaction as opposed normal HTTP requests which makes it a slightly difficultf to reverse engineer.
https://github.com/jugaad-py/jugaad-trader.git
Introduction 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. Getting started jtrader is the root command, it will then have sub-commands for each of the brokers $ jtrader Usage: jtrader [OPTIONS] COMMAND [ARGS].
2020-06-19 This is part of jugaad-trader documentation, with detailed reference for Upstox
related functions