Hey all,
I'm new to this system, and still trying to get my bearings from the documentation and the python examples. There does not seem to be any examples for forex trading with python, all of them appear to use stocks. This shouldn't be a problem as its just a different type of equity, but I keep running into problems getting 'simple' scripts to run. Anyway, I attempted to mod the MACD stock example code as a test case, but it has backtest issues.
Any advice/insight/guidance would be greatly appreciated. (I attached the backtest, but because it wont run the only merit is being able to see the code) {Still a really cool feature though}
Andreas Dekrout
Andreas Dekrout
Nolan English
@Andreas
Do you mind sharing your example by embedding your backtest? I haven't had the chance to try your solution?
Andreas Dekrout
I hope the attaching of the backtest works. I am very new here too.
anyway, I just took the code from github
just replaced "Equity" with "Forex" and ofcourse "EURUSD" instead of "SPY".
If you stumble across some good python documentation, I'd be thankfull, if you shared with me ;)
Nolan English
@Andreas Dekrout
At this point the best documentation, I have seen is the style guide. Which they are going to update. However, they are working on adding numpy and pandas support which will be amazing.
Nolan English
Thanks a ton for the specifics btw, (can't edit previous posts)
Apollos Hill
I also haven't had much luck finding other users on here that code forex algo's using python. Here;s my most successful backtest. I just joined the site a week ago. I'm learning on my feet. I'm doing a simple buy low sell high, sell high/buy low, strategy with CCI indicator. Feedback?
Alexandre Catarino
Hi Apollos Hill, your algorithm looks fine to me. It is a clean, easy to read, code and you used the API properly.
My only critic is on the order quantity: why are you fixing the order quantity to 40000 shares? This is not optimal, because you are not taking advantage of compounding.
Apollos Hill
Hi Alexandre.
when you say compounding, do you mean trading on my winnings instead of a flat number of 40,000? that thought hadn't occured to me yet. I should implement that. Can you start me on that code? I guess I would need to write a statement that says...setmarket order of a particular percentage of my portfolio (that i'm willing to risk)?
Jared Broad
Alex means sizing your position based on the total number of assets available in your account (e.g. 50% of portfolio value / share price = quantity).
Personally, I prefer to use a fixed position sizing like you've done here as it eliminates compounding allowing you to judge the algorithm purely on its insights over time. Compounding and leverage are mechanisms available to every algorithm so its best to remove them from backtests so it is easier to compare algorithms.
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.
Apollos Hill
Hi thanks for the feedback Jared. That is my goal to purely test the skill of the strategy before i start "optimizing" and managing risk. Can someone take a look at this? I've run a few tests and my algo only logs like 5 trades but on the chart it shows that its buying and selling throughout the year. I have the timeframe set to minute...? is there something wrong with m CCI values?
Jing Wu
Hi Apollos,in your algorithm, orders are placed when "not self.Portfolio.Invested". It means if you have any open positions in the portfolio, "self.SetHoldings" or "self.StopMarketOrder" wouldn't be triggered. The custom chart plots the CCI value, it does not reveal the internal trading logic of your algorithm. You can not check the order execution with only CCI indicator value. It is better to add the log message in the algorithm to find out if the trading conditions are met in the algorithm.
Nolan English
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!