2. What is Algo Trading?
• Algorithmic trading combines computer programming and financial
markets to execute trades at precise moments.
• Algorithmic trading attempts to strip emotions out of trades, ensures
the most efficient execution of a trade, places orders instantaneously
and may lower trading fees.
2
3. • Common trading strategies include trend-following
strategies, arbitrage opportunities, and index fund rebalancing.
• Algorithmic trading is also executed based on trading
volume (volume-weighted average price) or the passage of time
(time-weighted average price).
• To get started with algorithmic trading, you must have
computer access, network access, financial market knowledge, and
coding capabilities( Python preferred ).
3
4. Why Algo Trading?
• Trades are executed at the best possible prices.
• Trade order placement is instant and accurate (there is a high chance of execution at the desired
levels).
• Trades are timed correctly and instantly to avoid significant price changes.
• Reduced transaction costs.
• Reduced the possibility of mistakes by human traders based on emotional and psychological
factors.
• Reduced risk of manual errors when placing trades.
• Strategies can be backtested using available historical and real-time data to see if it is a
profitable trading strategy.
4
6. Logging in
import requests
import json
import hashlib
from zebullconnect.zebullapi import Zebullapi
sas_api = Zebullapi(user_id='Your_user_id',
api_key='Your_api_key')
response = sas_api.getEncryptionKey()
PRESENTATION TITLE 6
Installation of the Python API
pip install --upgrade zebull
7. Fetching Scrips using Symbol
and Exchange
scrip_response = sas_api.get_scrips(symbol='search_symbol_name', exchange=
['exchange_name'])
#Sample call of the function
scrip_response = sas_api.get_scrips(symbol='TCS', exchange=
[sas_api.EXCHANGE_NSE])
# SAMPLE RESPONSE
# {.....'exch': 'NSE', 'exchange': None, 'exchange_segment': 'nse_cm',
'symbol': 'TCS-EQ', 'token': '11536', 'instrument_name': 'TATA CONSULTANCY
SERV LT'....}
7
8. Available exchanges are as below
# sas_api.EXCHANGE_NSE --- For NSE Cash
# sas_api.EXCHANGE_NFO --- For NSE DERIVATIVES
# sas_api.EXCHANGE_CDS --- For NSE Currency Derivatives
# sas_api.EXCHANGE_BSE --- For BSE Cash
# sas_api.EXCHANGE_BSE --- For BSE Derivatives
# sas_api.EXCHANGE_BSE --- For BSE Currency Derivatives
# sas_api.EXCHANGE_MCX --- For MCX Contracts
8
9. Placing and Squaring off Orders
9
# # Place Order placeorderresp = sas_api.place_order(complexty=sas_api.REGULAR_ORDER,
discqty='0', exch=sas_api.EXCHANGE_NSE, pCode='MIS', price='140.0', qty='1',
prctyp=sas_api.LIMIT_ORDER, ret='Enter_your_retention_type', trading_symbol='49234',
transtype=sas_api.BUY_ORDER, trigPrice='139.0')
# SAMPLE RESPONSE # {['stat': 'Ok', 'nestOrderNumber': '191015000018737']}
# # Square of position
squareoffresp = sas_api.squareoff_positions(exchange=sas_api.EXCHANGE_NSE,
symbol='49234', qty='0', pCode='MIS')
# SAMPLE RESPONSE
# {"stat": "Ok","nestOrderNumber:"200626000052824"}
10. Getting Positions and Orders
10
# Fetch Order Book orderresp = sas_api.order_data()
# ===>No Parameters are passed to get response
# SAMPLE RESPONSE # [{....... "Prc": "1454.90", "RequestID": "1", "Cancelqty": 0,
"discQtyPerc": "10", "Qty": 8, "Prctype": "SL", "Status": "rejected","Exchange":
"NSE" ,"Avgprc": "00.00", "Trgprc": "1450.90",.....}]
# This one get method and no input parameters and output will be bunch of data's are
shown on response
# Fetch Trade Book tradebookresp = sas_api.tradebook()
# ===>No Parameters are passed to get response # SAMPLE RESPONSE # This one also get
method and no input parameters and data's will be shown
11. Thank You
Puneet Tewani
CEO
Fox Trading Solutions
Cell : +919799871428
Email : info@foxtradingsolutions.com
Twitter : @puneet_tewani
PRESENTATION TITLE 11