Au.Tra.Sy blog – Automated Trading System

Systematic Trading research and development, with a flavour of Trend Following

Au.Tra.Sy blog – Automated trading System header image 2

Unfair Advantage API Code (C#): Extract Futures Continuous data

October 4th, 2009 · No Comments · Backtest, Code, Data, Futures, Software

As mentioned in the previous post on retrieving Back-Adjusted Contracts using the RetrieveBackAdjustedContract2 function of the Unfair Advantage API, I have coded up this very simple project to read a list of Futures underlying instruments, retrieve a proportionally back-adjusted contract for each of the instruments and oputput it to a file.

Getting started with the API

Fire up your favourite IDE/language that supports COM Interoperability (I am using Visual C# 2008 Express Edition), start Console Application project and add a reference to the Unfair Advantage API. For this you just need to “Add reference” and browse to the Unfair Advantage installation folder and select the main EXE (uad.exe). This gives access to the CSI UA API.

Add UA into your project and "Bob's your Uncle!"

Add UA into your project and "Bob's your Uncle!"

Simple extraction code

The rest is fairly simple as long as you understand the RetrieveBackAdjustedContract2 parameters.
The code below takes 2 parameters: an input file name containing the list of markets to extract and a folder name to extract each continuous contract to. It sets specific UA session parameters and calls the RetrieveBackAdjustedContract2 with specific variables to obtain the concatenation desired. Each continuous contract is output to a folder in a .txt file.
The file containing the list of markets is of the following format (CSI number, Symbol, Market name):

8,CT,Cotton

The code

Please find the code there (very nicely formatted thanks to this great tool by manoli). You can also download the Program.cs file:
Program.cs



Get posts by RSS
Bookmark and Share
Related Posts with Thumbnails


Like this post? You may want to read these:

Tags: ······

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment