Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Samples are grouped by API area. Each `.md` file contains one or more Python sni
| [**user/**](user/) | User profile, fund and margin details, IP management, kill switch. |
| [**orders/**](orders/) | Order lifecycle: place (single/multi, v2 & v3), modify, cancel, order book, order details, order history, trades, historical trades, exit all positions. |
| [**portfolio/**](portfolio/) | Positions, holdings, MTF positions, convert positions. |
| [**market-quote/**](market-quote/) | LTP, full market quotes, OHLC (v2 & v3), option Greeks. |
| [**market-quote/**](market-quote/) | LTP, full market quotes (v2 & v3), OHLC (v2 & v3), option Greeks. |
| [**historical-data/**](historical-data/) | Historical and intraday candle data (v2 & v3). |
| [**option-chain/**](option-chain/) | Option contracts, put-call option chain. |
| [**expired-instruments/**](expired-instruments/) | Expiries, expired future/option contracts, expired historical candle data. |
Expand Down
36 changes: 21 additions & 15 deletions examples/market-quote/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,33 @@ Links to all market-quote-related examples in the `code/` folder.
- 1.1 [Get full market quote](code/full-market-quotes.md#get-full-market-quote)
- 1.2 [Get full market quote for multiple instrument keys](code/full-market-quotes.md#get-full-market-quote-for-multiple-instrument-keys)

## 2. OHLC Quotes V3
## 2. Full Market Quotes V3

- 2.1 [Get ohlc (open, high, low, close) market quotes](code/ohlc-quotes-v3.md#get-ohlc-open-high-low-close-market-quotes)
- 2.2 [Get ohlc (open, high, low, close) market quotes for multiple instrument keys](code/ohlc-quotes-v3.md#get-ohlc-open-high-low-close-market-quotes-for-multiple-instrument-keys)
- 2.1 [Get full market quote](code/full-market-quotes-v3.md#get-full-market-quote)
- 2.2 [Get full market quote for multiple instrument keys](code/full-market-quotes-v3.md#get-full-market-quote-for-multiple-instrument-keys)
- 2.3 [Read fields from the full market quote response](code/full-market-quotes-v3.md#read-fields-from-the-full-market-quote-response)

## 3. LTP Quotes V3
## 3. OHLC Quotes V3

- 3.1 [Get ltp (last traded price) market quotes](code/ltp-quotes-v3.md#get-ltp-last-traded-price-market-quotes)
- 3.2 [Get ltp (last traded price) market quotes for multiple instruments keys](code/ltp-quotes-v3.md#get-ltp-last-traded-price-market-quotes-for-multiple-instruments-keys)
- 3.1 [Get ohlc (open, high, low, close) market quotes](code/ohlc-quotes-v3.md#get-ohlc-open-high-low-close-market-quotes)
- 3.2 [Get ohlc (open, high, low, close) market quotes for multiple instrument keys](code/ohlc-quotes-v3.md#get-ohlc-open-high-low-close-market-quotes-for-multiple-instrument-keys)

## 4. Option Greek
## 4. LTP Quotes V3

- 4.1 [Get Option Greek fields](code/option-greek.md#get-option-greek-fields)
- 4.2 [Get Option Greek fields for multiple instruments keys](code/option-greek.md#get-option-greek-fields-for-multiple-instruments-keys)
- 4.1 [Get ltp (last traded price) market quotes](code/ltp-quotes-v3.md#get-ltp-last-traded-price-market-quotes)
- 4.2 [Get ltp (last traded price) market quotes for multiple instruments keys](code/ltp-quotes-v3.md#get-ltp-last-traded-price-market-quotes-for-multiple-instruments-keys)

## 5. OHLC Quotes
## 5. Option Greek

- 5.1 [Get ohlc (open, high, low, close) market quotes](code/ohlc-quotes.md#get-ohlc-open-high-low-close-market-quotes)
- 5.2 [Get ohlc (open, high, low, close) market quotes for multiple instrument keys](code/ohlc-quotes.md#get-ohlc-open-high-low-close-market-quotes-for-multiple-instrument-keys)
- 5.1 [Get Option Greek fields](code/option-greek.md#get-option-greek-fields)
- 5.2 [Get Option Greek fields for multiple instruments keys](code/option-greek.md#get-option-greek-fields-for-multiple-instruments-keys)

## 6. LTP Quotes
## 6. OHLC Quotes

- 6.1 [Get ltp (last traded price) market quotes](code/ltp-quotes.md#get-ltp-last-traded-price-market-quotes)
- 6.2 [Get ltp (last traded price) market quotes for multiple instruments keys](code/ltp-quotes.md#get-ltp-last-traded-price-market-quotes-for-multiple-instruments-keys)
- 6.1 [Get ohlc (open, high, low, close) market quotes](code/ohlc-quotes.md#get-ohlc-open-high-low-close-market-quotes)
- 6.2 [Get ohlc (open, high, low, close) market quotes for multiple instrument keys](code/ohlc-quotes.md#get-ohlc-open-high-low-close-market-quotes-for-multiple-instrument-keys)

## 7. LTP Quotes

- 7.1 [Get ltp (last traded price) market quotes](code/ltp-quotes.md#get-ltp-last-traded-price-market-quotes)
- 7.2 [Get ltp (last traded price) market quotes for multiple instruments keys](code/ltp-quotes.md#get-ltp-last-traded-price-market-quotes-for-multiple-instruments-keys)
78 changes: 78 additions & 0 deletions examples/market-quote/code/full-market-quotes-v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
## Get full market quote

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
try:
# For a single instrument
response = apiInstance.get_full_market_quote_v3(instrument_key="NSE_EQ|INE848E01016")
print(response)
except ApiException as e:
print("Exception when calling MarketQuoteV3Api->get_full_market_quote_v3: %s\n" % e)
```

## Get full market quote for multiple instrument keys

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
try:
# For multiple instruments (up to 500 in one call)
response = apiInstance.get_full_market_quote_v3(
instrument_key="NSE_EQ|INE848E01016,NSE_EQ|INE669E01016")
print(response)
except ApiException as e:
print("Exception when calling MarketQuoteV3Api->get_full_market_quote_v3: %s\n" % e)
```

## Read fields from the full market quote response

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
try:
response = apiInstance.get_full_market_quote_v3(instrument_key="NSE_EQ|INE848E01016")

# response.data is a dict keyed by "<exchange>:<trading_symbol>"
for key, quote in response.data.items():
print(key)
print(" symbol :", quote.symbol)
print(" instrument_token :", quote.instrument_token)
print(" last_price :", quote.last_price)
print(" volume :", quote.volume)
print(" average_price :", quote.average_price)
print(" net_change :", quote.net_change)
print(" prev_close_price :", quote.prev_close_price)
print(" lower_circuit_limit :", quote.lower_circuit_limit)
print(" upper_circuit_limit :", quote.upper_circuit_limit)
print(" year_high / year_low :", quote.year_high, "/", quote.year_low)
print(" oi / previous_oi :", quote.oi, "/", quote.previous_oi)
print(" cas_eligible :", quote.cas_eligible)

# Nested OHLC snapshot
print(" ohlc :", quote.ohlc.open, quote.ohlc.high,
quote.ohlc.low, quote.ohlc.close)

# Nested market depth (top 5 bids and asks)
for level in quote.depth.buy:
print(" bid:", level.price, level.quantity, level.orders)
for level in quote.depth.sell:
print(" ask:", level.price, level.quantity, level.orders)
except ApiException as e:
print("Exception when calling MarketQuoteV3Api->get_full_market_quote_v3: %s\n" % e)
```
15 changes: 15 additions & 0 deletions examples/websocket/market_data/v3/MarketDataFeedV3.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
syntax = "proto3";
package com.upstox.marketdatafeederv3udapi.rpc.proto;
import "google/protobuf/wrappers.proto";

message LTPC {
double ltp = 1;
int64 ltt = 2;
int64 ltq = 3;
double cp = 4;
google.protobuf.DoubleValue iep = 5;
}

message MarketLevel {
Expand Down Expand Up @@ -58,6 +60,12 @@ message MarketFullFeed{
double iv = 8; //implied volatility
double tbq =9; //total buy quantity
double tsq = 10; //total sell quantity
double iep = 11;
double rp = 12;
int64 ieq = 13;
int64 iiqTotal = 14;
int64 iiqM = 15;
bool casEligible = 16;
}

message IndexFullFeed{
Expand Down Expand Up @@ -108,8 +116,15 @@ enum MarketStatus {
}


message StatusInfo {
string status = 1;
int64 updatedTime = 2;
}

message MarketInfo {
map<string, MarketStatus> segmentStatus = 1;
map<string, StatusInfo> casMarketStatus = 2;
map<string, StatusInfo> preOpenSessionStatus = 3;
}

message FeedResponse{
Expand Down
Loading
Loading