-
Notifications
You must be signed in to change notification settings - Fork 239
websoclet2 api #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
SmartApi/smartWebSocketV2.py
Outdated
from __future__ import print_function | ||
|
||
import struct | ||
# import threading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused imports can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completed removed unused imports
SmartApi/smartWebSocketV2.py
Outdated
SNAP_QUOTE = 3 | ||
|
||
# Exchange Type | ||
NSE_CM = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maintain exchange types in Map/Dictionary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to update them in Dict because they are just for reference
SmartApi/smartWebSocketV2.py
Outdated
""" | ||
try: | ||
headers = { | ||
"Authorization": self.auth_token, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers can be extracted out of this try-catch block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completed
SmartApi/smartWebSocketV2.py
Outdated
|
||
def _parse_binary_data(self, binary_data): | ||
try: | ||
parsed_data = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review the code piece which can be extracted out of try-catch block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completed
while i < len(binary_packets): | ||
packets.append(binary_packets[i: i+20]) | ||
i += 20 | ||
return packets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain this? What are we doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are parsing for 5 latest purchases and sales
example/sample.py
Outdated
#login api call | ||
|
||
data = obj.generateSession(clientId,pin,totp) | ||
print('data',data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required. This print statement can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completed
example/sample.py
Outdated
"stoploss": "0", | ||
"quantity": "1" | ||
} | ||
# orderId=obj.placeOrder(orderparams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uncommented
example/sample.py
Outdated
obj.getCandleData(historicParam) | ||
except Exception as e: | ||
print("Historic Api failed: {}".format(e.message)) | ||
logout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turned to logger
try: | ||
for key, val in self.input_request_dict.items(): | ||
token_list = [] | ||
for key1, val1 in val.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we creating a new dict here? Why can't we use val directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted values from self.input_request_dict dict and assigned to payload hence dict is required
SmartApi/smartWebSocketV2.py
Outdated
"exchange_type": self._unpack_data(binary_data, 1, 2, byte_format="B")[0], | ||
"token": SmartWebSocketV2._parse_token_value(binary_data[2:27]), | ||
"sequence_number": self._unpack_data(binary_data, 27, 35, byte_format="q")[0], | ||
"exchange_timestamp": self._unpack_data(binary_data, 35, 43, byte_format="q")[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should ideally extract out constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done created and constant file and imported all apis from CONSTANT.py file
Can you please provide a short description and test plan for this PR? |
best_5_sell_data = [] | ||
|
||
for packet in best_5_buy_sell_packets: | ||
each_data = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are we detecting a close event from Server?
where to find the stock name, token/symbol number? |
No description provided.