Comments (7)
I could mess with this potentially. Where were you wanting this to go? Do you want visualization?
from rustquant.
Visualisation is not very high on the list, but could possibly make a new macro to plot a surface, e.g. plot_matrix!
(similar to the current plot_vector!
). Definitely would be a nice sanity check, and not too difficult.
The idea is that we need fairly generic Curve
and Surface
types that can represent things like yield curves, volatility surfaces, and such. These would mainly be used for pricing instruments like bonds and options.
Edit: I've come back to this issue many times and have yet to be able to settle on an implementation. For example, for the Surface
type, deciding whether to use a BTreeMap<f64, Curve>
or use something like polars::DataFrame
, ndarray::Array
, or nalgebra::Matrix
.
They each have their pros and cons. For example, obviously ndarray
or nalgebra
are better choices if we need to perform any array operations/algebra, but they don't have named dimensions which polars
or a BTreeMap
would give us.
Any thoughts ?
from rustquant.
Typical way to store curves or surfaces is to store a mesh and a function or the function values if you have a function defined on the surface. A question would be how general do you want these meshes? For instance, do you want polygonal meshes?
If I had to guess, most of the curves/surfaces would start as graphs of functions, e.g., a curve of the form (x,f(x))
or a surface of the form (x,y,f(x,y))
. Do you want to store implicit surfaces? E.g., (x,y,z) : f(x,y,z)==0
?
My gut tells me that using ndarray
or polars
would be the choice here. With ndarray
you may want to build additional structure to store some kind of metadata as you suggest.
from rustquant.
The function may be unknown, and the curve may simply be some market data, such as the US yield curve:
Date | 1 Mo | 2 Mo | 3 Mo | 4 Mo | 6 Mo | 1 Yr | 2 Yr | 3 Yr | 5 Yr | 7 Yr | 10 Yr | 20 Yr | 30 Yr |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
02/01/2024 | 5.49 | 5.51 | 5.42 | 5.38 | 5.15 | 4.68 | 4.20 | 3.96 | 3.80 | 3.83 | 3.87 | 4.21 | 4.10 |
In this case, we would then have the inverse problem of calibrating some function to the data, such as the Nelson-Siegel-Svensson model, which we could then also use to interpolate between the data (needed for bond pricing, etc).
And the key thing here is that we need the curves/surfaces to handle date-based indexing/construction, with my preference being time::Date
as it is what I've used in RQ so far.
ndarray
has the benefit of nice array ops, while polars
would make data IO super nice.
Which would you consider a better choice ?
from rustquant.
Maybe polars is safe to go with given it can do a lot of nice formatting/etc. However, and not to just go back and forth, but it wouldn't be too hard to go from ndarray to polars and vice versa if need be.
from rustquant.
If we can ensure that we can fit various models to the data and interpolation works, then polars would be awesome
from rustquant.
I realised Polars has a to_ndarray()
method for both their Series
and DataFrame
types, so that makes life easier.
from rustquant.
Related Issues (20)
- Add more calendars. HOT 7
- Implement Interest Rate Swap pricer. HOT 2
- feat(stochastics): Have time-varying parameters for processes HOT 5
- Use Release-Plz for automatic releases. HOT 6
- Add CEV process
- Implied volatility calculation HOT 4
- feat: Portfolio to have a get_weights() function or something similar HOT 1
- has some tutorial
- Can we support built-in "factor analysis"? HOT 3
- Deprecate `calendars` sub-module and move to `calenda-rs` crate.
- Replace `OffsetDateTime` with `Date`.
- Roadmap to `v1`
- Implement a `Curve` type. HOT 7
- doc.rs failed to build HOT 1
- decision tree algorithm for machine learning HOT 4
- Generalized Black-Scholes (GBS) model in Rust. HOT 2
- Inconsistency between code and documentation HOT 1
- CI/CD: GitHub Action `cargo_test` runs out of space on device.
- x86_64-pc-windows-gnu vs x86_64-pc-windows-msvc HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rustquant.