I have a strategy(let's say strategy A) in which there are about 50 lines of coding I want to reuse them again in other strategies. So I created few custom functions based on these lines and used these newly created functions instead of the 50 lines of coding in strategy B(everything remains the same as strategy A except without the 50 lines of coding). Then I made a comparison between strategy B with custom functions and strategy A to see if they gave the same result on the performance report. Obviously the results are the same, so I spent few days in reading the codes line by line and finding out where the bugs are and what made the discrepancy between them. Unfortunately I can't locate where the problems are. For example the stop orders in strategy A were working the way I wanted to. However these stop orders in strategy B had very different prices (although I used the reserved word "stop" in the coding, but it seems to me that these stop orders became market order instead) which gave a very different result compared to strategy A.
I understand that without showing you the codes you can not tell me what the problems are. I would be grateful if you could tell where the problems normally lies in and give some general guideline in debugging as well as creating custom functions which I should pay attention to.
Best regards,
Stephen
I am stuck and need helps on debugging
- arnie
- Posts: 1594
- Joined: 11 Feb 2009
- Location: Portugal
- Has thanked: 481 times
- Been thanked: 514 times
Re: I am stuck and need helps on debugging
You don't need to post your strategy code but it would be preferable to code some example that generate the same problem you're seeing on your strategy so the guys could easily see what is happening and help you.
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: I am stuck and need helps on debugging
I'm slightly confused by this part; you say that 'obviously the results are the same' but also that there's a discrepancy between them. So is there's a difference between Strategy A and Strategy B, or are you talking about Strategy A without functions and Strategy A with functions, or some other comparison?Then I made a comparison between strategy B with custom functions and strategy A to see if they gave the same result on the performance report. Obviously the results are the same, so I spent few days in reading the codes line by line and finding out where the bugs are and what made the discrepancy between them.
Stop orders become a market order when triggered, yes. Did you meant to use a stop-limit order?However these stop orders in strategy B had very different prices (although I used the reserved word "stop" in the coding, but it seems to me that these stop orders became market order instead) which gave a very different result compared to strategy A.
Re: I am stuck and need helps on debugging
JoshM, it's stop order I want, not stop limit order. Thanks for your help anyway.
I have emailed the all the details to Henry to have a look. Hopefully, Henry will give me positive feedback.
Best regards!
I have emailed the all the details to Henry to have a look. Hopefully, Henry will give me positive feedback.
Best regards!