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!
Eldar
Why so much fees? Isn't the transaction fee in the spread?
Petter Hansson
Interesting stuff, thanks for sharing.
When it comes to computing profit target and stoploss, I would like to do something like this eventually:
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.
JayJayD
@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!
Eldar
Andrew Hart
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.
JayJayD
@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?
Eldar
@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.
Ronnachit Deepankaew
FX Trader
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.
JayJayD
Hi there FX Trader,
I suspect there is an error with the BaseData implementation.
Please, post this error as Issue in github.
FX Trader
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!
FX Trader
Could be interesting to see how applying the Kelly Criterion to this strategy would affect risk/profit-taking opportunities by the way.
JayJayD
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.
Kiki Te Iri
FX Trader
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.
JayJayD
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!
Apollos Hill
hi everyone,
is there any documentation on other events to use with the DailyFX Data other than calendar? I would like to use their sentiment data located here.
https://www.dailyfx.com/sentiment?ref=SentimentWidget
I know they take it from IG. Is there an IG API documentation i can read to learn how to import their sentiment data? Thank you.
Alexandre Catarino
At the moment, Lean/QuantConnect does not support other data from DailyFx that is not Calendar.
Does DailyFx distribute Sentiment data via API?
Apollos Hill
i couldn't find any documentation on sentiment data via API. i did find some documentation on IG.com but i would need backtest data for it to work.
Alexandre Catarino
We can add sentiment data (other than DailyFx Calendar) to your TODO list but without a data source, we will have to spend some time looking for one.
JayJayD
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!