StockPriceSimulator
Introduction
This package provide a way to simulate a fully random stock ticker based on theory provided by __“Stochastic Calculus For Finance ii”, Shreve“__
Functions provided by the package
Key functions
- Stock price generator for a single instance: sstock()
- Stock price generator for a single instance, using the Ito’s formula approximation sstock_ito()
- Position taken in hedging strategy: delta()
- First derivative of option pricing function with respect to time: theta()
- Second derivative of option pricing function with respect to stock price: gamma()
Optionals or peripherals functions
- Multiplier used several time: d
Description of the functions as they was created and defined
sstock()
Summary
It returns a data.frame containing the following variables:
- time_periods
- stock_price_path
Arguments
Arguments | Default | Description |
---|---|---|
time_to_maturity | 4 | Final time up to the Stock Price Path goes |
seed | 1 | It fixes initial value of the pseudo random number generation in order to get reproducible experiments. |
scale | 100 | Define the partition of the time period. |
sigma | 1 |
Example of Usage
library(StockPriceSimulator)
##
## Attaching package: 'StockPriceSimulator'
## The following object is masked from 'package:base':
##
## gamma
stock_tick <- sstock()
Summary
It returns a data.frame containing the following variables:
- time_periods
- stock_price_path
The computed path is based on approximation given by the Itô’s formula.
Arguments
Arguments | Default | Description |
---|---|---|
time_to_maturity | 4 | Final time up to the Stock Price Path goes |
seed | 1 | It fixes initial value of the pseudo random number generation in order to get reproducible experiments. |
scale | 100 | Define the partition of the time period. |
sigma | 1 | standard deviation of the stock |
alpha | 0 | Mean trend |
Example of Usage
library(StockPriceSimulator)
## Call the path generating function from equation:
stock_tick <- sstock(scale = 1000)
## Call the path generating function from Itôs approximation
stock_tick_ito <- sstock_ito(scale = 1000)
delta()
Delta return the position one should take in order to hedge a short position in a call.
theta()
gamma()
Test Black-Scholes-Merton function
# Create a stoch price motion from 0 to 4(Year) with a daily step
S <- sstock(initial_stock_price = 50,
time_to_maturity = 4,
scale = 360)
# According to the previous sampled path, the option price is computed
# With option in the money
C <- BSM(stock_path = S)