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

Optionals or peripherals functions

Description of the functions as they was created and defined

sstock()

Summary

It returns a data.frame containing the following variables:

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)
stock_tick <- sstock()
ggplot2::ggplot(stock_tick, 
                ggplot2::aes(time_periods, stock_price_path)) +
  ggplot2::geom_point()

sstock\ito()

Summary

It returns a data.frame containing the following variables:

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)
ggplot2::ggplot(stock_tick, 
                ggplot2::aes(time_periods, stock_price_path)) +
    ggplot2::geom_point(color = 'pink') +
        ggplot2::geom_line(data = stock_tick_ito,
                           ggplot2::aes(time_periods, stock_price_path),
                           color = 'steelblue')

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)

```{R echo=FALSE} ggplot2::ggplot(S, ggplot2::aes(time_periods, stock_price_path)) + ggplot2::geom_point()

```{R echo=FALSE}
ggplot2::ggplot(C, ggplot2::aes(time_periods, option_price_path)) +
  ggplot2::geom_point()


AnthonyTedde/StockPriceSimulator documentation built on May 17, 2019, 5:39 p.m.