-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add Tulip and Talib Indicator-Results to 'stratUpdate' event #2483
Conversation
great idea! Just tiny style nits:
That way they are easier to use for the UI since all indicators are fully encapsulated. If we than have UI elements that can draw bbands we can simply pass the object (per stratUpdate).
|
Nice ideas! I'll change a few things ;) |
Omg, Github didn't show the changes... :( But these commits lead to the suggested structure. |
It does look great for me, I'll test and run this asap before I can merge.
But I'm pretty sure it looks good as is :)
…On Wed, Aug 29, 2018 at 12:36 AM, Klemens Wittig ***@***.***> wrote:
Omg, Github didn't show the changes... :( But these commits lead to the
suggested structure.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2483 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA7MD7MDTBr6lEAeMb-ZaKH3Tpsilfcqks5uVXF7gaJpZM4WPReF>
.
--
PGP key at keybase.io/mikevanrossum
<https://keybase.io/mikevanrossum/key.asc>
|
I tested this and would you mind doing one more tiny tweak? A lot of indicators only have one result (I quickly spotted ADR, RSI, DEMA, EMA, etc), which TA-lib nests in an object with a single prop called outReal. In case there is outReal we don't need to include that property name. For example:
|
Hmmm... I think it needs a more generic approach then. This should deal with all eventualities. |
Yea that is fine too!
…On Wed, 29 Aug 2018, 19:45 Klemens Wittig, ***@***.***> wrote:
Hmmm... I think it needs a more generic approach then.
The best would be to check if the indicator result is an object.
Then check if it's _.size() is 1.
If so, directly insert the first key into result, otherwise insert the
whole object.
If size is 0, set result null to show, that is not set..
This should deal with all eventualities.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2483 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA7MDyj7su7tC58dNwzIF7ThHfiO_tEOks5uVn7UgaJpZM4WPReF>
.
|
Ok, so now the code considers empty objects and inserts single-property objects directly. It uses |
I usually agree here, but in this case I think it's more important to stick to what we know the output will look like: The current version of tulip will already spit out a number instead of an object with one result property. Do we really need all these checks (for tulip) because we know TA-lib does something different (while we know tulip does not)? I really don't think we need 15 lines of if checks for tulip indicators:
Note that tulip and talib are compiled libraries that (once installed properly) give very consistent output. This is different from external APIs that can have timeouts, network errors, other API errors, etc. As such I think it's better to have very simply code that parses it according to our expectations than complex code that tries to work with anything thrown at it (I'm not sure why we need things like explicit forOwn at all: lodash already filters these when looping). I personally rather merge up to Do you agree? What do you think? Apologies I should have said that when you asked about, I didn't think the result would turn out to ~40 lines of if checks with as much property lookups and loops. |
I agree on the Tulip part. It's really very generic where it shouldn't be. On the TaLib side, if I understand it's concept correctly, there might be the chance that ot has more properties than Since I don't have access to any PC for the next few days, this might take a while. 😉 |
1 similar comment
I agree on the Tulip part. It's really very generic where it shouldn't be. On the TaLib side, if I understand it's concept correctly, there might be the chance that ot has more properties than Since I don't have access to any PC for the next few days, this might take a while. 😉 |
Just to be sure, whether there is one property (called outReal) is not random or chance based. This happens 100% of the time for specific indicators which only have 1 output. The proper solution (imo) would be a whitelist of indicators that have one output. But that requires us now to go through all of them, and maintain a whitelist. As such as quick and easy solution would be a simple check for only the talib indicators like (pseudo code):
This code is concise, easy to understand (there is 1 edge case: there is only 1 prop called outReal), all other cases don't transform output. And most likely fast enough. If speed proves a bottleneck a whitelist would be faster (since you don't need to convert an object into an array of its keys on every stratUpdate). But overkill given that we need to make and maintain one now. If you really want to have a more generic solution, could you argue what the benefits would be? |
Revert to performant variant and consider outReal in Talib
I reverted to the most performant version. ´outReal´ will be considered in Talib instead of ´result´. If there's any more properties to consider, it would be easy to implement them later with if-else or similar without using any overhead functions from lodash or requiring to iterate btw. Coding on mobile phone somehow works, but is tedious ;) |
Home again, tested it. Works! ;) |
It took me while to test this, it works great! And apologies for going back and forth between how to solve the talib issue. |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
It add TULIP and TALIB indicator results to the
stratUpdate
event - emitter.What is the current behavior? (You can also link to an open issue here)
Currently only native indicators can be retrieved via
stratUpdate
event.What is the new behavior (if this is a feature change)?
TULIP and TALIB indicator results are added as [name of the indicator]-[resulting value incl. name], e.g.
Now they can be displayed or evaluated in the GUI client.