Back

FX Macro Economic Sentiment Algorithm

Hi there guys!

Here is a pretty simple but promising algorithm.

It has two modules, the alpha generator that makes uses of the FXCM Macro Economic Sentiment (Lean example) to get the signals. And, the risk manager I already shared in this forum.

The code is commented, so you can follow the logic there.

Now, I need some advices.

Quant front:

The take profit is very simple; is that bad? how can I improve it?

Also the volatility model, that in turns defines the stop loss price and –in turn- the take profit price is just a STD. Seems it works, but I have the feeling it can be improved. Maybe different indicator or same indicator with different configuration for each pair can be used. What do you think?

Implementation front:

When I try to use the trailing order from the RiskManager, the algorithm runs out of memory. After reading in this post, I call the Garbage Collector once per day. The algorithm runs a little longer, but in it hits the memory limit again. Any ideas of how the trailing order can be improved?

Any hint, advice, idea will be much appreciated.

Have a nice Weekend!

Update Backtest






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.



Why so much fees? Isn't the transaction fee in the spread?

0

 

Interesting stuff, thanks for sharing.

When it comes to computing profit target and stoploss, I would like to do something like this eventually: 

http://forexop.com/strategy/stop-loss-profit-placements-max-returns/

A more simple and obvious approach would be to optimize take profit, if this is the single parameter optimized it shouldn't be too bad w.r.t. chance of curve fitting. I don't think QC yet supports that though, but James Smith published a fork of Lean with GA optimization if you can run it locally.

@Eldar: At least a while back, Oanda data only had spreads for Tick resolution in QC. (Not sure if that's been fixed yet.) Anyway, if that's the case, it's necessary to model that cost as additional fee or slippage. However, I can't find any code doing this so maybe it's been handled by QC now and listed as fees? Not sure.

0

@Peter, I'm glad you like it.

Thank you for the post on SP and TP... I'm already thinking in how to implement it in Lean ;)

The TP/SL price rate was defined in a naïve way. If you try this algorithm with the Take Profit orders disabled, the Average Win is 8%, but the Win Rate is so small that the algorithm has negative Net Profit. Given that the Spot Loss price is defined in a way that the maximum risk is 2%, I tried with a proportion of 3 in order to capture some profit from loser trades.

The gut feeling was like: “If the Average Win is 8%, then for sure, lots of the losing trades can archive some smaller profit (6% in this case), so let’s try to capture it”… and it worked.

@Elgar

Respect to the fees, testing with a simpler algorithm, Oanda brokerage charges $2 for each order in backtest. In the code the fee model is constant and equal to zero and no slippage is considered.

QC Staff, we can use some help here!

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.


@JayJayD @Peter Would you guys wanna collaborate on the RiskManager? Maybe a tiny GitHub project?
0

JayJayD

With respect to slippage, we are currently reprocessing all of our Oanda and FXCM data to more accurately reflect spreads.  This data is currently in testing and should be rolled out in the next day or two.  There shouldn't be any code changes you'll need to make. The only difference you'll see is the fill price which will more accurately reflect the kinds of fill prices you see in live trading.

0

@Eldar, I’d like to work in a RiskManager… actually I keep working in the implementation used in this algorithm. Have you seen it? Do you have any ideas to improve it or new features to implement? Or even new ideas to make a new RiskManager from scratch?

Thank you @Andrew Hart, I can’t wait for the new data.

But, the question of why this algorithm has so high fees is still open. Why this algorithm made 268 trades and the fees are $3468?

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.


@JayJay Yes I had my own ideas for a risk manager too. I have seen your implementation and it would be nice if we can exchange ideas for some new features to implement.

0

Thanks
1

JayJayD - Hope you are well. I've turned the Strategy on to a Live market, but I noticed that no trades have been placed. In the aftermath of the AU GDP numbers being released, your strategy placed a trade on AUDUSD yesterday within the backtesting framework, but no live trade was placed. Do you have any ideas on why this could be? I do not have any conspicuous error/log messages that suggests there was an internal strategy issue related to the build.

0

Hi there FX Trader,

I suspect there is an error with the BaseData implementation.

Please, post this error as Issue in github.

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.


JayJayD - sounds good. Can you let me know what led you to think there could be an error with the BaseData implementation section? Anyway, thanks for the quick response. It is nice to see how involved some of the community members are!

0

Could be interesting to see how applying the Kelly Criterion to this strategy would affect risk/profit-taking opportunities by the way.

0

Hey FX,

Thanks for your kind words!

I said about the BaseData implementation because you said that in Live mode didn’t trigger an order but in backtest it did. And you can see in the GetSource method there is a different url if the algorithm is running in Live mode. But I’m not sure, maybe the problem is in the server side, That’s why I suggest to post a Github Issue.

I like the idea of Kelly criterion, it shouldn’t be hard to implement.

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.


thanks for sharing
1

JayJayD ; am I correct to assume that no live trades can be placed until this BaseData implementation feature is researched further? I made the issue/comment on Github, but have not heard any replies. 

0

This is open source, there is a core team working on it full time, but most of this kind of problems are solved by the users.

Maybe you can give it a shoot, fix it and share it with the community.

Good luck!

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.


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