Angel Broking openApi integration
Project description
SMARTAPI-PYTHON
SMARTAPI-PYTHON is a Python library for dealing AMX,that is a set of REST-like HTTP APIs that expose many capabilities required to build stock market investment and trading platforms. It lets you execute orders in real time.
Installation
Use the package manager pip to install smartapi-python.
pip install smartapi-python
Usage
# package import statement
from smartapi import SmartConnect
#create object of call
obj=SmartConnect()
#login api call
data = obj.generateSession("D88311","Angel@444")
refreshToken= data['data']['refreshToken']
#fetch User Profile
userProfile= obj.getProfile(refreshToken)
#place order
try:
orderparams = {
"variety": "NORMAL",
"tradingsymbol": "SBIN-EQ",
"symboltoken": "3045",
"transactiontype": "BUY",
"exchange": "NSE",
"ordertype": "LIMIT",
"producttype": "INTRADAY",
"duration": "DAY",
"price": "19500",
"squareoff": "0",
"stoploss": "0",
"quantity": "1"
}
orderId=obj.placeOrder(orderparams)
print("The order id is: {}".format(orderId))
except Exception as e:
print("Order placement failed: {}".format(e.message))
#logout
try:
logout=obj.terminateSession('D88311')
print("Logout Successfull")
except Exception as e:
print("Logout failed: {}".format(e.message))
#websocket
from smartapi import SmartSocket
FEED_TOKEN= "your feed token"
CLIENT_CODE="your client code"
token="channel you want the information of" #"nse_cm|2885&nse_cm|1594&nse_cm|11536"
ss = SmartSocket(FEED_TOKEN, CLIENT_CODE)
def on_tick(ws, tick):
print("Ticks: {}".format(tick))
def on_connect(ws, response):
ws.send_request(token)
def on_close(ws, code, reason):
ws.stop()
# Assign the callbacks.
ss.on_ticks = on_tick
ss.on_connect = on_connect
ss.on_close = on_close
ss.connect( )
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smartapi-python-1.0.3.tar.gz.
File metadata
- Download URL: smartapi-python-1.0.3.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02424de98c7555ddd0895a23569da6a37c84beb15724404506ddf70db761584e
|
|
| MD5 |
5c15d4a3c8e2e04514140e8002a20102
|
|
| BLAKE2b-256 |
e73cc393072a19a6c0b6d78d8dd600f2271703203c9cbc7405a91b3bacba2d3c
|
File details
Details for the file smartapi_python-1.0.3-py3-none-any.whl.
File metadata
- Download URL: smartapi_python-1.0.3-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d44d61a831e19c4b3f8590f0db64d116d8cae4344f0bf78cd941eb03c3ac802
|
|
| MD5 |
713956d05804b8b49406073936b27e92
|
|
| BLAKE2b-256 |
31c473091863c32291141a2a60fd34e136e6c23469ac5dd2e521d73fade648d3
|