-
Notifications
You must be signed in to change notification settings - Fork 1
/
Trade.py
66 lines (51 loc) · 1.72 KB
/
Trade.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import logging
def Place_order(kite,tradingSymbol, qty, direction, exchangeType, product, orderType):
try:
orderId = kite.place_order(
variety=kite.VARIETY_REGULAR,
exchange=exchangeType,
tradingsymbol=tradingSymbol,
transaction_type=direction,
quantity=qty,
product=product,
order_type=orderType)
logging.info('Order placed successfully, orderId = %s', orderId)
return 'Done'
except Exception as e:
return e
def Place_Limit(kite,tradingSymbol, qty, direction, exchangeType, product, orderType,price):
try:
orderId = kite.place_order(
variety=kite.VARIETY_REGULAR,
exchange=exchangeType,
tradingsymbol=tradingSymbol,
transaction_type=direction,
quantity=qty,
product=product,
order_type=orderType,
price=price)
logging.info('Order placed successfully, orderId = %s', orderId)
return 'Done'
except Exception as e:
return e
def Kite_login(Info,access_token=None):
from kiteconnect import KiteConnect
import Login
# try:
# kite = KiteConnect(Info['APIKey'], access_token)
# print('Login Successful')
# except:
kite = None
try:
kite = Login.login(Info['APIKey'],Info['APISecret'],Info['ClientID'],Info['ZerodhaPassword'],Info['Totp'])
print("Login Successful")
except Exception as e:
print(e)
return kite
import json
with open(f'./Info/User.json','r') as f:
Info = json.load(f)
# with open(f'./Access_token.txt','r') as f:
# access_token = f.read()
# print(access_token)
# kite = Kite_login(Info)