- ago
I had a weird new RT error attributed to this code line:

CODE:
          _greek = TradierHistorical.Instance.GetGreeks(_contractSymbol);


When I commented out this function, the RT error disappeared. Nothing I did corrected the runtime error, including manually typing in the valid string symbol(s) in place of the variable for _contractSymbol. Certain other symbols worked fine. All symbols looked valid in a Tradier Options Chain.

I decided to create a barebones testbench strategy and ran one of the offending symbols. It worked fine. I went back to the original strategy, and now it ran fine, with no modification. Even more strangely, all the offending symbols now worked, even though I tested only one with the workbench.

Does any possible explanation for this behavior come to mind?

BTW, this issue occurred both before and after he Tradier extension update.
0
151
15 Replies

Reply

Bookmark

Sort
Glitch8
 ( 12.05% )
- ago
#1
First let’s clarify terms, what is an RT error?
0
- ago
#2
Run Time

"Line ... not an object"
0
- ago
#3
Moreover, can you tell us what the actual Run-Time error message says?

I'm also wondering why you're getting all these errors, but no one else is? What's going on?

My thinking at this point is the problem has nothing to do with the application layer (such as WL), but is in the OS itself. If I were you, I would load WL up on a separate (borrowed) second machine and see if all these problem disappear. If so, I would have a Windows security expert review your problem machine. Something is seriously going on that's affecting its ability to communicate. Perhaps you're hosting a spam bot and don't even know it--but that's just a "guess" on my part. It could even be a corrupted Ethernet driver or TCP/IP protocol stack on your machine.
0
- ago
#4
QUOTE:
Moreover, can you tell us what the actual Run-Time error message says?

Post #2

QUOTE:
I'm also wondering why you're getting all these errors, but no one else is? What's going on?

It's a good question. I have recently been working on multiple new types of strategies and functions that use features of WL, which I haven't used before. So far, most of the recent issues I have reported have been software-related and have since been resolved. Once I stop trying new things, I'm sure the issues will decrease, and I will have a stable set of working strategies.
0
Glitch8
 ( 12.05% )
- ago
#5
The TradierHistorical.Instance property is an undocumented property that the extension uses internally. You’re welcome to use it, but it won’t actually get initialized until you’ve collected some historical data from Tradier previously (like in a chart.) That’s likely the cause of the Strategy error.
0
- ago
#6
First time I've heard that. Is there another way to get Greeks for a symbol with Tradier?
0
Glitch8
 ( 12.05% )
- ago
#7
Let me check with Cone. For now you can try the following line before using the Instance:

TradierHistorical.Instance.InitializeIfRequired();
0
Cone8
 ( 23.52% )
- ago
#8
Instead of inventing a new way to do the same thing, let's get some better data about what's happening. It sounds like there's an object reference error, which means we got a response with no data and didn't handle it properly. That's a bug. I can probably find it, but it usually helps if we actually know the line number and full text of the error message.
0
Cone8
 ( 23.52% )
- ago
#9
I looked into and have to guess that the bug is in your strategy code.

We can take some blame for not having any Tradier documentation in the Help Guide (not sure what happened there), but the OptionGreek class is documented and the Symbol property has a GetGreeks() example (snippet):

CODE:
         if (optSym != null)          {                OptionGreek greek = IBHistorical.Instance.GetGreeks(optSym);             if (greek != null)             { }
GetGreeks returns an OptionGreek, but it can be null if no greeks data were found. Are you checking for null there?
If you don't, you'll get the error your "RT error".

Further, if a non-null object is returned, each of the greeks can be a NaN. Keep that in mind and that Tradier updates the greeks only once each hour . You can check when it was last updated by checking the greek.UpdateAt property.
0
Glitch8
 ( 12.05% )
- ago
#10
Robert, these Instance properties being used in a Strategy is something we haven’t documented. Any method intended to be used in a Strategy should ensure that the Provider being used has been initialized by calling InitializeIfRequired.
0
Cone8
 ( 23.52% )
- ago
#11
Okay, we can add that to the base methods.
0
Glitch8
 ( 12.05% )
- ago
#12
Sounds good!
0
- ago
#13
QUOTE:
Let me check with Cone. For now you can try the following line before using the Instance:

TradierHistorical.Instance.InitializeIfRequired();

Yes. this fixed it.

QUOTE:
GetGreeks returns an OptionGreek, but it can be null if no greeks data were found. Are you checking for null there?

Yes. I did not test for null on _ContractSymbol, but I did send value to DebugLog and it appeared successfully even on failure.
CODE:
               _greek = TradierHistorical.Instance.GetGreeks(_contractSymbol);                if (_greek != null)                {                   _optPrice = _greek.OptionPrice;                   //dev2 - test                   WriteToDebugLog("Selling " + _contractSymbol + " Greek price " + _optPrice, false);                }                else                {                   _optPrice = _obars.Close[idx];                   //dev2 - test                   WriteToDebugLog("Greeks are null. Selling " + _contractSymbol + " at Last bar price " + _optPrice, false);                }

This code does not prevent the run time error. Only eliminating the GetGreeks() method call or using @Glitch workaround above does. The error message is exhibiiting as if _contractSymbol is not an object. But it is, so the error message is actually misleading.

I cannot replicate the error once I use the @Glitch fix, at least until tomorrow, assuming I run without intitalization code, ulnless you tell me how to manipulate the history data to recreate the problem. Do you want me to do that and send you the error message?. Apparently, once the instance is "initialized," it works fine (until bar data is out of date, as @Glitch predicted).

QUOTE:
Okay, we can add that to the base methods.

Does that mean the initialization line will no longer be needed in the code, and it will work like the other [broker]Historical.Instance....? Will this be a change in the Tradier extension or main WL code base?

0
Cone8
 ( 23.52% )
- ago
#14
We'll update both. It's really not a big deal. If you just request one chart that is served by TradierHistorical before you start requesting GetGreeks from Tradier, that's all that's required right now.
0
- ago
#15
Just FYI, while you're looking into this: The first time each day (after WL restart) I run strategy with this code

CODE:
               TradierHistorical.Instance.InitializeIfRequired();                _greek = TradierHistorical.Instance.GetGreeks(_contractSymbol);                if (_greek != null)


it throws a runtime error on every symbol. If I run it immediately after, it runs perfectly. It appears the workaround to initialize is not working in this case.
0

Reply

Bookmark

Sort