Skip to content

MACDIndicatorValue has histogram and signal values reversed #517

@ibcodemonkey

Description

@ibcodemonkey

Describe the bug
The MACDIndicatorValue object create in response to python API call get_macd() has its histogram and signal values reversed. It appears the from_dict() deserializer either uses wrong labels or the variable assignment is incorrect.

To Reproduce
As an example the most recent MACDIndicatorValue returned by the call

client = RESTClient(api_key=“….”)
client.get_macd(ticker=“DBC”, timestamp_lte="2023-09-16", timespan=“week”, short_window=4, long_window=13, 
                                  signal_window=8, series_type="close")

is
MACDIndicatorValue(timestamp=1694318400000, value=0.6858891541204777, signal=0.23005417069090606,
histogram=0.4558349834295716)

Comparing with the values returned by a similar call to MACD with the same parameters in TradeView which yield:-
hist (histogram) = 0.2301
macd (value) = 0.6859
signal (signal) = 0.4558

Appears polygon has swapped its returned histogram and signal values. This, on the surface is confirmed by looking at the code
With respect to tag v1.12.4
File client-python/polygon/rest/models/indicators.py
Line 34 & 35
signal=d.get("histogram", None),
histogram=d.get("signal", None),

Expected behavior
Would expect the returned MACDIndicatorValue object in this situation to be :-

MACDIndicatorValue(timestamp=1694318400000, value=0.6858891541204777, histogram=0.23005417069090606, signal=0.4558349834295716)

Screenshots
None

Additional context
None

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions