## Recent Posts

4 stars based on 69 reviews

The cheat sheet can be downloaded from RStudio cheat sheets repository. Any comments comments welcome! Feel free to have a look, the first chapter is free! This is why visualization is the most used and powerful way to get a better understanding of your data. After this course you will have a very good overview of R time series visualization capabilities and you will be able to better decide which model to choose for quantitative trading strategies in r part 1 of 3 analysis.

You will be able to also convey the message you want to deliver in an efficient and beautiful way. Univariate Time Series Univariate plots are designed to learn as much as possible about the distribution, central tendency and spread of the data at hand.

In this chapter you will be presented with some visual tools used to diagnose univariate times series.

Multivariate Time Series What to do if you have to deal with multivariate time series? In this chapter, you will learn how to identify patterns in the distribution, central tendency and spread over pairs or groups of data. Imagine you already own a portfolio of stocks and you have some spare cash to invest, how can you wisely select a new stock to invest your additional cash?

Analyzing the statistical properties of individual stocks vs. It is a well known and recognized data feed provider geared toward retail users and small institutions. Stanislav Kovalevsky has developed a package called QuantTools.

The feature that interests me the most is the ability to link IQFeed to R. More information can be found here. QuantTools offers four main functionalities: First make sure that IQfeed is quantitative trading strategies in r part 1 of 3.

You can either download daily or intraday data. Note the period parameter. It can take any of the following values: QuantTools makes the process of managing and storing tick market data easy.

You just setup storage parameters and you are ready to go. The parameters are where, since what date and which symbols you would like to be stored. Any quantitative trading strategies in r part 1 of 3 you can add more symbols and if they are not present in a storage, QuantTools tries to get the data from specified start date. The code below will save the data in the following directory: There is one sub folder by instrument and the data is aved in.

You can also store data between specific dates. In the example below, I first retrieve the data stored above, then select the first price observations and finally draw the chart. Two things to notice: You can refer to the Examples section on QuantTools website. Overall I find the package extremely useful and well documented. The only missing bit is the live feed between R and IQFeed which will make the package a real end to end solution. A few months ago a reader point me out this new way of connecting R and Excel.

At the time of writing the current version of BERT is 1. Ultimately I have a single Excel file gathering all the necessary tasks to manage my portfolio: In the next sections I present the prerequisite to developed such an approach and a step by step guide that explains how BERT could be used for simply passing data from R to Excel with minimal VBA code. Once the installation has completed you should have a new Add-Ins menu in Excel with the buttons as shown below.

This is what we want to retrieve in Excel. Save this in a file called myRCode. R any other name is fine in a directory of your choice. In this file paste the following code. Then save and close the file functions. Create and save a file called myFile.

This is a macro-enabled file that you save in the directory of your choice. Once the file is saved close it. Once the file is open, paste the below code. You should see something like this. Paste the code below in the newly created module. You should see something like the below appearing. From my perspective the interest of such an approach is the ability to glue together R and Excel obviously but also to include via XML and batch pieces of code from Python, SQL and more.

This is exactly what I needed. Making the most of the out of sample data August 19,9: Then a comparison of the in and out of sample data help to decide whether the model is robust enough.

This post aims at going a step further and provides a statistical method to decide whether the out of sample data is in line with what was created in sample. There is a non-parametric statistical test that does exactly this: Using the Kruskal-Wallis Testwe can decide whether the population distributions are identical without assuming them to follow the normal distribution.

It exists other tests of the same nature that could fit into that framework. Then I tested each in sample subset against the out of sample data and I recorded the p-values. This process creates not a single p-value for the Kruskall-Wallis test but a distribution making the analysis more robust.

As usual what is presented in this post is a toy example that only scratches the surface of the problem and should be tailored to individual needs.

As usual with quantitative trading strategies in r part 1 of 3 things just a kind reminder: This is a very first version of the project so do not expect perfection but hopefully it will get better over time. Please report any comment, suggestion, bug etcâ€¦ to: Doing quantitative research implies a lot of data crunching and one needs clean and reliable data to achieve this. What is really needed is quantitative trading strategies in r part 1 of 3 data that is easily accessible even without an internet connection.

The most efficient way to do this for me has been to maintain a set of csv files. I have one csv file per instrument and each file is named after the instrument it contains. The reason I do so is twofold: Simple quantitative trading strategies in r part 1 of 3 very efficient so far. The process is summarized in the chart below. In everything that follows, I assume that data is coming from Yahoo.

The code will have to be amended for data from Google, Quandl etcâ€¦ In addition I present the process of updating daily price data. The code below is placed on a. Note that I added an output file updateLog. The process above is extremely simple because it only describes how to update daily price data.

The Asset Management industry is on the verge of a major change. Over the last couple of years Robots Advisors RA have emerged as new players. The term itself is hard to define as it encompasses a large variety of services. I found the Wikipedia definition pretty good. Quantitative trading strategies in r part 1 of 3 this post R is just an excuse to present nicely what is a major trend in the asset management industry.

Those figures are a bit dated given how fast this industry evolves but are still very informative. It is starting to significantly affect the way traditional asset managers are doing business. Despite all the above, I think the real change is ahead of us. Ultimately it will affect the way traditional investment firms do business. Active portfolio management quantitative trading strategies in r part 1 of 3 is having a tough time for some years now will suffer even more.

Another potential impact is the rise of ETFs and low commission financial products in general. Obviously this has started a while ago but I do think the effect will be even more pronounced in the coming years. This trend will get stronger inevitably.

Some of the functions presented here are incredibly powerful but unfortunately buried in the documentation hence my desire to create a dedicated post. I only address daily or lower frequency times series.

The example below loads the package and creates quantitative trading strategies in r part 1 of 3 daily time series of days normaly distributed returns. The join argument does the magic!

Apply a specified function to each distinct period in a given time series object. Extract index values of a given xts object corresponding to the last observations given a period specified by on.

Generic function for replacing each NA with the most recent non-NA prior to it. For a set of returns, create a wealth index chart, bars for per-period performance, and underwater chart for drawdown.

This is incredibly useful as it displays on a single window all the relevant information for a quick visual inspection of a trading strategy. The list above is by no means exhaustive but once you master the functions describe in this post it makes the manipulation of financial time series a lot easier, the code shorter and the readability of the code better.