-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathget_instrument_details.py
68 lines (52 loc) · 1.75 KB
/
get_instrument_details.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from dhanhq_ticker_py import (
get_option_chain,
get_expiry_dates,
get_instrument_details,
get_instruments_details,
fetch_and_save_latest_dhan_master_scrip_feather,
)
fetch_and_save_latest_dhan_master_scrip_feather()
get_instrument_details("RELIANCE", "BSE", is_equity=True, pretty_print=True)
get_instrument_details(
"USDINR",
"BSE",
is_optcur=True,
expiry_date="2023-12-08",
strike=82.5,
opt_type="CE",
pretty_print=True,
)
get_instruments_details(
["RELIANCE", "HDFCBANK"], "BSE", is_equity=True, pretty_print=True
)
get_instruments_details(["SENSEX", "BANKEX"], "BSE", is_index=True, pretty_print=True)
get_instruments_details(
["NIFTY", "BANKNIFTY", "FINNNIFTY", "MIDCPNIFTY"],
"NSE",
is_index=True,
pretty_print=True,
)
print(get_expiry_dates("NIFTY", "NSE"))
print(get_option_chain("NIFTY", "NSE"))
print(get_option_chain("NIFTY", "NSE", "2023-12-14"))
print(get_expiry_dates("BANKNIFTY", "NSE"))
print(get_option_chain("BANKNIFTY", "NSE"))
print(get_option_chain("BANKNIFTY", "NSE", "2023-12-13"))
bnf_expiry, nf_expiry = [get_expiry_dates(idx, "NSE") for idx in {"BANKNIFTY", "NIFTY"}]
print(bnf_expiry, nf_expiry, sep="\n" * 2, end="\n" * 2)
nearest_bnf_expiry, nearest_nf_expiry = (
bnf_expiry["ExpiryDate"][0],
nf_expiry["ExpiryDate"][0],
)
print(nearest_bnf_expiry, nearest_nf_expiry, sep="\n" * 2, end="\n" * 2)
instruments = get_instruments_details(
["NIFTY", "BANKNIFTY"],
"NSE",
is_optidx=True,
expiry_dates=[nearest_bnf_expiry, nearest_nf_expiry],
strikes=[20000, 45000],
opt_types=["CE", "PE"],
)
print(instruments, end="\n" * 2)
finnifty_all_nearest_expiry_options = get_option_chain("FINNIFTY", "NSE")
print(finnifty_all_nearest_expiry_options, end="\n" * 2)