- ago
Hi,
In back test mode run time errors are noted at the bottom of the C# code editor page at the same place where compiler results are posted.
However, this page does not exist in streaming mode (chart).
Currently I insert writes to a debug file to locate the error.
It would be a productivity improvement if I could see sch errors in streaming mode.
My state machines are such that the errored code is not hit in back test mode.
Thanks!
0
154
Solved
8 Replies

Reply

Bookmark

Sort
Cone8
 ( 2.85% )
- ago
#1
Send messages to the Log Viewer with AddLogItem using WLHost.Instance.
https://www.wealth-lab.com/Support/ApiReference/IHost#AddLogItem

Example:
CODE:
WLHost.Instance.AddLogItem(StrategyName, yourString, WLColor.Blue);
0
Best Answer
- ago
#2
it seems this is a call from within a catch in a try/catch pair.
In other words, one needs to have an idea where the exception is.
I was looking for a facility like the one in the strategy window.
In the C# code editor tab where compiler results are posted.
If there is a run time error in backtest run, it shows up there.
0
Cone8
 ( 2.85% )
- ago
#3
Why is your code generating runtime errors?
Does it only happen in Streaming for some reason?

Generally, if you've written code that expect errors, you need to catch the errors and do something with them.
0
- ago
#4
QUOTE:
it seems this is a call from within a catch in a try/catch pair.
In other words, one needs to have an idea where the exception is.

Well I typically reserve try/catch pairs for local library code, which my strategies call, but you don't have to. You could put a try/catch pair around your Initialize code if you wanted to.

If the error is in the strategy itself, it's easiest to simply place a WriteToDebugLog line in the strategy code.

Another option is to place "return;" statements in the code to see if you hit the return statement before the run-time error. If not, then just move the return statement farther down in the program until you do.

I wouldn't let your main strategy code get much over 400 lines. If it is, then I would move some of the more stable/established (and debugged) code into local library code to reduce the strategy size. My strategies are typically under 250 lines, but my local library code is around 2800 lines and shared by many strategies.
0
- ago
#5
In streaming a strategy with bars updating every 10 seconds
Possibly due to Y! quotes coming in at irregular intervals
WL8 submits a pass (init + execs) too soon after a previous pass
I use globals to idle the second one
What happens is:
The earlier pass skips cleanup and backtestcomplete
And also the tail end code in execute does not execute
I am still working this issue to be able to present it clearly.
It might take a week or two. It is a sporadic problem.
I inserted a try/catch for the code that does not execute.
It did not go to catch.
By the way I use file writes to a debug.txt for debug purposes.
I will submit under a different heading.
Any thoughts that come to mind are appreciated!
0
Cone8
 ( 2.85% )
- ago
#6
I'll just mention that Yahoo! streaming is probably the worst provider you could think of to use for 10 second bars. It only polls for quotes every 5 seconds, so it's not really "streaming" at all. ANY other streaming provider would be better.
0
- ago
#7
Yes, thank you!
Y! for debugging purposes.
Eventually will use IBKR and whatever your IBKR users most often choose. as data provider.
In a way Y! s shortcomings create a good testbed to create resilient code.
0
Cone8
 ( 2.85% )
- ago
#8
All the pros and cons for intraday and streaming providers is here:
All About WealthLab Intraday and Realtime Data Providers
0

Reply

Bookmark

Sort