- ago
Does anyone have sample code for creating BarHistory objects for unit-testing a compiled strategy? I'm having issues with exceptions from the IndicatorFactory.
Thanks
0
84
Solved
10 Replies

Reply

Bookmark

Sort
Cone8
- ago
#1
Create a BarHistory, for example:
CODE:
         BarHistory mybars = new BarHistory("ABCD", HistoryScale.Daily);          mybars.Add(...); // start adding data

What does creating a BarHistory have to do with IndicatorFactory?
What are you doing?
0
- ago
#2
I'm not doing anything with IndicatorFactory - BarHistory is. And what you wrote is exactly what I have....and it fails miserably.

I'm just trying to create a BarHistory so I can test my Strategy during development.

But BarHistory construction has a dependency on IndicatorFactory - and the unit tests blow up....and I'm really trying not to go down the reflection route to fix the problem
0
- ago
#3
0
Cone8
- ago
#4
Probably attaching debuggers in demo mode is not allowed. Write support@wealth-lab.com.

.. but if you just need to access a BarHistory that already exists, i.e., AAPL, use GetHistoryUnsynched().
0
- ago
#5
Thanks - but I need to be able to create them from scratch.....so I can drive my test scenarios.

I'll hit up support and see if they can give me an answer.
0
- ago
#6
The dependency is a missing instance for WLHost.Instance (which implements IHost.) Many things in WL assume that this WLHost.Instance is set. In this case, the MassageColors property of IndicatorFactory is pulling the persisted WLHost.Instance.Settings "MassageColors" value from the settings file. I can remove the dependency for the next build, or you can create a proxy class the implements the IHost interface, but that would probably be quite a bit of work.
0
- ago
#7
let me look at the proxy class class first - unless you have other developers running into a similar issue.

I don't want to blow up your architecture, if I'm the only one trying to do this.

Could end up being an interesting problem for me to solve :D
0
- ago
#8
I just need to add a null check in one method to prevent that exception, it's already in place for the next release cycle. But feel free to implement the proxy class too :)
1
Best Answer
- ago
#9
That turned into a futile chase down the reflection rabbit hole - ohh, the horror. TY muchly for the coming update
1
- ago
#10
Build 170 is released with that dependency removed.
0

Reply

Bookmark

Sort