HMA throws exception with a misleading / incorrect message.
See original GitHub issueThe problem
I called:
var values = quotes.GetHma(9);
Where quotes
only had 10 items. This throws an exception, which is fine. The text of the exception is not quite right. (See next section.)
Error message(s):
Skender.Stock.Indicators.BadQuotesException: 'Insufficient quotes provided for WMA. You provided 2 periods of quotes when at least 3 is required. (Parameter 'quotes')'
To Reproduce
Call the GetHma()
extension method passing in 9
as the number of lookback periods, calling from a List<Quote> with 10 instances of Quote
.
Expected behavior
I expected the error message use the term “HMA” rather than “WMA”, and I expected the count of items to reflect the actual number of items in my collection (which was 10).
Screenshots or other reference materials
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
java - Message of Throwable shows wrong text
Message of Throwable shows wrong text ... We're mocking the service and we're throwing the exception that we sometimes get from the service:...
Read more >Fixed defects - HCL Product Documentation
HMA -284415, Saving user Preference throws error in tcs tab. ... HMA-294556, Message displayed for text field length in misleading while creating form....
Read more >Function returning true/false vs. void when succeeding and ...
Throwing an exception is simply an additional way of making a method return a value. The caller can check for a return value...
Read more >Best Practice: Catching and re-throwing Java Exceptions
What is the correct Java™ programming best practice to catch, print, and re-throw Java exceptions?
Read more >7 Common Mistakes You Should Avoid When Handling ...
Mistake 1: Specify a java. · Mistake 2: Catch unspecific exceptions · Mistake 3: Log and throw an Exception · Mistake 4: Use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m glad you’re enjoying it! Thank you.
And thanks for finding this interestingly strange bug. HMA uses WMA internally and on their face they have the same historical quotes requirements. HMA basically takes two WMAs then does another aggregate WMA calculation that uses square root of
N
lookback — square root of 9 is 3 — and then it usesN-1
quotes.Clearly a rounding error in here that pops up with certain historical quote quantities or lookback periods. I may have to increase the minimum threshold if small quote quantities are the actual problem. I’ll dig in on it this weekend.
This Issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new Issue for related bugs.