Author: Raul Pefaur

Rotating Inversely Correlated Assets – NIFTY and USDINR

Over the last 15 years the economy of India has boomed and it has been reflected in the NIFTY index. The NIFTY has grown 7x since 1998 as the country has grown its exports. According to the UN the one of the primary exports of India are high value services which contributes 30% to their GDP.

We developed a hypothesis that as the strength of the NIFTY grew, the strength of the currency would follow as it is a primarily export economy. As the INR strengthens the ratio to USD falls making it an almost ideally inversely correlated asset.

We first tested this hypothesis treating the USDINR FX pair as a hedge against the NIFTY, but found there were periods where they were positively correlated and the hedge did not work.

Pivoting slightly we experimented with rotating the holdings of the portfolio to focus on the peak performing asset. We used a fixed rolling window to determine the peak performance and then swapped our holdings to focus on that asset.

We used the QuantConnect LEAN 2.0 backtesting engine which allowed us to import financial data from any source to run our analysis. The backtests were conducted over a 16 year period and were completed in 5-10 seconds. We saw phenomenal performance due to the strongly trending nature of the NIFTY and USDINR, achieving a Sharpe Ratio achieving 1.3 vs the NIFTY 0.7, and 42x returns vs 7x of the NIFTY.

To test the resilience of the strategy we experimented with the rolling window period to determine if this was critical to the success of the strategy. We used a rotating window from 3 days up to a 30 day window to optimize the variable for the best performance:

The resulting Sharpe Ratio is fairly robust regardless of the precise value of the rotating window period.

We believe there are many potential future improvements to the strategy to be explored; such as using a dynamically determined rolling window to avoid curve fitting. You could also experiment with different portfolios of inversely correlated assets to pick the best basket of assets.

Harnessing the Twitter API for Sentiment Strategies

In this project we will be writing an application which downloads tweets from Twitter. We are continuing our journey leaning C#, as we started with our Yahoo Finance data downloader.

Twitter has a REST API that allows us to  search for tweets, users, timelines, or even post new messages. We will use an incredible C# Twitter Library called Tweetinvi. It has everything you need to start building your own program. There are other alternatives, but we found this was the easiest and most complete. To use this program, you need to have a Twitter developer account, and use your own credentials.

Continue reading

Downloading Yahoo Finance Data with C#

The following post is the first in a series by Raul Pefaur on Learning C#. Over the last month Raul has taught himself C# with a variety of projects, tutorials and books which he will describe to help others on their journey to using C# for finance. Raul has a Master of Finance and lives in Santiago, Chile.

Yahoo has a popular API which lets you download daily financial data from its enormous library. In this blog post, I will be using this API to download financial data through a C# console application. It was created in Visual Studio and is free for you to download an use, though I recommend you try to build it yourself. If you like, use mine as a reference (I know there’s a lot of improvements in my code you could make. If you do, please share!). Continue reading

© 2017 QuantConnect Blog

Democratizing algorithmic investments Up ↑