---
# System prepended metadata

title: CC junk Rookley
tags: [research]

---

---
title: CC junk Rookley
tags: research
---


# Rookley's method summarized by Ning


:::info
This document summarizes feedback from Ning and my questions after running his codes. 
:::



## Python scripts by Franziska Wehrmann


1. The file with the name "risk_neutral_density.py" defines a function that returns the calculated result of a State-Price Density (SPD). 
2. The file with the name "smoothing.py", using the data set to be inputted, defines in the end a function that returns the estimated values of inputs that are needed in the function defined in "risk_neutral_density.py". 
3. The file with the name "plotting.py" returns to 
    1. scatterplots of data for all possibilities of tau_day (dates to maturity) given the fixed date; 
    2. calculated SPDs  for all possibilities of tau_day given the fixed date; 
    3. volatility smile + 1st derivative of implied volatiloty + 2nd derivative of implied volatility for all possibilities of tau_day (dates to maturity) given the fixed date; (:question: green for implied volatility $\sigma$, blue, and green? )
    4. For each possibility of tau_day, the scatterplot +implied volatility together with its 1st and 2nd derivatives plots+ the calculated SPD.
4. The file with the name "CrypOpt_RiskNeutralDensity.py" is the main body of the codes. One uses this part to input the data set of a fixed date and gets a output called "res" that contains the following values:
    - 'df': the data columns of ['M', 'iv', 'S', 'K'] (moneyness, implied volatility, underlying price, strike price) for all possibilities of tau_day given the fixed date
    - 'M': moneyness (underlying prices divided by strike prices)
    - 'smile': implied volatility 
    - 'first': first derivative of implied volatility
    - 'second': second derivative of implied volatility
    - 'K': strike prices
    - 'q': (local polynomial kernel) SPD
    - 'S': underlying prices (corrected for future dividends)



## Input


The file "trades_clean.csv" provided by Ms. Franziska Wehrmann has the following varaibles and descriptions: 

| Index | Column | Description |
|---|----|---|
|1 | date|trading date in the format of "2020/3/4"|
|2 | P| :question: |
|3 |S| underling price|
|4 |K|strike price | 
|5 | tau| days to maturity divided by 365| 
|6 |tau_day| days to maturity in days|
|7 |iv| implied volatility |
|8 |M| Moneyness (underlying prices divdided by strike prices)|
|9 |r| risk-free rate |
|10 |option| 'P': put, 'C': call
|11 | direction| 'sell', 'buy'| 



## Output of Franziska's data

### Fig A. Smoothing the implied volatility at different times to maturity

![](https://i.imgur.com/scDLszz.png)

### Fig B. Risk-neutral probability

![](https://i.imgur.com/eB3x4p8.png)

### Fig C. Why there are three different colors of implied volatility?(:question:)

![](https://i.imgur.com/OMCShGY.png)

### Fig D. Whats are the differences between the implied volatility and that in Figs A, B, C? Why the implied volatility in orange color is negative? 


![](https://i.imgur.com/GeNia1n.png)

![](https://i.imgur.com/MdJT5pg.png)

![](https://i.imgur.com/v9saYdj.png)


## Output of the data from BRC

