vortex-api 2.1.8b4__tar.gz → 2.1.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vortex_api-2.1.9/PKG-INFO +245 -0
- vortex_api-2.1.9/README.md +218 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/pyproject.toml +1 -1
- vortex_api-2.1.9/vortex_api/__init__.py +105 -0
- vortex_api-2.1.9/vortex_api/__version__.py +1 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/api.py +1146 -1146
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/instruments.py +36 -53
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/vortex_feed.py +766 -603
- vortex_api-2.1.9/vortex_api.egg-info/PKG-INFO +245 -0
- vortex_api-2.1.8b4/PKG-INFO +0 -114
- vortex_api-2.1.8b4/README.md +0 -87
- vortex_api-2.1.8b4/vortex_api/__init__.py +0 -39
- vortex_api-2.1.8b4/vortex_api/__version__.py +0 -1
- vortex_api-2.1.8b4/vortex_api.egg-info/PKG-INFO +0 -114
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/LICENSE +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/setup.cfg +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/backtest/__init__.py +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/backtest/_backtestingpy.py +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/backtest/_backtrader.py +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/backtest/_common.py +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api/backtest/_vectorbt.py +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api.egg-info/SOURCES.txt +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api.egg-info/dependency_links.txt +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api.egg-info/requires.txt +0 -0
- {vortex_api-2.1.8b4 → vortex_api-2.1.9}/vortex_api.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vortex_api
|
|
3
|
+
Version: 2.1.9
|
|
4
|
+
Summary: Vortex APIs to place orders in Rupeezy application
|
|
5
|
+
Author-email: "Astha Credit & Securities Pvt Ltd." <tech@rupeezy.in>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://vortex.rupeezy.in
|
|
8
|
+
Project-URL: Repository, https://github.com/RupeezyTech/pyvortex
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
11
|
+
Classifier: Natural Language :: English
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: requests>=2.25.1
|
|
20
|
+
Requires-Dist: wrapt>=1.15.0
|
|
21
|
+
Requires-Dist: six>=1.11.0
|
|
22
|
+
Requires-Dist: pyOpenSSL>=17.5.0
|
|
23
|
+
Requires-Dist: python-dateutil>=2.6.1
|
|
24
|
+
Requires-Dist: autobahn[twisted]==19.11.2
|
|
25
|
+
Requires-Dist: service_identity>=18.1.0
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# Vortex API Python Client
|
|
29
|
+
|
|
30
|
+
Official Python SDK for [Rupeezy Vortex APIs](https://vortex.rupeezy.in). Place orders, stream live quotes over WebSocket, run backtests, and look up any of ~190,000 NSE/BSE/MCX instruments by ticker.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install vortex-api
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from vortex_api import VortexAPI
|
|
42
|
+
from vortex_api import Constants as Vc
|
|
43
|
+
|
|
44
|
+
client = VortexAPI("your_api_secret", "your_application_id")
|
|
45
|
+
|
|
46
|
+
# Log in via SSO
|
|
47
|
+
print(client.login_url(callback_param="hi"))
|
|
48
|
+
client.exchange_token("auth_code_received_in_callback_url")
|
|
49
|
+
|
|
50
|
+
# Place an order — preferred, ticker form
|
|
51
|
+
client.place_order(
|
|
52
|
+
ticker="NSE:RELIANCE",
|
|
53
|
+
transaction_type=Vc.TransactionSides.BUY,
|
|
54
|
+
product=Vc.ProductTypes.DELIVERY,
|
|
55
|
+
variety=Vc.VarietyTypes.REGULAR_LIMIT_ORDER,
|
|
56
|
+
quantity=1,
|
|
57
|
+
price=1700.0,
|
|
58
|
+
trigger_price=0.0,
|
|
59
|
+
disclosed_quantity=0,
|
|
60
|
+
validity=Vc.ValidityTypes.FULL_DAY,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Order book
|
|
64
|
+
client.orders(limit=20, offset=1)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Identifying instruments
|
|
68
|
+
|
|
69
|
+
Most APIs accept either of:
|
|
70
|
+
|
|
71
|
+
- **`ticker`** (preferred) — a string like `"NSE:RELIANCE"` or `"NSE:NIFTY26JUL25000CE"`.
|
|
72
|
+
- **`exchange` + `token`** (legacy) — still works, but emits a `FutureWarning` urging migration to `ticker`.
|
|
73
|
+
|
|
74
|
+
This applies to `place_order`, `get_order_margin`, `historical_candles`, `subscribe`, and `unsubscribe`.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# Preferred
|
|
78
|
+
client.place_order(ticker="NSE:RELIANCE", ...)
|
|
79
|
+
|
|
80
|
+
# Legacy (still works, deprecated)
|
|
81
|
+
client.place_order(exchange=Vc.ExchangeTypes.NSE_EQ, token=2885, ...)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## InstrumentManager
|
|
85
|
+
|
|
86
|
+
The SDK ships an `InstrumentManager` that mirrors the full Rupeezy instrument master (~190,000 NSE, BSE and MCX instruments) and gives you O(1) lookups by ticker, by `(exchange, token)`, or by ISIN. It downloads the master CSV once per IST trading day and serves every subsequent lookup from an in-memory index backed by a disk cache.
|
|
87
|
+
|
|
88
|
+
### Accessing it
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
# Attached to every VortexAPI client
|
|
92
|
+
from vortex_api import VortexAPI
|
|
93
|
+
client = VortexAPI(...)
|
|
94
|
+
client.instruments.get_by_ticker("NSE:RELIANCE")
|
|
95
|
+
|
|
96
|
+
# Or standalone, no API client needed
|
|
97
|
+
from vortex_api import InstrumentManager
|
|
98
|
+
mgr = InstrumentManager()
|
|
99
|
+
mgr.get_by_ticker("NSE:RELIANCE")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The first lookup triggers a lazy load (~4 s on a cold cache, ~1 s from disk). Call `.load()` explicitly if you want to pay that cost up front instead of on the first lookup. `VortexFeed` does this for you before opening the websocket so that ticks arrive with `ticker` pre-resolved.
|
|
103
|
+
|
|
104
|
+
### Lookups
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
# Forward — ticker → Instrument
|
|
108
|
+
reliance = client.instruments.get_by_ticker("NSE:RELIANCE")
|
|
109
|
+
|
|
110
|
+
# Reverse — (exchange, token) → Instrument
|
|
111
|
+
reliance = client.instruments.get_by_exchange_token("NSE_EQ", 2885)
|
|
112
|
+
|
|
113
|
+
# Convenience pair
|
|
114
|
+
exchange, token = client.instruments.ticker_to_token("NSE:RELIANCE")
|
|
115
|
+
ticker = client.instruments.token_to_ticker("NSE_EQ", 2885)
|
|
116
|
+
|
|
117
|
+
# ISIN can map to multiple listings (NSE + BSE) — returns a list
|
|
118
|
+
listings = client.instruments.get_by_isin("INE002A01018")
|
|
119
|
+
|
|
120
|
+
# All F&O contracts under an underlying — option chain
|
|
121
|
+
nifty_options = client.instruments.all_by_underlying("NSE_FO", "NIFTY")
|
|
122
|
+
|
|
123
|
+
# Arbitrary predicate filter — anything you can express as a function
|
|
124
|
+
mtf_eligible = client.instruments.filter(lambda i: i.eligibility and i.series == "EQ")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Missing instruments raise `InstrumentNotFound`:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from vortex_api import InstrumentNotFound
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
client.instruments.get_by_ticker("NSE:DOESNOTEXIST")
|
|
134
|
+
except InstrumentNotFound:
|
|
135
|
+
...
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### The `Instrument` object
|
|
139
|
+
|
|
140
|
+
Each lookup returns an `Instrument` dataclass with the columns from the master file:
|
|
141
|
+
|
|
142
|
+
| Field | Type | Example |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| `ticker` | `str` | `"NSE:RELIANCE"` |
|
|
145
|
+
| `token` | `int` | `2885` |
|
|
146
|
+
| `exchange` | `str` | `"NSE_EQ"`, `"NSE_FO"`, `"BSE_EQ"`, `"MCX_FO"` |
|
|
147
|
+
| `symbol` | `str` | `"RELIANCE"` |
|
|
148
|
+
| `instrument_name` | `str` | `"EQUITY"` |
|
|
149
|
+
| `series` | `str` | `"EQ"`, `"BE"`, `"OPTIDX"`, `"FUTSTK"` |
|
|
150
|
+
| `expiry_date` | `str` | `"25JUL2026"` (F&O only) |
|
|
151
|
+
| `strike_price` | `float` | `25000.0` (options) |
|
|
152
|
+
| `option_type` | `str` | `"CE"` / `"PE"` (options) |
|
|
153
|
+
| `lot_size` | `int` | `250` |
|
|
154
|
+
| `tick` | `float` | `0.05` |
|
|
155
|
+
| `isin` | `str` | `"INE002A01018"` |
|
|
156
|
+
| `eligibility` | `bool` | `True` |
|
|
157
|
+
| `name` | `str` | Full security description |
|
|
158
|
+
| `last_trading_date` | `datetime` | F&O last trading day |
|
|
159
|
+
| `asm_gsm_stage` | `str` | ASM/GSM surveillance stage |
|
|
160
|
+
|
|
161
|
+
### Force refresh
|
|
162
|
+
|
|
163
|
+
The manager auto-refreshes whenever the disk cache is older than today's master publish. Trigger a manual refresh if you need to be sure you have the latest snapshot:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
client.instruments.refresh() # forces an unconditional re-download
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### How many are loaded
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
client.instruments.count() # → 188112
|
|
173
|
+
client.instruments.is_loaded # → True once load() has run
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Streaming live quotes (WebSocket)
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from vortex_api import VortexFeed
|
|
180
|
+
from vortex_api import Constants as Vc
|
|
181
|
+
import time
|
|
182
|
+
|
|
183
|
+
def on_price_update(ws, ticks):
|
|
184
|
+
for t in ticks:
|
|
185
|
+
# Each tick carries `ticker`, `exchange`, `token`, prices...
|
|
186
|
+
print(t["ticker"], t["last_trade_price"])
|
|
187
|
+
|
|
188
|
+
def on_order_update(ws, data):
|
|
189
|
+
print(data)
|
|
190
|
+
|
|
191
|
+
def on_connect(ws, response):
|
|
192
|
+
ws.subscribe(ticker="NSE:NIFTY", mode=Vc.QuoteModes.LTP)
|
|
193
|
+
ws.subscribe(ticker="NSE:BANKNIFTY", mode=Vc.QuoteModes.OHLCV)
|
|
194
|
+
ws.subscribe(ticker="NSE:RELIANCE", mode=Vc.QuoteModes.FULL)
|
|
195
|
+
|
|
196
|
+
def main():
|
|
197
|
+
wire = VortexFeed(access_token) # auto-loads instruments before connect
|
|
198
|
+
wire.on_price_update = on_price_update
|
|
199
|
+
wire.on_order_update = on_order_update
|
|
200
|
+
wire.on_connect = on_connect
|
|
201
|
+
wire.connect(threaded=True) # blocks briefly while instruments load,
|
|
202
|
+
# then opens the websocket
|
|
203
|
+
|
|
204
|
+
time.sleep(10)
|
|
205
|
+
wire.unsubscribe(ticker="NSE:NIFTY")
|
|
206
|
+
wire.unsubscribe(ticker="NSE:BANKNIFTY")
|
|
207
|
+
wire.unsubscribe(ticker="NSE:RELIANCE")
|
|
208
|
+
|
|
209
|
+
if __name__ == "__main__":
|
|
210
|
+
main()
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Tick payload
|
|
214
|
+
|
|
215
|
+
Every tick passed to `on_price_update` carries a `ticker` field client-side, resolved from `(exchange, token)` via the bundled `InstrumentManager`. The wire format still ships `exchange` + `token` — the SDK does the mapping locally so no server change is needed.
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
{
|
|
219
|
+
"ticker": "NSE:RELIANCE", # added by SDK
|
|
220
|
+
"exchange": "NSE_EQ",
|
|
221
|
+
"token": 2885,
|
|
222
|
+
"last_trade_price": 1734.55,
|
|
223
|
+
# ... mode-specific fields
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
If the instrument master can't be loaded (network down, read-only filesystem), the feed continues working without the `ticker` field — `exchange` and `token` are always present.
|
|
228
|
+
|
|
229
|
+
## Backtesting
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from vortex_api import VortexAPI
|
|
233
|
+
|
|
234
|
+
client = VortexAPI(...)
|
|
235
|
+
|
|
236
|
+
# Save a backtest run for review on the developer portal.
|
|
237
|
+
# Accepts results from backtesting.py, vectorbt, or backtrader.
|
|
238
|
+
client.save_backtest_result(stats, name="SMA Crossover v2", symbol="NIFTY")
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Further reading
|
|
242
|
+
|
|
243
|
+
Full method reference: [vortex_api docs](https://vortex.rupeezy.in/docs/pyvortex/vortex_api.html)
|
|
244
|
+
|
|
245
|
+
API reference: [vortex.rupeezy.in/docs](https://vortex.rupeezy.in/docs)
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Vortex API Python Client
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [Rupeezy Vortex APIs](https://vortex.rupeezy.in). Place orders, stream live quotes over WebSocket, run backtests, and look up any of ~190,000 NSE/BSE/MCX instruments by ticker.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install vortex-api
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from vortex_api import VortexAPI
|
|
15
|
+
from vortex_api import Constants as Vc
|
|
16
|
+
|
|
17
|
+
client = VortexAPI("your_api_secret", "your_application_id")
|
|
18
|
+
|
|
19
|
+
# Log in via SSO
|
|
20
|
+
print(client.login_url(callback_param="hi"))
|
|
21
|
+
client.exchange_token("auth_code_received_in_callback_url")
|
|
22
|
+
|
|
23
|
+
# Place an order — preferred, ticker form
|
|
24
|
+
client.place_order(
|
|
25
|
+
ticker="NSE:RELIANCE",
|
|
26
|
+
transaction_type=Vc.TransactionSides.BUY,
|
|
27
|
+
product=Vc.ProductTypes.DELIVERY,
|
|
28
|
+
variety=Vc.VarietyTypes.REGULAR_LIMIT_ORDER,
|
|
29
|
+
quantity=1,
|
|
30
|
+
price=1700.0,
|
|
31
|
+
trigger_price=0.0,
|
|
32
|
+
disclosed_quantity=0,
|
|
33
|
+
validity=Vc.ValidityTypes.FULL_DAY,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Order book
|
|
37
|
+
client.orders(limit=20, offset=1)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Identifying instruments
|
|
41
|
+
|
|
42
|
+
Most APIs accept either of:
|
|
43
|
+
|
|
44
|
+
- **`ticker`** (preferred) — a string like `"NSE:RELIANCE"` or `"NSE:NIFTY26JUL25000CE"`.
|
|
45
|
+
- **`exchange` + `token`** (legacy) — still works, but emits a `FutureWarning` urging migration to `ticker`.
|
|
46
|
+
|
|
47
|
+
This applies to `place_order`, `get_order_margin`, `historical_candles`, `subscribe`, and `unsubscribe`.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
# Preferred
|
|
51
|
+
client.place_order(ticker="NSE:RELIANCE", ...)
|
|
52
|
+
|
|
53
|
+
# Legacy (still works, deprecated)
|
|
54
|
+
client.place_order(exchange=Vc.ExchangeTypes.NSE_EQ, token=2885, ...)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## InstrumentManager
|
|
58
|
+
|
|
59
|
+
The SDK ships an `InstrumentManager` that mirrors the full Rupeezy instrument master (~190,000 NSE, BSE and MCX instruments) and gives you O(1) lookups by ticker, by `(exchange, token)`, or by ISIN. It downloads the master CSV once per IST trading day and serves every subsequent lookup from an in-memory index backed by a disk cache.
|
|
60
|
+
|
|
61
|
+
### Accessing it
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# Attached to every VortexAPI client
|
|
65
|
+
from vortex_api import VortexAPI
|
|
66
|
+
client = VortexAPI(...)
|
|
67
|
+
client.instruments.get_by_ticker("NSE:RELIANCE")
|
|
68
|
+
|
|
69
|
+
# Or standalone, no API client needed
|
|
70
|
+
from vortex_api import InstrumentManager
|
|
71
|
+
mgr = InstrumentManager()
|
|
72
|
+
mgr.get_by_ticker("NSE:RELIANCE")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The first lookup triggers a lazy load (~4 s on a cold cache, ~1 s from disk). Call `.load()` explicitly if you want to pay that cost up front instead of on the first lookup. `VortexFeed` does this for you before opening the websocket so that ticks arrive with `ticker` pre-resolved.
|
|
76
|
+
|
|
77
|
+
### Lookups
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# Forward — ticker → Instrument
|
|
81
|
+
reliance = client.instruments.get_by_ticker("NSE:RELIANCE")
|
|
82
|
+
|
|
83
|
+
# Reverse — (exchange, token) → Instrument
|
|
84
|
+
reliance = client.instruments.get_by_exchange_token("NSE_EQ", 2885)
|
|
85
|
+
|
|
86
|
+
# Convenience pair
|
|
87
|
+
exchange, token = client.instruments.ticker_to_token("NSE:RELIANCE")
|
|
88
|
+
ticker = client.instruments.token_to_ticker("NSE_EQ", 2885)
|
|
89
|
+
|
|
90
|
+
# ISIN can map to multiple listings (NSE + BSE) — returns a list
|
|
91
|
+
listings = client.instruments.get_by_isin("INE002A01018")
|
|
92
|
+
|
|
93
|
+
# All F&O contracts under an underlying — option chain
|
|
94
|
+
nifty_options = client.instruments.all_by_underlying("NSE_FO", "NIFTY")
|
|
95
|
+
|
|
96
|
+
# Arbitrary predicate filter — anything you can express as a function
|
|
97
|
+
mtf_eligible = client.instruments.filter(lambda i: i.eligibility and i.series == "EQ")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Missing instruments raise `InstrumentNotFound`:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from vortex_api import InstrumentNotFound
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
client.instruments.get_by_ticker("NSE:DOESNOTEXIST")
|
|
107
|
+
except InstrumentNotFound:
|
|
108
|
+
...
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### The `Instrument` object
|
|
112
|
+
|
|
113
|
+
Each lookup returns an `Instrument` dataclass with the columns from the master file:
|
|
114
|
+
|
|
115
|
+
| Field | Type | Example |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| `ticker` | `str` | `"NSE:RELIANCE"` |
|
|
118
|
+
| `token` | `int` | `2885` |
|
|
119
|
+
| `exchange` | `str` | `"NSE_EQ"`, `"NSE_FO"`, `"BSE_EQ"`, `"MCX_FO"` |
|
|
120
|
+
| `symbol` | `str` | `"RELIANCE"` |
|
|
121
|
+
| `instrument_name` | `str` | `"EQUITY"` |
|
|
122
|
+
| `series` | `str` | `"EQ"`, `"BE"`, `"OPTIDX"`, `"FUTSTK"` |
|
|
123
|
+
| `expiry_date` | `str` | `"25JUL2026"` (F&O only) |
|
|
124
|
+
| `strike_price` | `float` | `25000.0` (options) |
|
|
125
|
+
| `option_type` | `str` | `"CE"` / `"PE"` (options) |
|
|
126
|
+
| `lot_size` | `int` | `250` |
|
|
127
|
+
| `tick` | `float` | `0.05` |
|
|
128
|
+
| `isin` | `str` | `"INE002A01018"` |
|
|
129
|
+
| `eligibility` | `bool` | `True` |
|
|
130
|
+
| `name` | `str` | Full security description |
|
|
131
|
+
| `last_trading_date` | `datetime` | F&O last trading day |
|
|
132
|
+
| `asm_gsm_stage` | `str` | ASM/GSM surveillance stage |
|
|
133
|
+
|
|
134
|
+
### Force refresh
|
|
135
|
+
|
|
136
|
+
The manager auto-refreshes whenever the disk cache is older than today's master publish. Trigger a manual refresh if you need to be sure you have the latest snapshot:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
client.instruments.refresh() # forces an unconditional re-download
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### How many are loaded
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
client.instruments.count() # → 188112
|
|
146
|
+
client.instruments.is_loaded # → True once load() has run
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Streaming live quotes (WebSocket)
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from vortex_api import VortexFeed
|
|
153
|
+
from vortex_api import Constants as Vc
|
|
154
|
+
import time
|
|
155
|
+
|
|
156
|
+
def on_price_update(ws, ticks):
|
|
157
|
+
for t in ticks:
|
|
158
|
+
# Each tick carries `ticker`, `exchange`, `token`, prices...
|
|
159
|
+
print(t["ticker"], t["last_trade_price"])
|
|
160
|
+
|
|
161
|
+
def on_order_update(ws, data):
|
|
162
|
+
print(data)
|
|
163
|
+
|
|
164
|
+
def on_connect(ws, response):
|
|
165
|
+
ws.subscribe(ticker="NSE:NIFTY", mode=Vc.QuoteModes.LTP)
|
|
166
|
+
ws.subscribe(ticker="NSE:BANKNIFTY", mode=Vc.QuoteModes.OHLCV)
|
|
167
|
+
ws.subscribe(ticker="NSE:RELIANCE", mode=Vc.QuoteModes.FULL)
|
|
168
|
+
|
|
169
|
+
def main():
|
|
170
|
+
wire = VortexFeed(access_token) # auto-loads instruments before connect
|
|
171
|
+
wire.on_price_update = on_price_update
|
|
172
|
+
wire.on_order_update = on_order_update
|
|
173
|
+
wire.on_connect = on_connect
|
|
174
|
+
wire.connect(threaded=True) # blocks briefly while instruments load,
|
|
175
|
+
# then opens the websocket
|
|
176
|
+
|
|
177
|
+
time.sleep(10)
|
|
178
|
+
wire.unsubscribe(ticker="NSE:NIFTY")
|
|
179
|
+
wire.unsubscribe(ticker="NSE:BANKNIFTY")
|
|
180
|
+
wire.unsubscribe(ticker="NSE:RELIANCE")
|
|
181
|
+
|
|
182
|
+
if __name__ == "__main__":
|
|
183
|
+
main()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Tick payload
|
|
187
|
+
|
|
188
|
+
Every tick passed to `on_price_update` carries a `ticker` field client-side, resolved from `(exchange, token)` via the bundled `InstrumentManager`. The wire format still ships `exchange` + `token` — the SDK does the mapping locally so no server change is needed.
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
{
|
|
192
|
+
"ticker": "NSE:RELIANCE", # added by SDK
|
|
193
|
+
"exchange": "NSE_EQ",
|
|
194
|
+
"token": 2885,
|
|
195
|
+
"last_trade_price": 1734.55,
|
|
196
|
+
# ... mode-specific fields
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
If the instrument master can't be loaded (network down, read-only filesystem), the feed continues working without the `ticker` field — `exchange` and `token` are always present.
|
|
201
|
+
|
|
202
|
+
## Backtesting
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
from vortex_api import VortexAPI
|
|
206
|
+
|
|
207
|
+
client = VortexAPI(...)
|
|
208
|
+
|
|
209
|
+
# Save a backtest run for review on the developer portal.
|
|
210
|
+
# Accepts results from backtesting.py, vectorbt, or backtrader.
|
|
211
|
+
client.save_backtest_result(stats, name="SMA Crossover v2", symbol="NIFTY")
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Further reading
|
|
215
|
+
|
|
216
|
+
Full method reference: [vortex_api docs](https://vortex.rupeezy.in/docs/pyvortex/vortex_api.html)
|
|
217
|
+
|
|
218
|
+
API reference: [vortex.rupeezy.in/docs](https://vortex.rupeezy.in/docs)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Vortex API client for Python -- [Visit Api Center](https://vortex.rupeezy.in).
|
|
3
|
+
Astha Credit & Securities Pvt. Ltd. (c) 2023
|
|
4
|
+
|
|
5
|
+
License
|
|
6
|
+
-------
|
|
7
|
+
Rupeezy's Vortex Python library is licensed under the MIT License
|
|
8
|
+
|
|
9
|
+
The library
|
|
10
|
+
-----------
|
|
11
|
+
Vortex APIs are meant for clients who want to execute orders based on their own
|
|
12
|
+
strategy programmatically and for partners to build their own applications.
|
|
13
|
+
These APIs provide a fast and secure way to place trades, manage positions, and
|
|
14
|
+
access real-time market data.
|
|
15
|
+
|
|
16
|
+
The Python client provides an abstraction over these APIs so you can write
|
|
17
|
+
applications and strategies without dealing with HTTP, websocket framing, or
|
|
18
|
+
instrument-master plumbing yourself.
|
|
19
|
+
|
|
20
|
+
Getting started
|
|
21
|
+
---------------
|
|
22
|
+
#!python
|
|
23
|
+
from vortex_api import VortexAPI
|
|
24
|
+
from vortex_api import Constants as Vc
|
|
25
|
+
|
|
26
|
+
client = VortexAPI("your_api_secret", "your_application_id")
|
|
27
|
+
|
|
28
|
+
# SSO login
|
|
29
|
+
print(client.login_url(callback_param="hi"))
|
|
30
|
+
client.exchange_token("auth_token_received_in_callback_url")
|
|
31
|
+
|
|
32
|
+
# Place an order — preferred, ticker form
|
|
33
|
+
client.place_order(
|
|
34
|
+
ticker="NSE:RELIANCE",
|
|
35
|
+
transaction_type=Vc.TransactionSides.BUY,
|
|
36
|
+
product=Vc.ProductTypes.DELIVERY,
|
|
37
|
+
variety=Vc.VarietyTypes.REGULAR_LIMIT_ORDER,
|
|
38
|
+
quantity=1,
|
|
39
|
+
price=1700.0,
|
|
40
|
+
trigger_price=0.0,
|
|
41
|
+
disclosed_quantity=0,
|
|
42
|
+
validity=Vc.ValidityTypes.FULL_DAY,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Order book
|
|
46
|
+
client.orders(limit=20, offset=1)
|
|
47
|
+
|
|
48
|
+
InstrumentManager
|
|
49
|
+
-----------------
|
|
50
|
+
``client.instruments`` is an :class:`InstrumentManager` that mirrors the full
|
|
51
|
+
Rupeezy instrument master (~190,000 NSE/BSE/MCX rows) and gives you O(1)
|
|
52
|
+
lookups by ticker, ``(exchange, token)``, or ISIN. The first lookup triggers
|
|
53
|
+
a lazy load; subsequent lookups are in-memory hits. The master is cached on
|
|
54
|
+
disk so the SDK downloads it at most once per IST trading day.
|
|
55
|
+
|
|
56
|
+
#!python
|
|
57
|
+
inst = client.instruments.get_by_ticker("NSE:RELIANCE")
|
|
58
|
+
print(inst.token, inst.lot_size, inst.isin)
|
|
59
|
+
|
|
60
|
+
# Reverse lookup
|
|
61
|
+
inst = client.instruments.get_by_exchange_token("NSE_EQ", 2885)
|
|
62
|
+
|
|
63
|
+
# ISIN → list of listings (one ISIN can list on multiple exchanges)
|
|
64
|
+
listings = client.instruments.get_by_isin("INE002A01018")
|
|
65
|
+
|
|
66
|
+
# F&O chain — all contracts under an underlying
|
|
67
|
+
chain = client.instruments.all_by_underlying("NSE_FO", "NIFTY")
|
|
68
|
+
|
|
69
|
+
# Predicate filter
|
|
70
|
+
eq = client.instruments.filter(lambda i: i.exchange == "NSE_EQ" and i.eligibility)
|
|
71
|
+
|
|
72
|
+
# Force a refresh (otherwise auto-refreshed daily)
|
|
73
|
+
client.instruments.refresh()
|
|
74
|
+
|
|
75
|
+
You can also use the manager standalone, without a :class:`VortexAPI` client::
|
|
76
|
+
|
|
77
|
+
#!python
|
|
78
|
+
from vortex_api import InstrumentManager
|
|
79
|
+
mgr = InstrumentManager()
|
|
80
|
+
mgr.get_by_ticker("NSE:RELIANCE")
|
|
81
|
+
|
|
82
|
+
Streaming quotes
|
|
83
|
+
----------------
|
|
84
|
+
#!python
|
|
85
|
+
from vortex_api import VortexFeed
|
|
86
|
+
from vortex_api import Constants as Vc
|
|
87
|
+
|
|
88
|
+
def on_price_update(ws, ticks):
|
|
89
|
+
for t in ticks:
|
|
90
|
+
# Each tick carries `ticker`, `exchange`, `token`, prices...
|
|
91
|
+
print(t["ticker"], t["last_trade_price"])
|
|
92
|
+
|
|
93
|
+
def on_connect(ws, response):
|
|
94
|
+
ws.subscribe(ticker="NSE:RELIANCE", mode=Vc.QuoteModes.FULL)
|
|
95
|
+
|
|
96
|
+
wire = VortexFeed(access_token)
|
|
97
|
+
wire.on_price_update = on_price_update
|
|
98
|
+
wire.on_connect = on_connect
|
|
99
|
+
wire.connect(threaded=True)
|
|
100
|
+
"""
|
|
101
|
+
from __future__ import unicode_literals, absolute_import
|
|
102
|
+
from vortex_api.api import VortexAPI,Constants
|
|
103
|
+
from vortex_api.vortex_feed import VortexFeed
|
|
104
|
+
from vortex_api.instruments import InstrumentManager, Instrument, InstrumentNotFound
|
|
105
|
+
__all__ = [VortexAPI,Constants,VortexFeed,InstrumentManager,Instrument,InstrumentNotFound]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.1.9"
|