-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNdtvProfit_Usage.py
More file actions
83 lines (58 loc) · 3.92 KB
/
NdtvProfit_Usage.py
File metadata and controls
83 lines (58 loc) · 3.92 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#=====================================================================#
# NdtvProfit Usage
#=====================================================================#
from NseKit import NdtvProfit
from rich.console import Console
convert_to_cr = True
filter_old_expiry = True
# Create NDTV Profit instance with global settings
api = NdtvProfit(convert_to_cr=convert_to_cr, filter_old_expiry=filter_old_expiry)
# api = NdtvProfit(convert_to_cr=False, filter_old_expiry=True)
# api = NdtvProfit(False, True)
rich = Console()
#---------------------------------------------------------- Summary ----------------------------------------------------------
# 🔹 Nifty Future Summary
# print(api.get_nifty_summary()) # Default: NIFTY 50
# print(api.get_nifty_summary("NIFTY BANK")) # Specific Index
# 🔹 Stock Reference Details
# print(api.get_stock_details("Nse")) # "All" | "Nse"
#---------------------------------------------------------- Options Data ----------------------------------------------------------
# 🔹 Most Active Options by Volume
# print(api.get_most_active_options_by_volume("call", "stock", limit=20)) # "call"|"put", "stock"|"index"
# print(api.get_most_active_options_by_volume("put", "index", limit=20, output="json"))
# 🔹 Top Options by Open Interest (OI)
# print(api.get_top_open_interest("call", "stock", limit=10)) # "call"|"put", "stock"|"index"
# print(api.get_top_open_interest("put", "index", limit=5))
# 🔹 Current F&O Open Interest Break-Up
# print(api.get_oi_breakup("stock")) # "stock"|"index"
# 🔹 F&O Open Interest Change Since Last Expiry
# print(api.get_oi_change_since_last_expiry("stock")) # "stock"|"index"
# 🔹 PCR (Put Call Ratio) Data
# print(api.get_pcr_data("stock")) # "stock" | "index"
#---------------------------------------------------------- Futures Data ----------------------------------------------------------
# 🔹 Future OI Gainers/Losers
# print(api.get_future_by_oi("up", limit=50)) # "up" | "down"
# 🔹 Future Premium/Discount
# print(api.get_future_by_premium_discount("premium", limit=50)) # "premium"|"discount"
# 🔹 Future Rollover
# print(api.get_future_by_rollover("highest", limit=50)) # "highest" | "lowest"
# 🔹 Buildups (Hedging)
# print(api.get_buildups("long_buildup", limit=50)) # "long_buildup" | "long_unwinding" | "short_covering" | "short_buildup"
# 🔹 Future Active Volume
# print(api.get_future_active_volume(show_large_change=False, limit=50)) # Most Active
# print(api.get_future_active_volume(show_large_change=True, limit=50)) # Large Volume Change
#---------------------------------------------------------- Sectoral Movement ----------------------------------------------------------
# 🔹 Sectoral Movement
# print(api.get_sectoral_movement()) # Comprehensive sectoral price/OI/Vol trends
#---------------------------------------------------------- Customization ----------------------------------------------------------
# 🔹 JSON Output (Raw Data)
# json_data = api.get_pcr_data("index", output="json")
# rich.print(json_data[0]) # Access raw API keys
# 🔹 Custom Column Ordering
# custom_order = ["Symbol", "OI", "OI Chg %", "Spot Price"]
# df = api.get_options_by_oi("call", "stock", column_order=custom_order)
# print(df.head())
# 🔹 Custom Header Mapping
# custom_map = {"symbol": "Ticker", "open-interest": "Total OI"}
# df = api.get_pcr_data("stock", header_map=custom_map)
# print(df.head())