0% found this document useful (0 votes)
3 views

Understanding_Different_functions

Uploaded by

Sai Rajeev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Understanding_Different_functions

Uploaded by

Sai Rajeev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Overview of Functions

NIFTY

1. Flow of ImportChain Function

Initialize Spreadsheet

● Access the active Google Spreadsheet.


● Select the sheet named 'DATA'.
● Define the API URL for fetching Nifty options data.

Check Trigger Condition

● Read the value from cell A11 in the 'DATA' sheet.


● If the value is 1, proceed to fetch data.
● If the value is not 1, log a message: "Script execution is turned off."

Fetch Data from API

● Send a request to the defined API URL using UrlFetchApp.fetch().


● Parse the JSON response to extract options data.

Extract Relevant Data

● Use map() to create an array of arrays containing:Call and put Greeks


(e.g., rho, vega, gamma, theta, delta).

Populate Google Sheet


● Write the extracted data into the 'DATA' sheet starting from cell B3.

Clear Old Data (if necessary)

● Determine the last row with data in the sheet.


● If there are rows below the newly populated data:Clear those rows to
remove stale content.

Call Additional Function

● Execute SetValues() for further processing or updates (function details


not provided).

2. ImportValue(url)
Purpose: This function imports specific data about the Nifty index from a given URL and
updates the Google Sheet based on a trigger cell's value.

Key Components:

● Spreadsheet and Sheet Access: The function retrieves the active spreadsheet and
accesses the sheet named 'DATA'.
● Trigger Cell Check: It checks the value of a specific cell (A11). If this cell contains 1, it
proceeds to fetch data; otherwise, it logs that the script execution is turned off.
● Data Fetching: It uses UrlFetchApp.fetch(url) to get data from the specified API
endpoint. The URL is hardcoded to fetch today's spot data for Nifty.
● Data Extraction: The JSON response is parsed, and specific fields (like symbol name,
last trade price, high, low, etc.) are extracted into an array.
● Sheet Update: Finally, it writes this extracted data into the sheet starting from row 3
and column 31.

3. GetDate(url)
Purpose: This function retrieves the start date for contributors related to the Nifty index.
Key Components:

● Error Handling: It uses a try-catch block to handle potential errors during API calls.
● API Call: It fetches data from another API endpoint that provides a list of contributor
dates for Nifty.
● Date Extraction: The start date is extracted from the JSON response and returned as
an array.

4. GetData(url)
Purpose: This function retrieves summary data about the Nifty index.

Key Components:

● API Call and Data Parsing: Similar to the previous functions, it fetches data from a
specified URL and parses the JSON response.
● Summary Data Extraction: It extracts summary statistics such as positive and
negative counts and their respective sums.
● Return Values: The function returns these values as an array.

5. Function: SaveData()
● Purpose: Append the first row of the "Record" sheet to the end of the sheet.
● Process:
1. Retrieve the active spreadsheet.
2. Access the "Record" sheet.
3. Get values from the range A1:FZ1 (first row).
4. Append these values as a new row at the bottom of the "Record" sheet.

6. Function: Clear()
● Purpose: Clear contents in a specified range (A5:FZ600) of the "Record" sheet without
affecting filtered rows.
● Process:
1. Retrieve the active spreadsheet.
2. Activate the range A5:FZ600 in the "Record" sheet.
3. Clear contents while skipping filtered rows.
4. Reactivate cell A5 for user convenience.

7. Function: SetValues()
● Purpose: Copy values from one range (A2:AE250) to another (starting at I2) within the
"Change" sheet.
● Process:
○ Retrieve the active spreadsheet.
○ Access the "Change" sheet.
○ Copy values from A2:AE250 and paste them into I2 using PASTE_VALUES.
○ Log a message indicating successful execution.

8. Function Refresh

● Access the Active Spreadsheet


● Action: Retrieve the active spreadsheet.
● Purpose: To interact with the specific spreadsheet where the function will operate.
● Get the "DATA" Sheet
● Action: Attempt to access the sheet named "DATA".
● Purpose: To ensure that the function modifies the correct sheet.
● Check for Sheet Existence
● Action: Verify if the "DATA" sheet exists.
● If it does not exist:Log Message
● Get Current Date and Time
● Action: Create a new Date object representing the current date and time.
● Purpose: To have a timestamp to be recorded in cell A5.
● Format the Date
● Action: Use Utilities.formatDate to format the current date and time into a readable
string (e.g., "MM/dd/yyyy HH:mm:ss").
● Purpose: To enhance readability of the timestamp when displayed in the spreadsheet.
● Clear Cell A5
● Action: Clear any existing content in cell A5 while preserving its formatting.
● Purpose: To prepare cell A5 for new data without affecting its style.
● Set New Value in Cell A5
● Action: Insert the formatted current date and time into cell A5.
● Purpose: To update cell A5 with the latest timestamp.
NIFTY LiVE

