Back

Algo to trade forex on economic data releases

Is it possible to create an algo which reads a webpage (http://www.investing.com/economic-calendar/) and extracts a data release and places a trade on a logic formula preset into the algo.

The issues are:

1. reading the data instantly it is released - somehow reading the webpage continuously to do this. Of course this would only need to be done for seconds around the release time

2. having a template to accomodate logic which could be used for each release. Basically I would mentally enter a pip value for a range of possible values of the data release and the algo would enter a buy/sell limit or market order based on where price traded immediately prior to the release and my pip value entered pre-release.

Investing.com and other calendars are quick enough to do what I want. I do not need a Bloomberg, even if i could afford it.

I am a forex trader and in no way a coder. Your thoughts would be very welcome.

Update Backtest








Welcome Paul; this is already supported via the DailyFX class using FXCM's economic calendar. It is a very similar source to the one you linked above but that has a RSS feed. We've already written the basic algorithm for you. You can see it here.

/// <summary>
/// Daily Fx demonstration to call on and use the FXCM Calendar API
/// </summary>
public class DailyFxAlgorithm : QCAlgorithm
{
/// <summary>
/// Add the Daily FX type to our algorithm and use its events.
/// </summary>
public override void Initialize()
{
SetStartDate(2016, 05, 26); //Set Start Date
SetEndDate(2016, 05, 27); //Set End Date
SetCash(100000); //Set Strategy Cash
AddData<DailyFx>("DFX", Resolution.Second, DateTimeZone.Utc);
}

private int _sliceCount = 0;
public override void OnData(Slice slice)
{
var result = slice.Get<DailyFx>();
Console.WriteLine("SLICE >> {0} : {1}", _sliceCount++, result);
}

/// <summary>
/// Trigger an event on a complete calendar event which has an actual value.
/// </summary>
private int _eventCount = 0;
private Dictionary<string, DailyFx> _uniqueConfirmation = new Dictionary<string, DailyFx>();
public void OnData(DailyFx calendar)
{
_uniqueConfirmation.Add(calendar.ToString(), calendar);
Console.WriteLine("ONDATA >> {0}: {1}", _eventCount++, calendar);
}
}

 

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


That is more than I expected but I am a little lost how to use this.

I am guessing this code retrieves the events and data release number.

I then need to add a security and logic around when to trade.

With the code you've given me, how do I identify the event I want to trade?

Would you mind explaining exactly what the code does so I can then work out what I need to do next.

Has anyone used the code above in an example I can look at?

Many thanks. 

0

Hi PaulCookson,

Here is the reference for the DailyFx Class.

I attached an example too. In this pretty raw algorithm, it trades EURUSD based on the meaning (better or worse than expected) of an high importance event. I hope that can be a starting point for your algorithm. 

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Is DailyFX calendar used simply as they have an API or is it that using an API is the fastest method to read web based data?

I ask as the DailyFX calendar is slow to update on their website.

 

0

Hi PaulCookson,

If you add DailyFX data with a second resolution, it will poll new data every second. 

AddData<DailyFx>("DFX", Resolution.Second, DateTimeZone.Utc);

You could test DailyFX in a paper trading account and evaluate its speed (how well you enter a position). If it is too slow, we could look into how to import custom data from investing.com.

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Alexandre Catarino 

Can you expand on the DailyFX Class? I opened the link you have on an earlier message, but I don't believe it's what I'm looking for. (GetHashCode Method (MarketOrderTransaction)?)

I want to know what I can do besides FxDailyImportance and FxDailyMeaning. More specifically I want to know if I can filter out events that relate to specific currencies so I'm not placing orders for every major event, just the relevant ones for my currency.

I'd also like to know how I can find these so I can look up the reference material whenever possible. I've looked in Docs and haven't found anything the FXCM calendar. (Does Oanda have one?)

Also, is there a way to find the base Symbol and quote Symbol for forex pairs? I've seen it done with crypto, but I can't seem to get it to work with Forex.

Lastly, thank you for all of your help in the community. During my research over the past few weeks on QuantConnect, I see you have contributed a lot. Just wanted you to know your work is being appreciated, even by the lurkers ;-)


 
0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed