neuralhedge.data package
Submodules
neuralhedge.data.base module
- class neuralhedge.data.base.HedgerDataset(prices: Tensor, info: Tensor, payoff: Tensor)
Bases:
DatasetDataset contains data for hedging
- Parameters:
prices (
torch.Tensor)information (
torch.Tensor)payoff (
torch.Tensor)
- Shape:
prices: (n_samples, n_steps+1, n_assets)
information: (n_samples, >= n_steps , n_features)
payoff: (n_sample,)
- data
(prices, information, payoff)
- Type:
tuple
- class neuralhedge.data.base.ManagerDataset(prices: Tensor, info: Tensor)
Bases:
DatasetDataset contains data for management
- Parameters:
prices (
torch.Tensor)information (
torch.Tensor)
- Shape:
prices: (n_samples, n_steps+1, n_assets)
information: (n_samples, >= n_steps , n_features)
- data
(prices, information)
- Type:
tuple
neuralhedge.data.market module
- class neuralhedge.data.market.BS_Market(n_sample=10000, n_timestep=30, dt=0.03333333333333333, mu=0.1, sigma=0.2, r=0.0, init_price=100.0)
Bases:
objectData of BS stock + Bond + European call option
- Parameters:
n_sample – number of samples
n_timestep – number of timestep
dt – \(dt\)
mu – drift
sigma – volatility
r – risk-free rate
init_price – initial prices
- contigent
- bs_pricer
- bs_delta
- bs_price
theoretical Black-Scholes price
- Type:
float
For portfolio management, the option part e.g. payoff is redundant.
- get_hedge_ds()
Get dataset for hedging
- Returns:
hedge_ds (
neuralhedge.nn.HedgerDataset)
- get_manage_ds()
Get dataset for managing
- Returns:
manage_ds (
neuralhedge.nn.ManagerDataset)
- get_price_delta()
Get dataset for managing
- Returns:
bs_price, bs_delta (
float,BlackScholesDelta)
neuralhedge.data.stochastic module
- class neuralhedge.data.stochastic.BlackScholes(n_sample, n_timestep, dt, mu, sigma)
Bases:
objectA class with BlackScholes parameters to generate BlackScholes prices
- get_prices() Tensor
- Return type:
self.prices (
torch.Tensor)
- Shapes:
self.prices: (n_sample, n_timestep+1,1)
- neuralhedge.data.stochastic.simulate_BM(n_sample, dt, n_timestep) Tensor
- Return type:
BM_paths (
torch.Tensor)
- Shapes:
BM_paths: (n_sample, n_timestep+1,1)
- neuralhedge.data.stochastic.simulate_BS(n_sample, dt, n_timestep, mu, sigma) Tensor
- Return type:
BS_paths (
torch.Tensor)
- Shapes:
BS_paths: (n_sample, n_timestep+1,1)
- neuralhedge.data.stochastic.simulate_time(n_sample, dt, n_timestep, reverse=False) Tensor
- Return type:
time_paths (
torch.Tensor)
- Shapes:
time_paths: (n_sample, n_timestep+1,1)