1. Flow of the SaveData Function


● Start
○ The function SaveData is called.

● Access Active Spreadsheet


○ Retrieve the currently active spreadsheet using
SpreadsheetApp.getActiveSpreadsheet().

● Access Specific Sheet


○ Get the sheet named "Record" from the active spreadsheet using
getSheetByName("Record").

● Define Source Range


○ Specify the range of cells from A1 to TL1 using getRange("A1:TL1").

● Retrieve Values from Range


○ Get the values from the specified range as a two-dimensional array using
getValues().

● Append Row to Sheet


○ Append the first row of values (i.e., values) to the bottom of the "Record" sheet
using appendRow().

● End
○ The function completes execution.

2. Flow of the Clear() Function

The function Clear() is designed to clear the contents of a specific range in a Google
Sheets spreadsheet, specifically in the "Record" sheet. The range targeted for clearing is
from cell A5 to TL500. The function also ensures that it skips any filtered rows when clearing
the contents.
● Start: The function is invoked.
● Access Spreadsheet: It retrieves and references the active spreadsheet.
● Select Range: It activates a specific range (A5:TL500) in the "Record" sheet.
● Clear Contents: It clears only the contents of that range while skipping filtered rows
(the second clear call is unnecessary).
● Return Focus: Finally, it reactivates cell A5 for user convenience.

3. Function: onEdit(e)
onEdit(e): This function is triggered whenever a user edits the spreadsheet.

This function handles actions based on specific checkbox selections in the "Test" sheet.

Key Components
● Parameters:
● e: An event object that contains information about the edit event, including the
range that was edited.

● Variables:
● sheetName: A constant that specifies the name of the sheet ("Test") where the
script will operate.
● range: The range of cells that were edited.
● sheet: The specific sheet object corresponding to the edited range.
Logic Flow
● Check Sheet Name:
○ The function first checks if the edited sheet is named "Test".

● Checkbox Actions:
○ It then checks which specific cell was edited and whether it is checked
(i.e., true):Cell T9 Checked

● Reset Checkbox:
○ After processing any of these actions, it unchecks the checkbox that
was edited, ensuring it resets for future interactions.

4. Functions: addvalue() and devalue()


addvalue() and devalue(): These functions are designed to increment or decrement the
value in cell AJ1, respectively.

These two functions allow for manual incrementing or decrementing of the value in cell AJ1.

addvalue()
● Retrieves the current value from cell AJ1.
● Increments that value by 1.
● Updates cell AJ1 with the new value.

devalue()
● Retrieves the current value from cell AJ1.
● Decrements that value by 1.
● Updates cell AJ1 with the new value.
5. Function archiveCopy()

Flow of the archiveCopy() Function

a. Initialization
● Access Active Spreadsheet: The function starts by accessing the currently
active Google Spreadsheet using SpreadsheetApp.getActive().
● Select Specific Sheet: It then selects a sheet named 'OC' where the relevant
data and trigger cell are located.

b. Retrieve Trigger Value


● Read Trigger Cell: The script reads the value from cell AK5 in the 'OC' sheet.
This cell acts as a trigger to determine whether to execute the file copy
operation.

c. Conditional Execution
● Check Trigger Condition: The function checks if the value retrieved from AK5
equals 1:
● If true (i.e., trigger condition is met), it proceeds to copy the file.
● If false, it logs a message indicating that script execution is turned off,
and no further actions are taken.

d. File and Folder Setup


● Identify File: If the trigger condition is met, the script identifies the file to be
copied using its unique ID with DriveApp.getFileById().
● Identify Destination Folder: It also specifies the destination folder where the
copied file will be stored, again using a unique ID with
DriveApp.getFolderById().

e. Date Formatting
● Get Time Zone: The script retrieves the current time zone for accurate date
formatting.
● Format Current Date: It formats the current date into a specific string format
(e.g., "dd-MM-yyyy") to create a meaningful name for the copied file.
● Create New File Name: The formatted date is concatenated with the string
"NIFTY" to create a new file name (e.g., "NIFTY 03-12-2024").
f. Copying the File
● Make Copy: The script executes file.makeCopy(name, destination), which
creates a copy of the specified file in the designated folder with the newly
generated name.

