Description

Trading financial derivatives is one of the key functions for major investment banks.

A derivative is a contract between two or more parties whose value is based on an agreed-upon underlying financial asset (like a stock price) or set of assets ( basket of stocks ).

An example is a European call option on an equity stock( called the underlier of the option ). This option gives the buyer the right (but not the obligation) to buy the underlying asset (equity stock in this case) at a fixed price (called strike) at a fixed time (called maturity/ expiry). In return, the option buyer would need to pay some price at the contract start date called the 'Option Price'. The buyer would exercise the option (i.e. buy the underlier at the strike price) only if the stock price at the expiration date is greater than the strike price.

Similarly, a European put option gives the buyer the right (but not the obligation) to sell the underlying asset (equity stock in this case) at a fixed price (called strike) at a fixed time (called maturity/ expiry). The buyer would exercise the option (i.e. buy the underlier at the strike price) only if the stock price at the expiration date is lower than the strike price.
Objective

The problem here deals with estimating the Option Price based on historical data available by employing a mathematical model. The underlier of the option is 1 unit of a publicly traded stock of a hypothetical company.
Modeling Introduction

Option Price majorly depends on following features:

- Type of the Option ( Call or Put )

- Spot value of the underlier stock

- Strike Price of the option

- Risk free rate at which market participants can borrow or lend money

- Time to expiry of the option

- Market Fear Index – A hypothetical metric ranging from 0 (calm markets) to 100 (volative markets)indicating the expected market volatility

- BuySell Ratio – A hypothetical metric ranging from 0.25 to 4 indicating the market demand for buying and selling of the option close to market price. A value of 0.25 indicates that for every Buy order, there exist 4 sell orders indicating a potential sell-off.

Training Dataset

You can download the training dataset from here

The training dataset of ~10,000 samples. Each row corresponds to one unique option. The schema of the training data set is:
Data Schema

Id: Test case unique identifier

OptionType: Call or Put

Strike: Option Strike Price($)

Spot: Spot value of underlier($)

RiskfreeRate: Interest rate(%)

MarketFearIndex: Market Fear Index(0-100)

BuySellRatio: Buy Order to Sell Order Ratio(0.25-4)

OptionPrice: Observed Option Price($)
Evaluation Criteria

Each prediction (
) will be assessed against the observed Option Price(

)for all test cases in the test data set.

Note: This problem statement has additional test cases that'll run post your submission. You final score is subject to change, your current score is not the final score

Input Format

Input will be a filename. This file will be a CSV which contains the option information and relevant market data similar to the training data downloadable above. Schema is same as training data except for the fact that option price column will be missing.

CSV will contain unique rows corresponding to different options. You will need to predict the price for all these unique options.
How to read input

#!/bin/python3


import pandas as pd
from io import StringIO

inputdata = input()
inputdata = inputdata.replace("\\n","\n")
inputdata = StringIO(inputdata)
df = pd.read_csv(inputdata)

Constraints

Estimated Option Prices should be non-negative

Output Format

Below are sample input and output
Sample Input

Id,OptionType,Strike,Spot,TimeToExpiry,RiskfreeRate,MarketFearIndex,BuySellRatio

1,Put,120,148.5581572,0.944953829,0.027206587,71.28559419,0.487120444
Sample Output

Id,OptionPrice

1,2.877918997

Sample Input 0

Id,OptionType,Strike,Spot,TimeToExpiry,RiskfreeRate,MarketFearIndex,BuySellRatio\nDummy,Call,60,148.1797401,1.243255425,3.1980597,6.436489684,1.068700429

Sample Output 0

Id,OptionPrice
Dummy,1