forked from debanshur/algotrading
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimple.py
31 lines (24 loc) · 765 Bytes
/
simple.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
import logging
from kiteconnect import KiteConnect
from modules import auth
logging.basicConfig(level=logging.INFO)
userdata = auth.get_userdata()
kite = KiteConnect(api_key=userdata['api_key'])
kite.set_access_token(userdata['access_token'])
# Place an order
try:
order_id = kite.place_order(
variety=kite.VARIETY_AMO,
exchange=kite.EXCHANGE_NSE,
tradingsymbol="SBIN",
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=10,
product=kite.PRODUCT_CNC,
order_type=kite.ORDER_TYPE_MARKET
)
logging.info("Order placed. ID is: {}".format(order_id))
except Exception as e:
logging.info("Order placement failed: {}".format(e.message))
# Fetch all orders
orders = kite.orders()
print(orders)