Blog Archives

Plotting Tick Data with ggplot2

January 20, 2013
By

Here are some examples of using ggplot2 and kdb+ together to produce some simple graphs of data stored in kdb+. I am using the qserver extension for R (http://code.kx.com/wsvn/code/cookbook_code/r/) to connect to a running kdb+ instance from within R. First, … Continue reading →

Read more »

Rmathlib and kdb+ part 3: Utility Functions

January 11, 2013
By

In the first two parts of this series, I looked at the basics of the interface I created between rmathlib and kdb+. In this post, I’ll go through some of the convenience functions I wrote to emulate some basic R … Continue reading →

Read more »

Rmathlib and kdb+, part 2 – Probability Distribution Functions

January 10, 2013
By

Following on from the last post on integrating some rmathlib functionality with kdb+, here is a sample walkthrough of how some of the functionality can be used, including some of the R-style wrappers I wrote to emulate some of the … Continue reading →

Read more »

Integrating Rmathlib and kdb+

January 8, 2013
By

The R engine is usable in a variety of ways – one of the lesser-known features is that it provides a standalone math library that can be linked to from an external application. This library provides some nice functionality such … Continue reading →

Read more »

Exporting Data From R to KDB

December 12, 2012
By

Here is the beginnings of a simple routine to convert R data frames to Q format (in this case a dictionary). It uses the S3 dispatch mechanism to handle the conversion of different data types. Extremely basic (I havent even … Continue reading →

Read more »

Density Estimation of High-Frequency Financial Data

Frequently we will want to estimate the empirical probability density function of real-world data and compare it to the theoretical density from one or more probability distributions. The following example shows the empirical and theoretical normal density for EUR/USD high-frequency … Continue reading →

Read more »

Binomial Pricing Trees in R

Binomial Tree Simulation The binomial model is a discrete grid generation method from \(t=0\) to \(T\). At each point in time (\(t+\Delta t\)) we can move up with probability \(p\) and down with probability \((1-p)\). As the probability of an … Continue reading →

Read more »

Quasi-Random Number Generation in R

Random number generation is a core topic in numerical computer science. There are many efficient algorithms for generating random (strictly speaking, pseudo-random) variates from different probability distributions. The figure below shows a sampling of 1000 two-dimensional random variates from the … Continue reading →

Read more »

The Euler Method In R

April 11, 2012
By

The Euler Method is a very simple method used for numerical solution of initial-value problems. Although there are much better methods in practise, it is a nice intuitive mechanism. The objective is to find a solution to the equation $$ … Continue reading →

Read more »

Newton’s Method In R

Here is a toy example of implementing Newton’s method in R. I found some old code that I had written a few years ago when illustrating the difference between convergence properties of various root-finding algorithms, and this example shows a … Continue reading →

Read more »