g. Logging for Non-execution


● If the trigger condition was not met (i.e., if AK5 did not equal 1), a log entry is
created stating that script execution is turned off, providing feedback on why
no action was taken.

Flow of Google Apps Script Configuration

1. Script Initialization
● Load Configuration: The script loads the configuration settings defined in the
JSON.
● Time Zone: Set to "Asia/Kolkata".
● Logging: Exception logging is configured to use Stackdriver.
● Runtime Version: The script uses the V8 JavaScript engine.

2. Define Macros
● Macro Definitions: The script defines a list of macros that will appear in the
Google Sheets menu.
● Each macro has:Menu Name

3. User Interaction
● Open Google Sheets: The user opens a Google Sheets document where the
script is deployed.
● Access Custom Menu:
● The user navigates to the custom menu created by the script, which
displays all defined macros.

4. Execute Macro
● Select Macro: The user selects a macro from the menu (e.g., "Clear",
"GetData").
● Trigger Function Execution:
● The corresponding function (e.g., Clear, GetData) is executed.
● The function performs its defined task within the spreadsheet (e.g.,
clearing data, fetching data).

5. Logging and Error Handling


● Error Handling: If an error occurs during function execution:
● The error is logged using Stackdriver for later review.
● Feedback to User: Depending on implementation, feedback may be provided
to the user (e.g., success message, error notification).

6. End of Execution
● The script completes its execution and returns control back to the user in
Google Sheets.

NIFTY:

Data - Options - OI Analysis - S/R Analysis - Setup - Ticks - Record - change(different


sheets)

Macros used
- Clear
- ROC
- GetData

List of Macros
● Clear: Executes the Clear function.
● ROC: Executes the ROC function.
● DATA: Executes the DATA function.
● DATAA: Executes the DATAA function.
● GetData: Executes the GetData function (listed twice).
● get: Executes the get function.
● get 1: Executes the get1 function.
● GETY: Executes the GETY function.
● GG: Executes the GG function.
● gety: Executes the gety function.
—------------------------------------------------------------------------------------------------------------------------

Terminology Used - Just for reference


INPUTS:

1. Expiry Date
2. Today Date

STRIKE LEVEL DATA (For Calls and Puts):

1. Strike Price
2. Call OI
3. Put OI
4. Net OI
5. Zero Line (with respect to time)

METRICS AND INDICATORS:

1. LTP (Last Traded Price)


2. LTP Change
3. IV (Implied Volatility)
4. Delta
5. IV/Delta
6. OI Change
7. Net OI Change
8. Net Volume
9. Trading Volume
10. Volume
11. OI
12. OI Change Difference
13. PCR OI (Put-Call Ratio - Open Interest)
14. PCR OI Change
15. VIX (Volatility Index)
16. EOR (End of Range)
17. EOS (End of Strike)
RESISTANCE AND SUPPORT ANALYSIS:

1. Resistance:
○ Based on Volume (Strong/Weak)
○ Based on OI (WTB/Strong/Weakens)
○ Based on Delta (e.g., IV: 2.05/Delta: 0.07)
2. Support:
○ Based on Volume (Strong/Weak)
○ Based on OI (WTB/Bullish/Bearish)
○ Based on Delta (e.g., IV: 7.71/Delta: -0.40)

SENTIMENT ANALYSIS:

1. Bullishness:
○ Based on OI (Strong/Weak)
○ Based on Volume (Bearish/Bullish)
2. Bearishness:
○ Resistance (WTB)
○ Support (Volume-Based Weakening)

TIME SERIES & TRENDS:

1. WTB to Resistance Since N Months


2. WTB to Support Since N Months
3. Particular Minute-Level Analysis:
○ IV and Delta as Indicators (Resistance/Support)

1. WTB (Willingness to Buy):


○ Used to identify support levels.
2. WTT (Willingness to Trade):
○ Refers to the activity level and liquidity at specific strikes.
3. OI (Open Interest):
○ Tracks the total contracts at a given strike.
4. Volume:
○ Measures traded contracts.
5. WTB (Weak Trend Base): Indicates zones of weakening trader positions, usually near
support/resistance.
6. WTT (Weak Trend Top): Reflects zones where price action struggles to break resistance or
support.

Use WTB = Willingness to Buy and WTT = Willingness to Trade for market behavior analysis related
to demand, support, activity, and liquidity.
Use WTB = Weak Trend Base and WTT = Weak Trend Top when discussing technical weakening at
support or resistance zones.

Terminology Meaning Used

