Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="smartapi-python",
version="1.2.9",
version="1.3.4",
author="ab-smartapi",
author_email="[email protected]",
description="Angel Broking openApi integration",
Expand Down
42 changes: 42 additions & 0 deletions test/test1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from SmartApi.smartConnect import SmartConnect
import pyotp

api_key = 'api-key'
username = 'client-code'
pwd = 'pin'
smartApi = SmartConnect(api_key)
token = "QR-value code"
totp=pyotp.TOTP(token).now()
correlation_id = "abcde"
data = smartApi.generateSession(username, pwd, totp)
# print(data)
authToken = data['data']['jwtToken']
refreshToken = data['data']['refreshToken']
feedToken = smartApi.getfeedToken()
# print("Feed-Token :", feedToken)
res = smartApi.getProfile(refreshToken)
# print("Res:", res)
smartApi.generateToken(refreshToken)
res=res['data']['exchanges']

try:
orderparams = { "variety": "NORMAL",
"tradingsymbol": "RELIANCE-EQ",
"symboltoken": "122334875538",
"transactiontype": "BUY",
"exchange": "NSE",
"ordertype": "LIMIT",
"producttype": "DELIVERY",
"duration": "DAY",
"price": "2430",
"squareoff": "0",
"stoploss": "0",
"quantity": "8"
}
orderId=smartApi.placeOrder(orderparams)
print("The order id is: {}".format(orderId))
except Exception as e:
if isinstance(e, TypeError):
print("Order placement failed: Invalid request parameters.")
else:
print("Order placement failed: {}".format(str(e)))