Skip to content

Commit 95f998b

Browse files
authored
Merge pull request #54 from angel-one/readmeUpdate
Readme update
2 parents 3f9ed89 + 0e006fe commit 95f998b

3 files changed

Lines changed: 34 additions & 25 deletions

File tree

README.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ Use the package manager [pip](https://pip.pypa.io/en/stable/) to install smartap
1111
pip install -r requirements_dev.txt # for downloading the other required packages
1212
```
1313

14+
Download the following packages
15+
```bash
16+
pip install pyotp
17+
pip install logzero
18+
pip install websocket-client
19+
```
20+
For Downloading pycryptodome package
21+
```bash
22+
pip uninstall pycrypto
23+
pip install pycryptodome
24+
```
25+
1426
## Usage
1527

1628
```python
@@ -123,56 +135,54 @@ else:
123135
```
124136

125137
## Getting started with SmartAPI Websocket's
126-
127-
```python
128138
####### Websocket V2 sample code #######
129139

130140
from SmartApi.smartWebSocketV2 import SmartWebSocketV2
131141
from logzero import logger
132142

133-
AUTH_TOKEN = "Your Auth_Token"
134-
API_KEY = "Your Api_Key"
135-
CLIENT_CODE = "Your Client Code"
136-
FEED_TOKEN = "Your Feed_Token"
143+
AUTH_TOKEN = "authToken"
144+
API_KEY = "api_key"
145+
CLIENT_CODE = "client code"
146+
FEED_TOKEN = "feedToken"
137147
correlation_id = "abc123"
138148
action = 1
139149
mode = 1
150+
140151
token_list = [
141152
{
142153
"exchangeType": 1,
143154
"tokens": ["26009"]
144155
}
145156
]
146-
#retry_strategy=0 for simple retry mechanism
147-
sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN,max_retry_attempt=2, retry_strategy=0, retry_delay=10, retry_duration=30)
157+
token_list1 = [
158+
{
159+
"action": 0,
160+
"exchangeType": 1,
161+
"tokens": ["26009"]
162+
}
163+
]
148164

149-
#retry_strategy=1 for exponential retry mechanism
150-
# sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN,max_retry_attempt=3, retry_strategy=1, retry_delay=10,retry_multiplier=2, retry_duration=30)
165+
sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN)
151166

152167
def on_data(wsapp, message):
153168
logger.info("Ticks: {}".format(message))
154169
# close_connection()
155170

156-
def on_control_message(wsapp, message):
157-
logger.info(f"Control Message: {message}")
158-
159171
def on_open(wsapp):
160172
logger.info("on open")
161-
some_error_condition = False
162-
if some_error_condition:
163-
error_message = "Simulated error"
164-
if hasattr(wsapp, 'on_error'):
165-
wsapp.on_error("Custom Error Type", error_message)
166-
else:
167-
sws.subscribe(correlation_id, mode, token_list)
168-
# sws.unsubscribe(correlation_id, mode, token_list1)
173+
sws.subscribe(correlation_id, mode, token_list)
174+
# sws.unsubscribe(correlation_id, mode, token_list1)
175+
169176

170177
def on_error(wsapp, error):
171178
logger.error(error)
172179

180+
173181
def on_close(wsapp):
174182
logger.info("Close")
175183

184+
185+
176186
def close_connection():
177187
sws.close_connection()
178188

@@ -182,7 +192,6 @@ else:
182192
sws.on_data = on_data
183193
sws.on_error = on_error
184194
sws.on_close = on_close
185-
sws.on_control_message = on_control_message
186195

187196
sws.connect()
188197
####### Websocket V2 sample code ENDS Here #######

SmartApi/smartConnect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
class SmartConnect(object):
1919
#_rootUrl = "https://openapisuat.angelbroking.com"
20-
_rootUrl="https://apiconnect.angelbroking.com" #prod endpoint
20+
_rootUrl="https://apiconnect.angelone.in" #prod endpoint
2121
#_login_url ="https://smartapi.angelbroking.com/login"
22-
_login_url="https://smartapi.angelbroking.com/publisher-login" #prod endpoint
22+
_login_url="https://smartapi.angelone.in/publisher-login" #prod endpoint
2323
_default_timeout = 7 # In seconds
2424

2525
_routes = {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="smartapi-python",
15-
version="1.4.8",
15+
version="1.5.0",
1616
author="ab-smartapi",
1717
author_email="smartapi.sdk@gmail.com",
1818
description="Angel Broking openApi integration",

0 commit comments

Comments
 (0)