Price and Market Indicators

● Spot Price: The current market price of the underlying asset.


● Last Traded Price (LTP): The most recent price at which an option was
traded.
● Strike Price: The fixed price at which the underlying asset can be bought
or sold.
● Time to Expiry: The duration left until the option expires.

Open Interest (OI) and Volume

● Call OI: Open Interest in call options for a specific strike price, indicating
resistance levels.
● Put OI: Open Interest in put options for a specific strike price, indicating
support levels.
● OI Change: Changes in OI over time, suggesting new positions being built
or unwound.
● Volume: Total traded volume of options contracts, indicating liquidity
and activity.
● Net OI Change: The aggregated OI change across all strikes for calls/puts.

Implied Volatility (IV) and Greeks

● Implied Volatility (IV): Market's expectation of future volatility.


● Delta: The sensitivity of an option's price to changes in the underlying
asset price.
○ Call Delta: Positive, representing the likelihood of the option being
in-the-money.
○ Put Delta: Negative, representing the likelihood of the option being
in-the-money.
● Gamma: The rate of change of Delta, highlighting volatility risks.
● Theta: The rate of time decay in the option's value as expiration
approaches.
● Vega: Sensitivity of an option’s price to changes in IV.

Market Sentiment Metrics

● Put-Call Ratio (PCR): Ratio of total put OI to total call OI.


○ PCR OI Change: Indicates sentiment shifts over time.
● Market Sentiment: Derived from a combination of PCR, IV, and volume
data.

Support and Resistance

● Resistance:
○ OI-Based Resistance: Strikes with the highest call OI.
○ Volume-Based Resistance: Strikes with high call volume but weak
OI changes (WTB - Weakening Trend Base).
● Support:
○ OI-Based Support: Strikes with the highest put OI.
○ Volume-Based Support: Strikes with high put volume but weak OI
changes.

Volatility Index (VIX)

● VIX: Market-wide measure of expected volatility, impacting option


premiums.

Trading Metrics

● Net Volume: Aggregated trading volume across calls/puts.


● Trading Volume Changes: Reflects increasing or decreasing trader
activity at specific strikes.
Derived Metrics

● WTB (Weak Trend Base): Indicates zones of weakening trader positions,


usually near support/resistance.
● WTT (Weak Trend Top): Reflects zones where price action struggles to
break resistance or support.
● Bullishness/Bearishness Scores: Quantitative measures derived from OI,
volume, and sentiment analysis.

Time-Based Metrics

● Zero Line Analysis: Tracks strike-specific OI changes over time to identify


resistance/support trends.
● Historical Resistance/Support Zones: Evaluated over months to
highlight recurring patterns (WTB/WTT over "N months").

—--------------------------------------

Key Indicators and Their Interpretations


● Open Interest (OI):
○ High Call OI: Indicates potential resistance at a strike price. Traders
might sell calls here expecting the price not to rise above this level.
○ High Put OI: Indicates potential support, where traders expect the
price to hold or bounce upward.
● Price Resistance and Support:
○ Resistance (High Call OI): Seen as zones where prices tend to
reverse downward due to seller dominance.
○ Support (High Put OI): Price levels where buyers dominate,
preventing further drops.
● IV and Delta:
○ IV: Reflects the market's expectation of future volatility. A spike
near resistance/support can signify strong options activity.
○ Delta: Indicates directional bias. A delta close to zero suggests a
neutral outlook (suitable for strategies like straddles or strangles).
● Put-Call Ratio (PCR):
○ Changes in PCR OI highlight shifts in sentiment. High PCR
indicates bearishness, while a low PCR signals bullishness.
● Volume and OI Change:
○ Increased OI with high volume suggests fresh position buildup,
aligning with the resistance/support concept.

● Strong Resistance at WTB (High Call OI, Weak Volume): Suggests


positions were initiated at these levels expecting price stagnation or
reversal.

● Strong Support at WTB (High Put OI, Weak Volume): Indicates


confidence in price stability at this level.

● IV & Delta (e.g., IV: 2.05 / Delta: 0.07): Delta near neutral shows
potential use of straddles/strangles or hedging strategies like iron
condors for limited movement.

References:
https://unofficed.com/courses/options-chain/lessons/theory-of-open-interest/

https://unofficed.com/courses/options-chain/lessons/the-16-types-of-options-trading/

https://unofficed.com/courses/options-chain/lessons/how-to-see-the-option-chain/topic/different-tools-
for-options-chain/

https://unofficed.com/courses/max-pain-theory/

You might also like