Skip to content

Conversation

abhijeet-bote
Copy link

No description provided.

from __future__ import print_function

import struct
# import threading

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completed removed unused imports

SNAP_QUOTE = 3

# Exchange Type
NSE_CM = 1

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?

Copy link
Author

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

"""
try:
headers = {
"Authorization": self.auth_token,

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completed


def _parse_binary_data(self, binary_data):
try:
parsed_data = {

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.

Copy link
Author

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

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?

Copy link
Author

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

#login api call

data = obj.generateSession(clientId,pin,totp)
print('data',data)

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completed

"stoploss": "0",
"quantity": "1"
}
# orderId=obj.placeOrder(orderparams)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is commented?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncommented

obj.getCandleData(historicParam)
except Exception as e:
print("Historic Api failed: {}".format(e.message))
logout

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Author

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

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?

Copy link
Author

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

"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],

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.

Copy link
Author

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

@NakshArora
Copy link

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 = {
Copy link

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?

@Ankitkalauni
Copy link

where to find the stock name, token/symbol number?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants