forked from ramesh8v/zerodha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
49 lines (42 loc) · 946 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from kitewrapper import KiteFront
from kiteconnect import KiteConnect
q_arr = [
'question1',
'question2',
"question3",
'question4',
'question5',
'question6',
]
#answer array
a_arr = [
"ans1",
"ans2",
"ans3",
"ans4",
"ans5",
"ans6"
]
auth={k:v for k,v in zip(q_arr,a_arr)}
auth['user_id'] = 'UDI'
auth['password'] = 'PASS1'
# get session parameters
k_browser = KiteFront(auth=auth)
k_browser.connect()
z = k_browser.zsession()
# Use session parameters with native api
kite = KiteConnect(api_key="kitefront")
kite.set_access_token(z['access_token'])
# Place an order
try:
order_id = kite.order_place(tradingsymbol="INFY",
exchange="NSE",
transaction_type="BUY",
quantity=1,
order_type="MARKET",
product="NRML")
print("Order placed. ID is", order_id)
except Exception as e:
print("Order placement failed", e.message)
# Fetch all orders
print(kite.orders())