Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d8cd1ce
Merge pull request #3 from angelbroking-github/develop
vrushalikapse Nov 24, 2020
ee48512
changes in socket files and readme
vrushalikapse Nov 30, 2020
1615444
changes in endpoint url for prod
vrushalikapse Nov 30, 2020
29a05e2
changes in endpoint url for prod
vrushalikapse Nov 30, 2020
f280630
changes in readme-conflict solved
vrushalikapse Nov 30, 2020
928e6a4
changes in readme-conflict solved
vrushalikapse Nov 30, 2020
245cfb8
changes in __init__.py
vrushalikapse Nov 30, 2020
047ee2d
Merge branch 'develop' into main
vrushalikapse Nov 30, 2020
3689fc6
changes in sample.py- import statement
vrushalikapse Nov 30, 2020
920e553
Merge branch 'develop' into main
vrushalikapse Nov 30, 2020
87bf4b6
changes in version
vrushalikapse Nov 30, 2020
29accb5
Merge branch 'develop' into main
vrushalikapse Nov 30, 2020
8c6b181
changes in version
vrushalikapse Nov 30, 2020
33f1d05
Merge branch 'develop' into main
vrushalikapse Nov 30, 2020
fbdf51f
bugs resolved
vrushalikapse Nov 30, 2020
ff144d3
Changes in import statement and version
vrushalikapse Nov 30, 2020
c230c9e
Changes in readme
vrushalikapse Nov 30, 2020
7dbc0ff
changes in version
vrushalikapse Nov 30, 2020
42b4c25
bugs resolved
vrushalikapse Nov 30, 2020
064faf6
bugs resolved
vrushalikapse Nov 30, 2020
75447d4
changes in root variable
vrushalikapse Nov 30, 2020
b6d7c2f
Updated code
vrushalikapse Dec 1, 2020
bd9896f
updated Readme file
vrushalikapse Dec 1, 2020
e5e1457
changes in init.py file and readme file
vrushalikapse Dec 3, 2020
260fc76
getFeedToken() function added, Changes in import statement for websocket
vrushalikapse Dec 8, 2020
ea49f8b
getFeedToken() function added, Changes in import statement for websocket
vrushalikapse Dec 8, 2020
8fecc00
Changes in import statement for websocket
vrushalikapse Dec 9, 2020
9765bcb
getfeedToken()
vrushalikapse Dec 10, 2020
a9617ce
bugs rectified
vrushalikapse Dec 10, 2020
bd11f8a
heartbeats added in websocket
vrushalikapse Dec 11, 2020
8b0f85d
removed unnecessary print statements
vrushalikapse Dec 29, 2020
15165d4
removed unnecessary print statements
vrushalikapse Dec 29, 2020
79ce701
conflicts solved
vrushalikapse Dec 29, 2020
5e7d323
Nameerror resolved
vrushalikapse Jan 19, 2021
e38242b
Merge branch 'main' of https://github.com/angelbroking-github/smartap…
vrushalikapse Feb 18, 2021
10ed698
Gtt services added
vrushalikapse Mar 3, 2021
c361cd8
Condition added for Public Ip Header
vrushalikapse Mar 8, 2021
1461f12
Merge branch 'develop' into main
vrushalikapse Mar 8, 2021
61e8917
Changes in Websocket.py as per main branch
vrushalikapse Mar 8, 2021
e885ea8
Changes in smartConnect.py as per main branch
vrushalikapse Mar 8, 2021
28ee960
Changes in websocket-sendRequest(token,task)
vrushalikapse Mar 8, 2021
0fdd1b9
Historic api added and Websocket Open Forum Issues Resolved
abhijeetbote Mar 26, 2021
7cd96b4
Conflicts resolved
abhijeetbote Mar 26, 2021
c51f3e1
Conflicts resolved
abhijeetbote Mar 26, 2021
7f0db4f
new websocket code added
vrushalikapse Apr 12, 2021
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
81 changes: 75 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ pip install smartapi-python

```python
# package import statement
from smartapi.smartConnect import SmartConnect
from smartapi import SmartConnect #or from smartapi.smartConnect import SmartConnect
#import smartapi.smartExceptions(for smartExceptions)

#create object of call
obj=SmartConnect()
obj=SmartConnect(api_key="your api key")

#login api call

data = obj.generateSession("D88311","Angel@444")
data = obj.generateSession("Your Client ID","Your Password")
refreshToken= data['data']['refreshToken']

#fetch the feedtoken
feedToken=obj.getfeedToken()

#fetch User Profile
userProfile= obj.getProfile(refreshToken)
#place order
Expand All @@ -46,16 +50,81 @@ try:
print("The order id is: {}".format(orderId))
except Exception as e:
print("Order placement failed: {}".format(e.message))
#gtt rule creation
try:
gttCreateParams={
"tradingsymbol" : "SBIN-EQ",
"symboltoken" : "3045",
"exchange" : "NSE",
"producttype" : "MARGIN",
"transactiontype" : "BUY",
"price" : 100000,
"qty" : 10,
"disclosedqty": 10,
"triggerprice" : 200000,
"timeperiod" : 365
}
rule_id=gtt.gttCreateRule(gttCreateParams)
print("The GTT rule id is: {}".format(rule_id))
except Exception as e:
print("GTT Rule creation failed: {}".format(e.message))

#gtt rule list
try:
status=["FORALL"] #should be a list
page=1
count=10
lists=smartApi.gttLists(status,page,count)
except Exception as e:
print("GTT Rule List failed: {}".format(e.message))

#Historic api
try:
historicParam={
"exchange": "NSE",
"symboltoken": "3045",
"interval": "MINUTE",
"fromdate": "2021-02-08 09:00",
"todate": "2021-02-08 09:16"
}
smartApi.getCandleData(historicParam)
except Exception as e:
print("Historic Api failed: {}".format(e.message))
#logout
try:
logout=obj.terminateSession('D88311')
logout=obj.terminateSession('Your Client Id')
print("Logout Successfull")
except Exception as e:
print("Logout failed: {}".format(e.message))


License
MIT

## WebSocket
from smartapi import WebSocket
FEED_TOKEN= "your feed token"
CLIENT_CODE="your client Id"
token="channel you want the information of" #"nse_cm|2885&nse_cm|1594&nse_cm|11536"
task="task" #"mw"|"sfi"|"dp"
ss = WebSocket(FEED_TOKEN, CLIENT_CODE)

def on_tick(ws, tick):
print("Ticks: {}".format(tick))

def on_connect(ws, response):
ws.websocket_connection() # Websocket connection
ws.send_request(token,task)

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( )





6 changes: 6 additions & 0 deletions SmartApi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from __future__ import unicode_literals,absolute_import

from smartapi.smartConnect import SmartConnect
from smartapi.webSocket import WebSocket

__all__ = ["SmartConnect","WebSocket"]



Expand Down
Binary file modified SmartApi/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified SmartApi/__pycache__/smartConnect.cpython-36.pyc
Binary file not shown.
Binary file modified SmartApi/__pycache__/smartExceptions.cpython-36.pyc
Binary file not shown.
Binary file added SmartApi/__pycache__/smartSocket.cpython-36.pyc
Binary file not shown.
Binary file modified SmartApi/__pycache__/socketTP.cpython-36.pyc
Binary file not shown.
Binary file modified SmartApi/__pycache__/version.cpython-36.pyc
Binary file not shown.
Loading