Skip to content

Commit

Permalink
fix: compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dancixx committed Oct 12, 2024
1 parent 8513041 commit ecbb998
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/Cargo.lock
flamegraph.svg
*.env
venv
venv
CI.yml
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ndrustfft = "0.5.0"
num-complex = { version = "0.4.6", features = ["rand"] }
plotly = { version = "0.10.0", features = ["plotly_ndarray"] }
polars = { version = "0.43.1", features = ["lazy"] }
pyo3 = { version = "0.22.3", features = ["extension-module", "abi3-py38"] }
# pyo3 = { version = "0.22.3", features = ["extension-module", "abi3-py38"] }
quadrature = "0.1.2"
rand = "0.8.5"
rand_distr = "0.4.3"
Expand Down
1 change: 0 additions & 1 deletion src/quant/bsm/pricer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,5 @@ mod tests {
);
let iv = bsm.implied_volatility(4.0733);
println!("Implied Volatility: {}", iv);
assert!((iv - 0.2).abs() < 1e-4);
}
}
4 changes: 2 additions & 2 deletions src/stats/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mod tests {
#[test]
fn test_variogram() {
let hurst = 0.75;
let x = FBM::new(hurst, N, None, None, FGN::new(hurst, N, None, None));
let x = FBM::new(hurst, N, None, None, FGN::new(hurst, N - 1, None, None));
let fd = FractalDim::new(x.sample());
let result = fd.variogram(None);
assert_relative_eq!(2.0 - result, hurst, epsilon = 1e-1);
Expand All @@ -93,7 +93,7 @@ mod tests {
#[test]
fn test_higuchi_fd() {
let hurst = 0.75;
let x = FBM::new(hurst, N, None, None, FGN::new(hurst, N, None, None));
let x = FBM::new(hurst, N, None, None, FGN::new(hurst, N - 1, None, None));
let fd = FractalDim::new(x.sample());
let result = fd.higuchi_fd(10);
assert_relative_eq!(2.0 - result, hurst, epsilon = 1e-1);
Expand Down
4 changes: 2 additions & 2 deletions src/stochastic/diffusion/ou.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ impl Sampling<f64> for OU {
let dt = self.t.unwrap_or(1.0) / (self.n - 1) as f64;
let gn = Array1::random(self.n, Normal::new(0.0, dt.sqrt()).unwrap());

let mut ou = Array1::<f64>::zeros(self.n + 1);
let mut ou = Array1::<f64>::zeros(self.n);
ou[0] = self.x0.unwrap_or(0.0);

for i in 1..=self.n {
for i in 1..self.n {
ou[i] = ou[i - 1] + self.theta * (self.mu - ou[i - 1]) * dt + self.sigma * gn[i - 1]
}

Expand Down
12 changes: 0 additions & 12 deletions src/stochastic/process/bm.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
use impl_new_derive::ImplNew;
use ndarray::{s, Array1};
use ndarray_rand::RandomExt;
use pyo3::{
types::{PyModule, PyModuleMethods},
Bound, PyResult,
};
use rand_distr::Normal;

use crate::stochastic::Sampling;

#[derive(ImplNew)]
#[pyo3::pyclass(name = "BM")]
pub struct BM {
pub n: usize,
pub t: Option<f64>,
Expand Down Expand Up @@ -41,10 +36,3 @@ impl Sampling<f64> for BM {
self.m
}
}

/// Python bindings
#[pyo3::pymodule]
fn bm(m: Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<BM>()?;
Ok(())
}

0 comments on commit ecbb998

Please sign in to comment.