0% found this document useful (0 votes)
43 views1 page

Python Assignment

The document provides instructions for pre-processing future and option data from a csv file. For futures data, it describes steps to filter for BANKNIFTY futures, combine date and time into a datetime column, and remove unnecessary columns before sorting by datetime. For options data, it describes extracting the expiry date and strike from the ticker, calculating days to expiry, filtering by a minimum dte, and removing extra columns before sorting.

Uploaded by

kakashi hatake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views1 page

Python Assignment

The document provides instructions for pre-processing future and option data from a csv file. For futures data, it describes steps to filter for BANKNIFTY futures, combine date and time into a datetime column, and remove unnecessary columns before sorting by datetime. For options data, it describes extracting the expiry date and strike from the ticker, calculating days to expiry, filtering by a minimum dte, and removing extra columns before sorting.

Uploaded by

kakashi hatake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment 1: Simple Data Pre-processing.

Create BANKNIFTY future and option data from


given csv file:
Steps for preparing Future data:

1. Filter BANKNIFTY-I.NFO from Ticker column.


2. Convert Date and Time into a new datetime column.
3. Remove columns: Ticker, Date, Time, Volume, Open Interest.
4. Sort data by datetime.

Output: Your output seems to appear like this.

Steps for preparing Option data:

1. Filter BANKNIFTYxxxxxxxxxxCE.NFO & BANKNIFTYxxxxxxxxxxPE.NFO from ticker column.


Now, Ticker column have value like:
BANKNIFTY03FEB2235000PE.NFO
BANKNIFTY03FEB2235500CE.NFO
BANKNIFTY03FEB2235500CE.NFO
BANKNIFTY03FEB2235500CE.NFO
BANKNIFTY03FEB2235500CE.NFO
BANKNIFTY03FEB2235000PE.NFO => BANKNIFTY | 03FEB22 | 35000PE | .NFO
Extract scrip (35000PE) from ticker and create separate column named scrip.
Extract expiry date (03FEB22) form ticker and create separate column named expiry.
2. Convert Date and Time into a new datetime column.
3. Calculate dte = expiry - Date
4. Filter data by minimum dte value.
5. Remove columns: Ticker, Date, Time, Volume, Open Interest.
6. Sort data by datetime.

Output: Your output seems to appear like this.

You might also like