In our previous post on Nelson-Siegel model we have shown some pitfalls of it. In this follow-up we will discuss how to circumvent them and how machine learning and artificial intelligence can[not] help. Continue reading "Pitfalls of Nelson-Siegel Yield Curve Modeling – Part II – what ML and AI can[not] do"
The Nelson-Siegel-[Svensson] Model is a common approach to fit a yield curve. Its popularity might be explained with economic interpretability of its parameters but most likely it is because the European Central Bank uses it. However, what may do for ECB will not necessarily work in all cases: the model parameters are sometimes extremely unstable and fail to converge. Continue reading "Pitfalls of Nelson-Siegel Yield Curve Modeling – Part I"
We test different kinds of neural network (vanilla feedforward, convolutional-1D and LSTM) to distinguish samples, which are generated from two different time series models. Contrary to a (naive) expectation, conv1D does much better job than the LSTM. Continue reading "Classifying Time Series with Keras in R : A Step-by-Step Example"
Support and resistance levels are quite popular among traders. Although they are implemented in many apps and services, an open source implementation of the algorithm is hardly available. We try to close the gap.
Continue reading "R code to detect support and resistance levels"
A very important question, which every trader or investor encounters is how many trades to commit or how many stocks to hold in portfolio. Whereas the law of the large numbers readily gives a [naive] answer "the more the better", in practice the answer is often better less but better. Continue reading "Optimal Number of Trades: better less but better"
Even if you are not a Forex trader, it is often necessarily to get currency exchange rates, e.g. if you trade [the options on] foreign stocks. Fixer.io provides daily FX-rates from European Central Bank for 31 currencies via JSON API. We present a script to get data in R.
Continue reading "R-script for Fixer.io – get FX rates in R for 31 currencies"
Remarkably, many market players in energy market still cannot calculate the fair value of a gas storage. In particular, many of them rely on perfect foresight. We put online a simple but correct model from QuantLib. Confidence intervals are estimated as well.
NB! This time not for retail investors but for the colleagues from energy industry. Have a look at short introductory video.
Gas Storage is a relatively complex option to evaluate, esp. if there are non-trivial constraints. Remarkably, many energy companies cannot correctly evaluate even the simplest storage contracts. Moreover, they often resort to a so-called perfect foresight: the price paths are considered random but once the price path is known, it is assumed to be known completely (like at the left-hand sketch).
|Prefect foresight (unrealistic)||One-step foresight (realistic)|
Some of QuantLib functionality is ported to R in RQuantLib. In particular the pricing of Barrier options. Unfortunately, only European. But we need American in order to price and simulate future scenarios for the so-called KO-Zertifikate (Knock-Out Warrants), which are quite popular among German retail traders. We show how to quickly adopt the code from QuantLib testsuite, compile it under Linux and integrate with R and web.
Continue reading "Integrating QuantLib with R and Web – Barrier Options Pricer"
Our simulator allows you to simulate 100 future scenarios of your portfolios, estimate the expected risk, return and correlations, helping you to improve the diversification of your portfolios. The simulator projects the historical returns in future and is completely model-free (in particular, we don't make an unrealistic assumption of Normally-distributed returns). Though the past doesn't capture all possible future scenarios, it provides a good idea of possible outcomes.
Continue reading "Portfolio Simulator – estimate the expected risk and return of your investments"
We continue developing letYourMoneyGrow.com and soon will make the first tool from the promised portfolio optimization toolset publicly available. And so far a small technical report. We implement the core business logic in R and wrap-up it with PHP. Calling Rscript from PHP via exec("Rscript ...") seems to be easy ... as far as you don't use any libraries. And if you do, you will get an error message like Error in library(RMySQL) : there is no package called 'RMySQL'. Fortunately, there is a solution. However, note that a loaded package may depend on other packages. For instance, RMySQL depends on DBI. Thus you should explicitly resolve this dependency in your R-code like this:
library(DBI, lib.loc = c("/home/<yourUsername>/R/x86_64-pc-linux-gnu-library/<yourRVersion>", "/usr/local/lib/R/site-library", "/usr/lib/R/library")) library(RMySQL, lib.loc = c("/home/<yourUsername>/R/x86_64-pc-linux-gnu-library/<yourRVersion>", "/usr/local/lib/R/site-library", "/usr/lib/R/library"))