Skip to content
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

Unable to fetch Market Depth using ScripData #306

Open
NMNDV opened this issue Dec 22, 2024 · 1 comment
Open

Unable to fetch Market Depth using ScripData #306

NMNDV opened this issue Dec 22, 2024 · 1 comment

Comments

@NMNDV
Copy link

NMNDV commented Dec 22, 2024

  • 5paisa Python SDK version: 0.7.19
  • Python version: 3.10.11
  • Operating System: Windows

Description

Describe what you were trying to get done.

Trying to get market depth using "client.fetch_market_depth", "client.fetch_market_depth_by_scrip" py5paisa client methods by providing only ScripData instead of ScripCode.

Tell us what happened, what went wrong, and what you expected to happen.

We received invalid values for LastTradedPrice (0), and market depth prices (0) which is incorrect.

What I Did

As per https://xstream.5paisa.com/dev-docs/market-data-system/market-depth with python tab selected;

Stock request client.fetch_market_depth

client.fetch_market_depth([{"Exchange": "N","ExchangeType":"C","ScripData":"RELIANCE_EQ"}])

Response

{'CacheTime': 0, 'Data': [{'AverageTradePrice': 0, 'BuyQuantity': 0, 'Close': '0', 'Exchange': 'N', 'ExchangeType': 'C', 'High': '0', 'LastQuantity': 0, 'LastTradeTime': '/Date(1734805800000)/', 'LastTradedPrice': 0, 'Low': '0', 'NetChange': '0', 'Open': '0', 'OpenInterest': '0', 'ScripCode': 0, 'SellQuantity': 0, 'TotalBuyQuantity': 0, 'TotalSellQuantity': 0, 'Volume': '0'}], 'Message': 'Success', 'Status': 0, 'TimeStamp': '/Date(1734858334539+0530)/'}

Stock request client.fetch_market_depth_by_scrip

client.fetch_market_depth_by_scrip(Exchange="N",ExchangeType="C",ScripData="RELIANCE_EQ")

Response

{'CacheTime': 5, 'Exch': 'N', 'ExchType': 'C', 'MarketDepthData': [{'BbBuySellFlag': 66, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 66, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 66, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 66, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 66, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, 
{'BbBuySellFlag': 83, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 83, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 83, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 83, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}, {'BbBuySellFlag': 83, 'NumberOfOrders': 0, 'Price': 0, 'Quantity': 0}], 'Message': 'Success', 'ScripCode': 2885, 'Status': 0, 'TimeStamp': '/Date(-19800000+0530)/'}

Futures request client.fetch_market_depth

client.fetch_market_depth([{"Exchange": "B","ExchangeType":"D","ScripData":"SENSEX 27 Dec 2024_20241227"}])

Response

{'CacheTime': 0, 'Data': [{'AverageTradePrice': 0, 'BuyQuantity': 0, 'Close': '0', 'Exchange': 'B', 'ExchangeType': 'D', 'High': '0', 'LastQuantity': 0, 'LastTradeTime': '/Date(1734805800000)/', 'LastTradedPrice': 0, 'Low': '0', 'NetChange': '0', 'Open': '0', 'OpenInterest': '0', 'ScripCode': 0, 'SellQuantity': 0, 'TotalBuyQuantity': 0, 'TotalSellQuantity': 0, 'Volume': '0'}], 'Message': 'Success', 'Status': 0, 'TimeStamp': '/Date(1734858812898+0530)/'}

Equivalent ScripCode requests are passing and returning the correct data;

SENSEX 27 Dec 2024_20241227 = 1146913
RELIANCE_EQ = 2885

as per https://xstream.5paisa.com/dev-docs/docFundamentals/scrip-master

Stock request

client.fetch_market_depth([{"Exchange": "N","ExchangeType":"C","ScripCode":"2885"}])

Response

{'CacheTime': 0, 'Data': [{'AverageTradePrice': 0, 'BuyQuantity': 0, 'Close': '1230.45', 'Exchange': 'N', 'ExchangeType': 'C', 'High': '1239.5', 'LastQuantity': 0, 'LastTradeTime': '/Date(1734863399000)/', 'LastTradedPrice': 1205.3, 'Low': '1201.5', 'NetChange': '-25.1500000000001', 'Open': '1224', 'OpenInterest': '0', 'ScripCode': 2885, 'SellQuantity': 0, 'TotalBuyQuantity': 0, 'TotalSellQuantity': 0, 'Volume': '0'}], 'Message': 'Success', 'Status': 0, 'TimeStamp': '/Date(1734859119440+0530)/'}

Future request

client.fetch_market_depth([{"Exchange": "B","ExchangeType":"D","ScripCode":"1146913"}])

Response

{'CacheTime': 0, 'Data': [{'AverageTradePrice': 0, 'BuyQuantity': 0, 'Close': '79414.2', 'Exchange': 'B', 'ExchangeType': 'D', 'High': '79750', 'LastQuantity': 0, 'LastTradeTime': '/Date(1734861596000)/', 'LastTradedPrice': 78303.8, 'Low': '78137.65', 'NetChange': '-1110.39999999999', 'Open': '79402.9', 'OpenInterest': '22810', 'ScripCode': 1146913, 'SellQuantity': 0, 'TotalBuyQuantity': 0, 'TotalSellQuantity': 0, 'Volume': '0'}], 'Message': 'Success', 'Status': 0, 'TimeStamp': '/Date(1734859119361+0530)/'}

Background

This requirement occurred on 13th December 2024, when we received invalid Scrip master data following https://xstream.5paisa.com/dev-docs/docFundamentals/scrip-master with missing rows. This issue has appeared several times, and we tried to migrate from depending on ScripCode to ScripData for reliability. Still, while testing, we found the problem of invalid values while fetching market depths.

@Mizzlr
Copy link

Mizzlr commented Dec 25, 2024

Related, see #305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants