wiz-trader 0.18.0__py3-none-any.whl → 0.19.0__py3-none-any.whl
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.
- wiz_trader/__init__.py +1 -1
- wiz_trader/apis/client.py +73 -5
- {wiz_trader-0.18.0.dist-info → wiz_trader-0.19.0.dist-info}/METADATA +368 -9
- wiz_trader-0.19.0.dist-info/RECORD +9 -0
- wiz_trader-0.18.0.dist-info/RECORD +0 -9
- {wiz_trader-0.18.0.dist-info → wiz_trader-0.19.0.dist-info}/WHEEL +0 -0
- {wiz_trader-0.18.0.dist-info → wiz_trader-0.19.0.dist-info}/top_level.txt +0 -0
wiz_trader/__init__.py
CHANGED
wiz_trader/apis/client.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2
2
|
import json
|
3
3
|
import logging
|
4
4
|
from typing import Dict, List, Optional, Union, Any
|
5
|
+
from datetime import datetime
|
5
6
|
|
6
7
|
import requests
|
7
8
|
|
@@ -137,6 +138,19 @@ class WizzerClient:
|
|
137
138
|
EXPIRY_FOURTH_QUARTER_PLUS_4 = "fourth_quarter_plus_4"
|
138
139
|
EXPIRY_FIRST_HALF_PLUS_4 = "first_half_yearly_plus_4"
|
139
140
|
EXPIRY_SECOND_HALF_PLUS_4 = "second_half_yearly_plus_4"
|
141
|
+
|
142
|
+
# Historical data interval constants
|
143
|
+
INTERVAL_1_MINUTE = "1m"
|
144
|
+
INTERVAL_2_MINUTES = "2m"
|
145
|
+
INTERVAL_3_MINUTES = "3m"
|
146
|
+
INTERVAL_5_MINUTES = "5m"
|
147
|
+
INTERVAL_10_MINUTES = "10m"
|
148
|
+
INTERVAL_15_MINUTES = "15m"
|
149
|
+
INTERVAL_30_MINUTES = "30m"
|
150
|
+
INTERVAL_45_MINUTES = "45m"
|
151
|
+
INTERVAL_1_HOUR = "1h"
|
152
|
+
INTERVAL_1_DAY = "1d"
|
153
|
+
INTERVAL_1_MONTH = "1M"
|
140
154
|
|
141
155
|
# URIs to various API endpoints
|
142
156
|
_routes = {
|
@@ -229,6 +243,33 @@ class WizzerClient:
|
|
229
243
|
|
230
244
|
return {"id": self.strategy_id}
|
231
245
|
|
246
|
+
def _validate_datetime_format(self, datetime_str: str, interval: str) -> bool:
|
247
|
+
"""
|
248
|
+
Validate datetime format based on interval type.
|
249
|
+
|
250
|
+
Args:
|
251
|
+
datetime_str (str): The datetime string to validate
|
252
|
+
interval (str): The interval type
|
253
|
+
|
254
|
+
Returns:
|
255
|
+
bool: True if format is valid for the interval
|
256
|
+
"""
|
257
|
+
# For daily and monthly intervals, only date is required
|
258
|
+
if interval in [self.INTERVAL_1_DAY, self.INTERVAL_1_MONTH]:
|
259
|
+
try:
|
260
|
+
datetime.strptime(datetime_str, "%Y-%m-%d")
|
261
|
+
return True
|
262
|
+
except ValueError:
|
263
|
+
return False
|
264
|
+
|
265
|
+
# For intraday intervals, datetime is required
|
266
|
+
else:
|
267
|
+
try:
|
268
|
+
datetime.strptime(datetime_str, "%Y-%m-%d %H:%M:%S")
|
269
|
+
return True
|
270
|
+
except ValueError:
|
271
|
+
return False
|
272
|
+
|
232
273
|
# ===== DATA HUB METHODS =====
|
233
274
|
|
234
275
|
def get_indices(self, trading_symbol: Optional[str] = None, exchange: Optional[str] = None) -> List[Dict[str, Any]]:
|
@@ -272,7 +313,7 @@ class WizzerClient:
|
|
272
313
|
logger.debug("Fetching index components with params: %s", params)
|
273
314
|
response = self._make_request("GET", self._routes["datahub.index.components"], params=params)
|
274
315
|
return response
|
275
|
-
|
316
|
+
|
276
317
|
def get_historical_ohlcv(
|
277
318
|
self,
|
278
319
|
instruments: List[str],
|
@@ -286,14 +327,41 @@ class WizzerClient:
|
|
286
327
|
|
287
328
|
Args:
|
288
329
|
instruments (List[str]): List of instrument identifiers (e.g., ["NSE:SBIN:3045"]).
|
289
|
-
start_date (str): Start date
|
290
|
-
|
330
|
+
start_date (str): Start date. For daily/monthly intervals: YYYY-MM-DD format.
|
331
|
+
For intraday intervals: YYYY-MM-DD HH:MM:SS format.
|
332
|
+
end_date (str): End date. For daily/monthly intervals: YYYY-MM-DD format.
|
333
|
+
For intraday intervals: YYYY-MM-DD HH:MM:SS format.
|
291
334
|
ohlcv (List[str]): List of OHLCV fields to retrieve (open, high, low, close, volume).
|
292
|
-
interval (str, optional): Data interval. Options:
|
335
|
+
interval (str, optional): Data interval. Options:
|
336
|
+
- Intraday: "1m", "2m", "3m", "5m", "10m", "15m", "30m", "45m", "1h"
|
337
|
+
- Daily: "1d" (default)
|
338
|
+
- Monthly: "1M" (last trading day of month)
|
339
|
+
|
340
|
+
Use constants like client.INTERVAL_5_MINUTES, client.INTERVAL_1_DAY, etc.
|
293
341
|
|
294
342
|
Returns:
|
295
343
|
List[Dict[str, Any]]: Historical data for requested instruments.
|
344
|
+
|
345
|
+
Note: For daily/monthly intervals, the 'date' field contains YYYY-MM-DD.
|
346
|
+
For intraday intervals, the 'date' field contains YYYY-MM-DD HH:MM:SS.
|
347
|
+
|
348
|
+
Raises:
|
349
|
+
ValueError: If datetime format doesn't match the interval requirements.
|
296
350
|
"""
|
351
|
+
# Validate datetime formats
|
352
|
+
if not self._validate_datetime_format(start_date, interval):
|
353
|
+
if interval in [self.INTERVAL_1_DAY, self.INTERVAL_1_MONTH]:
|
354
|
+
raise ValueError(f"For interval '{interval}', start_date must be in YYYY-MM-DD format")
|
355
|
+
else:
|
356
|
+
raise ValueError(f"For interval '{interval}', start_date must be in YYYY-MM-DD HH:MM:SS format")
|
357
|
+
|
358
|
+
if not self._validate_datetime_format(end_date, interval):
|
359
|
+
if interval in [self.INTERVAL_1_DAY, self.INTERVAL_1_MONTH]:
|
360
|
+
raise ValueError(f"For interval '{interval}', end_date must be in YYYY-MM-DD format")
|
361
|
+
else:
|
362
|
+
raise ValueError(f"For interval '{interval}', end_date must be in YYYY-MM-DD HH:MM:SS format")
|
363
|
+
|
364
|
+
endpoint = self._routes["datahub.historical.ohlcv"]
|
297
365
|
data = {
|
298
366
|
"instruments": instruments,
|
299
367
|
"startDate": start_date,
|
@@ -303,7 +371,7 @@ class WizzerClient:
|
|
303
371
|
}
|
304
372
|
|
305
373
|
logger.debug("Fetching historical OHLCV with data: %s", data)
|
306
|
-
response = self._make_request("POST",
|
374
|
+
response = self._make_request("POST", endpoint, json=data)
|
307
375
|
return response
|
308
376
|
|
309
377
|
# ===== ORDER MANAGEMENT METHODS =====
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: wiz_trader
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.19.0
|
4
4
|
Summary: A Python SDK for connecting to the Wizzer.
|
5
5
|
Home-page: https://bitbucket.org/wizzer-tech/quotes_sdk.git
|
6
6
|
Author: Pawan Wagh
|
@@ -388,29 +388,388 @@ for component in components[:5]:
|
|
388
388
|
```
|
389
389
|
|
390
390
|
#### Get Historical OHLCV Data
|
391
|
+
## Overview
|
391
392
|
|
392
|
-
|
393
|
+
The `get_historical_ohlcv` method supports multiple time intervals for historical data retrieval, from 1-minute intraday data to monthly aggregated data.
|
394
|
+
|
395
|
+
## Supported Intervals
|
396
|
+
|
397
|
+
### Intraday Intervals
|
398
|
+
- `1m` - 1 minute
|
399
|
+
- `2m` - 2 minutes
|
400
|
+
- `3m` - 3 minutes
|
401
|
+
- `5m` - 5 minutes
|
402
|
+
- `10m` - 10 minutes
|
403
|
+
- `15m` - 15 minutes
|
404
|
+
- `30m` - 30 minutes
|
405
|
+
- `45m` - 45 minutes
|
406
|
+
- `1h` - 1 hour
|
407
|
+
|
408
|
+
### Daily/Monthly Intervals
|
409
|
+
- `1d` - 1 day (default)
|
410
|
+
- `1M` - 1 month (last trading day of month)
|
411
|
+
|
412
|
+
## Date Format Requirements
|
413
|
+
|
414
|
+
### For Daily and Monthly Intervals (`1d`, `1M`)
|
415
|
+
- **Format**: `YYYY-MM-DD`
|
416
|
+
- **Example**: `"2024-01-15"`
|
417
|
+
|
418
|
+
### For Intraday Intervals (all minute/hour intervals)
|
419
|
+
- **Format**: `YYYY-MM-DD HH:MM:SS`
|
420
|
+
- **Example**: `"2024-01-15 09:30:00"`
|
421
|
+
|
422
|
+
## Using Constants
|
423
|
+
|
424
|
+
The client provides constants for all intervals:
|
425
|
+
|
426
|
+
```python
|
427
|
+
from wiz_trader import WizzerClient
|
428
|
+
|
429
|
+
client = WizzerClient(...)
|
430
|
+
|
431
|
+
# Intraday intervals
|
432
|
+
client.INTERVAL_1_MINUTE # "1m"
|
433
|
+
client.INTERVAL_2_MINUTES # "2m"
|
434
|
+
client.INTERVAL_3_MINUTES # "3m"
|
435
|
+
client.INTERVAL_5_MINUTES # "5m"
|
436
|
+
client.INTERVAL_10_MINUTES # "10m"
|
437
|
+
client.INTERVAL_15_MINUTES # "15m"
|
438
|
+
client.INTERVAL_30_MINUTES # "30m"
|
439
|
+
client.INTERVAL_45_MINUTES # "45m"
|
440
|
+
client.INTERVAL_1_HOUR # "1h"
|
441
|
+
|
442
|
+
# Daily/Monthly intervals
|
443
|
+
client.INTERVAL_1_DAY # "1d"
|
444
|
+
client.INTERVAL_1_MONTH # "1M"
|
445
|
+
```
|
446
|
+
|
447
|
+
## Usage Examples
|
448
|
+
|
449
|
+
### 1. Get 5-minute intraday data
|
450
|
+
|
451
|
+
```python
|
452
|
+
# Get 5-minute candles for a trading session
|
453
|
+
intraday_data = client.get_historical_ohlcv(
|
454
|
+
instruments=["NSE:SBIN:3045"],
|
455
|
+
start_date="2024-01-15 09:15:00", # Market open
|
456
|
+
end_date="2024-01-15 15:30:00", # Market close
|
457
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
458
|
+
interval=client.INTERVAL_5_MINUTES
|
459
|
+
)
|
460
|
+
|
461
|
+
# Response will have date field as: "2024-01-15 09:15:00", "2024-01-15 09:20:00", etc.
|
462
|
+
```
|
463
|
+
|
464
|
+
### 2. Get 1-minute data for scalping
|
465
|
+
|
466
|
+
```python
|
467
|
+
# Get 1-minute data for the first hour of trading
|
468
|
+
scalping_data = client.get_historical_ohlcv(
|
469
|
+
instruments=["NSE:RELIANCE:2885", "NSE:TCS:2953"],
|
470
|
+
start_date="2024-01-15 09:15:00",
|
471
|
+
end_date="2024-01-15 10:15:00",
|
472
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
473
|
+
interval=client.INTERVAL_1_MINUTE
|
474
|
+
)
|
475
|
+
```
|
476
|
+
|
477
|
+
### 3. Get hourly data for swing trading
|
478
|
+
|
479
|
+
```python
|
480
|
+
# Get hourly data for a week
|
481
|
+
hourly_data = client.get_historical_ohlcv(
|
482
|
+
instruments=["NSE:NIFTY 50:26000"],
|
483
|
+
start_date="2024-01-15 09:15:00",
|
484
|
+
end_date="2024-01-19 15:30:00",
|
485
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
486
|
+
interval=client.INTERVAL_1_HOUR
|
487
|
+
)
|
488
|
+
```
|
489
|
+
|
490
|
+
### 4. Get daily data (traditional)
|
393
491
|
|
394
492
|
```python
|
395
|
-
# Get daily data
|
493
|
+
# Get daily data for a month
|
396
494
|
daily_data = client.get_historical_ohlcv(
|
397
495
|
instruments=["NSE:SBIN:3045"],
|
398
|
-
start_date="2024-01-01",
|
496
|
+
start_date="2024-01-01", # Note: No time component
|
399
497
|
end_date="2024-01-31",
|
400
498
|
ohlcv=["open", "high", "low", "close", "volume"],
|
401
|
-
interval=
|
499
|
+
interval=client.INTERVAL_1_DAY
|
402
500
|
)
|
403
501
|
|
404
|
-
#
|
502
|
+
# Response will have date field as: "2024-01-01", "2024-01-02", etc.
|
503
|
+
```
|
504
|
+
|
505
|
+
### 5. Get monthly data for long-term analysis
|
506
|
+
|
507
|
+
```python
|
508
|
+
# Get monthly data for a year
|
405
509
|
monthly_data = client.get_historical_ohlcv(
|
406
|
-
instruments=["NSE:SBIN:3045"
|
510
|
+
instruments=["NSE:SBIN:3045"],
|
407
511
|
start_date="2023-01-01",
|
408
|
-
end_date="
|
512
|
+
end_date="2023-12-31",
|
409
513
|
ohlcv=["close", "volume"],
|
410
|
-
interval=
|
514
|
+
interval=client.INTERVAL_1_MONTH
|
411
515
|
)
|
412
516
|
```
|
413
517
|
|
518
|
+
## Response Structure
|
519
|
+
|
520
|
+
The response structure remains the same, but the `date` field format varies:
|
521
|
+
|
522
|
+
### For Daily/Monthly Intervals
|
523
|
+
```json
|
524
|
+
{
|
525
|
+
"instrument": {
|
526
|
+
"exchange": "NSE",
|
527
|
+
"tradingSymbol": "SBIN",
|
528
|
+
"exchangeToken": 3045,
|
529
|
+
"identifier": "NSE:SBIN:3045"
|
530
|
+
},
|
531
|
+
"data": [
|
532
|
+
{
|
533
|
+
"date": "2024-01-15", // YYYY-MM-DD format
|
534
|
+
"open": 750.0,
|
535
|
+
"high": 765.0,
|
536
|
+
"low": 745.0,
|
537
|
+
"close": 760.0,
|
538
|
+
"volume": 1000000
|
539
|
+
}
|
540
|
+
]
|
541
|
+
}
|
542
|
+
```
|
543
|
+
|
544
|
+
### For Intraday Intervals
|
545
|
+
```json
|
546
|
+
{
|
547
|
+
"instrument": {
|
548
|
+
"exchange": "NSE",
|
549
|
+
"tradingSymbol": "SBIN",
|
550
|
+
"exchangeToken": 3045,
|
551
|
+
"identifier": "NSE:SBIN:3045"
|
552
|
+
},
|
553
|
+
"data": [
|
554
|
+
{
|
555
|
+
"date": "2024-01-15 09:15:00", // YYYY-MM-DD HH:MM:SS format
|
556
|
+
"open": 750.0,
|
557
|
+
"high": 752.0,
|
558
|
+
"low": 749.0,
|
559
|
+
"close": 751.0,
|
560
|
+
"volume": 50000
|
561
|
+
}
|
562
|
+
]
|
563
|
+
}
|
564
|
+
```
|
565
|
+
|
566
|
+
## Advanced Usage Examples
|
567
|
+
|
568
|
+
### Multiple Timeframe Analysis
|
569
|
+
|
570
|
+
```python
|
571
|
+
def get_multi_timeframe_data(symbol, date):
|
572
|
+
"""Get data across multiple timeframes for comprehensive analysis"""
|
573
|
+
|
574
|
+
# 1-minute data for entry/exit precision
|
575
|
+
minute_data = client.get_historical_ohlcv(
|
576
|
+
instruments=[symbol],
|
577
|
+
start_date=f"{date} 09:15:00",
|
578
|
+
end_date=f"{date} 15:30:00",
|
579
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
580
|
+
interval=client.INTERVAL_1_MINUTE
|
581
|
+
)
|
582
|
+
|
583
|
+
# 5-minute data for short-term trends
|
584
|
+
five_min_data = client.get_historical_ohlcv(
|
585
|
+
instruments=[symbol],
|
586
|
+
start_date=f"{date} 09:15:00",
|
587
|
+
end_date=f"{date} 15:30:00",
|
588
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
589
|
+
interval=client.INTERVAL_5_MINUTES
|
590
|
+
)
|
591
|
+
|
592
|
+
# 15-minute data for medium-term trends
|
593
|
+
fifteen_min_data = client.get_historical_ohlcv(
|
594
|
+
instruments=[symbol],
|
595
|
+
start_date=f"{date} 09:15:00",
|
596
|
+
end_date=f"{date} 15:30:00",
|
597
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
598
|
+
interval=client.INTERVAL_15_MINUTES
|
599
|
+
)
|
600
|
+
|
601
|
+
# Hourly data for major trend
|
602
|
+
hourly_data = client.get_historical_ohlcv(
|
603
|
+
instruments=[symbol],
|
604
|
+
start_date=f"{date} 09:15:00",
|
605
|
+
end_date=f"{date} 15:30:00",
|
606
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
607
|
+
interval=client.INTERVAL_1_HOUR
|
608
|
+
)
|
609
|
+
|
610
|
+
return {
|
611
|
+
"1m": minute_data,
|
612
|
+
"5m": five_min_data,
|
613
|
+
"15m": fifteen_min_data,
|
614
|
+
"1h": hourly_data
|
615
|
+
}
|
616
|
+
|
617
|
+
# Usage
|
618
|
+
multi_data = get_multi_timeframe_data("NSE:SBIN:3045", "2024-01-15")
|
619
|
+
```
|
620
|
+
|
621
|
+
### Building OHLC Candlestick Data
|
622
|
+
|
623
|
+
```python
|
624
|
+
import pandas as pd
|
625
|
+
import matplotlib.pyplot as plt
|
626
|
+
from mplfinance import plot as mpf
|
627
|
+
|
628
|
+
def plot_candlestick_chart(symbol, start_date, end_date, interval):
|
629
|
+
"""Create a candlestick chart from historical data"""
|
630
|
+
|
631
|
+
# Get historical data
|
632
|
+
data = client.get_historical_ohlcv(
|
633
|
+
instruments=[symbol],
|
634
|
+
start_date=start_date,
|
635
|
+
end_date=end_date,
|
636
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
637
|
+
interval=interval
|
638
|
+
)
|
639
|
+
|
640
|
+
if not data or not data[0].get('data'):
|
641
|
+
print("No data available")
|
642
|
+
return
|
643
|
+
|
644
|
+
# Convert to DataFrame
|
645
|
+
df = pd.DataFrame(data[0]['data'])
|
646
|
+
df['date'] = pd.to_datetime(df['date'])
|
647
|
+
df.set_index('date', inplace=True)
|
648
|
+
|
649
|
+
# Rename columns for mplfinance
|
650
|
+
df.columns = ['Open', 'High', 'Low', 'Close', 'Volume']
|
651
|
+
|
652
|
+
# Create candlestick chart
|
653
|
+
mpf.plot(df, type='candle', volume=True,
|
654
|
+
title=f'{symbol} - {interval} Chart',
|
655
|
+
style='charles')
|
656
|
+
|
657
|
+
# Plot 5-minute chart
|
658
|
+
plot_candlestick_chart(
|
659
|
+
"NSE:SBIN:3045",
|
660
|
+
"2024-01-15 09:15:00",
|
661
|
+
"2024-01-15 15:30:00",
|
662
|
+
client.INTERVAL_5_MINUTES
|
663
|
+
)
|
664
|
+
```
|
665
|
+
|
666
|
+
### Backtesting with Different Intervals
|
667
|
+
|
668
|
+
```python
|
669
|
+
def backtest_strategy_multiple_intervals(symbol, start_date, end_date):
|
670
|
+
"""Backtest a strategy across different intervals"""
|
671
|
+
|
672
|
+
intervals = [
|
673
|
+
(client.INTERVAL_5_MINUTES, "5m"),
|
674
|
+
(client.INTERVAL_15_MINUTES, "15m"),
|
675
|
+
(client.INTERVAL_30_MINUTES, "30m"),
|
676
|
+
(client.INTERVAL_1_HOUR, "1h")
|
677
|
+
]
|
678
|
+
|
679
|
+
results = {}
|
680
|
+
|
681
|
+
for interval_code, interval_name in intervals:
|
682
|
+
# For intraday intervals, use datetime format
|
683
|
+
data = client.get_historical_ohlcv(
|
684
|
+
instruments=[symbol],
|
685
|
+
start_date=f"{start_date} 09:15:00",
|
686
|
+
end_date=f"{end_date} 15:30:00",
|
687
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
688
|
+
interval=interval_code
|
689
|
+
)
|
690
|
+
|
691
|
+
if data and data[0].get('data'):
|
692
|
+
df = pd.DataFrame(data[0]['data'])
|
693
|
+
df['date'] = pd.to_datetime(df['date'])
|
694
|
+
|
695
|
+
# Simple moving average crossover strategy
|
696
|
+
df['sma_10'] = df['close'].rolling(10).mean()
|
697
|
+
df['sma_20'] = df['close'].rolling(20).mean()
|
698
|
+
|
699
|
+
# Generate signals
|
700
|
+
df['signal'] = 0
|
701
|
+
df.loc[df['sma_10'] > df['sma_20'], 'signal'] = 1
|
702
|
+
df.loc[df['sma_10'] < df['sma_20'], 'signal'] = -1
|
703
|
+
|
704
|
+
# Calculate returns
|
705
|
+
df['returns'] = df['close'].pct_change()
|
706
|
+
df['strategy_returns'] = df['signal'].shift(1) * df['returns']
|
707
|
+
|
708
|
+
# Calculate total return
|
709
|
+
total_return = (1 + df['strategy_returns']).prod() - 1
|
710
|
+
|
711
|
+
results[interval_name] = {
|
712
|
+
'total_return': total_return,
|
713
|
+
'num_trades': df['signal'].diff().abs().sum() / 2,
|
714
|
+
'num_candles': len(df)
|
715
|
+
}
|
716
|
+
|
717
|
+
return results
|
718
|
+
|
719
|
+
# Compare strategy performance across intervals
|
720
|
+
performance = backtest_strategy_multiple_intervals(
|
721
|
+
"NSE:SBIN:3045",
|
722
|
+
"2024-01-01",
|
723
|
+
"2024-01-31"
|
724
|
+
)
|
725
|
+
|
726
|
+
for interval, metrics in performance.items():
|
727
|
+
print(f"{interval}: Return={metrics['total_return']:.2%}, "
|
728
|
+
f"Trades={metrics['num_trades']:.0f}, "
|
729
|
+
f"Candles={metrics['num_candles']}")
|
730
|
+
```
|
731
|
+
|
732
|
+
## Error Handling
|
733
|
+
|
734
|
+
```python
|
735
|
+
try:
|
736
|
+
data = client.get_historical_ohlcv(
|
737
|
+
instruments=["NSE:SBIN:3045"],
|
738
|
+
start_date="2024-01-15 09:15:00",
|
739
|
+
end_date="2024-01-15 15:30:00",
|
740
|
+
ohlcv=["open", "high", "low", "close", "volume"],
|
741
|
+
interval=client.INTERVAL_5_MINUTES
|
742
|
+
)
|
743
|
+
except ValueError as e:
|
744
|
+
print(f"Date format error: {e}")
|
745
|
+
except Exception as e:
|
746
|
+
print(f"API error: {e}")
|
747
|
+
```
|
748
|
+
|
749
|
+
## Best Practices
|
750
|
+
|
751
|
+
1. **Use appropriate intervals for your strategy**:
|
752
|
+
- Scalping: 1m, 2m, 3m
|
753
|
+
- Day trading: 5m, 15m, 30m
|
754
|
+
- Swing trading: 1h, 1d
|
755
|
+
- Position trading: 1d, 1M
|
756
|
+
|
757
|
+
2. **Be mindful of data volume**:
|
758
|
+
- 1-minute data generates a lot of candles
|
759
|
+
- Use shorter date ranges for minute-level data
|
760
|
+
|
761
|
+
3. **Validate date formats**:
|
762
|
+
- The client will validate formats automatically
|
763
|
+
- Use datetime strings consistently
|
764
|
+
|
765
|
+
4. **Consider market hours**:
|
766
|
+
- For intraday data, use market hours: 09:15:00 to 15:30:00
|
767
|
+
- Weekend dates won't have intraday data
|
768
|
+
|
769
|
+
5. **Cache data when possible**:
|
770
|
+
- Historical data doesn't change
|
771
|
+
- Store frequently used datasets locally
|
772
|
+
|
414
773
|
### Order Management
|
415
774
|
|
416
775
|
#### Place Regular Order
|
@@ -0,0 +1,9 @@
|
|
1
|
+
wiz_trader/__init__.py,sha256=iU9Crioz_4eIjYFIOJ9aqjfGXBMxvEi_836Ln39sV70,182
|
2
|
+
wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
|
3
|
+
wiz_trader/apis/client.py,sha256=vFoKHJWfyLTX7Alb6WK2fxJimqLj7E42ri1bl_jUDWY,56281
|
4
|
+
wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
|
5
|
+
wiz_trader/quotes/client.py,sha256=LJeMcQPjJIRxrTIGalWsLYh_XfinDXBP5-4cNS7qCxc,9709
|
6
|
+
wiz_trader-0.19.0.dist-info/METADATA,sha256=GxrCN8ospIwoUahWVp6WC669msDd61KTNaCQvg7_Tqw,82928
|
7
|
+
wiz_trader-0.19.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
8
|
+
wiz_trader-0.19.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
|
9
|
+
wiz_trader-0.19.0.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
wiz_trader/__init__.py,sha256=UCNwgBmLz6fPSfo69NlZZd9pJeorYKXgTs4Y3bslEBc,182
|
2
|
-
wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
|
3
|
-
wiz_trader/apis/client.py,sha256=Mbgzadgx__1QpUiz1itpWQL66lGFWOhSXSfWggtFqp0,53712
|
4
|
-
wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
|
5
|
-
wiz_trader/quotes/client.py,sha256=LJeMcQPjJIRxrTIGalWsLYh_XfinDXBP5-4cNS7qCxc,9709
|
6
|
-
wiz_trader-0.18.0.dist-info/METADATA,sha256=yzbGX_R69DE-0p8IXfQJo69hrg_S5xIRHnPXSnCih3Q,73214
|
7
|
-
wiz_trader-0.18.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
8
|
-
wiz_trader-0.18.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
|
9
|
-
wiz_trader-0.18.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|