Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiqwerty committed Aug 10, 2023
1 parent 3c4f64f commit 8317756
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ pub fn random_walk(
let start_price = 1.0;
let mut res = vec![start_price; n_months + 1];
let expected_monthly_return = (1.0 + (expected_yearly_return / 100.0)).powf(1.0 / 12.0);
// let mut mu_base = 1.0 + expected_yearly_return;
let mut mu = expected_monthly_return;
for (i, sigma) in (1..(n_months + 1)).zip(sigma_distribution.sample_iter(&mut sigma_rng)) {
for i in 0..9 {
Expand All @@ -214,8 +213,12 @@ pub fn random_walk(
res[i] = (res[i - 1] * rv).max(1e-1);

if !is_return_indpendent && sigma - sigma_mean > 0.0 {
let actual_total_return: f64 = (1..=i).map(|j| res[j] / res[j - 1]).product::<f64>().powf(1.0/(n_months-i) as f64);
let expected_total_return = expected_monthly_return.powf(n_months as f64 / (n_months-i) as f64);
let actual_total_return: f64 = (1..=i)
.map(|j| res[j] / res[j - 1])
.product::<f64>()
.powf(1.0 / (n_months - i) as f64);
let expected_total_return =
expected_monthly_return.powf(n_months as f64 / (n_months - i) as f64);
mu = expected_total_return / actual_total_return;
}
}
Expand Down

0 comments on commit 8317756

Please sign in to comment.