Skip to content

Conversation

justinpolygon
Copy link
Contributor

@justinpolygon justinpolygon commented Sep 18, 2023

Fixes #517.

When you query MACD with https://api.polygon.io/v1/indicators/macd/AAPL?timestamp=2023-09-15&timespan=day&adjusted=true&short_window=12&long_window=26&signal_window=9&series_type=close&order=desc&apiKey=XXXXX

You'll get:

{
    "results": {
        "underlying": {
            "url": "https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/1683259200000/1694822400000?limit=129&sort=desc"
        },
        "values": [
            {
                "timestamp": 1694750400000,
                "value": -1.8845466782712492,
                "signal": -1.1791051213715642,
                "histogram": -0.705441556899685
            }
        ]
    },
    "status": "OK",
    "request_id": "f445778cb41fc163c0ee5a10da0c940e"
}

If you run the same thing via the python client using this:

from polygon import RESTClient

client = RESTClient()

macd = client.get_macd("AAPL", 
	timestamp="2023-09-15", 
	timespan="day", 
	adjusted=True, 
	short_window=12,
	long_window=26,
	signal_window=9,
	series_type="close"
	)
print(macd)

You'll get:

MACDIndicatorResults(
	values=[
	MACDIndicatorValue(
		timestamp=1694750400000, 
		value=-1.8845466782712492, 
		signal=-0.705441556899685, 
		histogram=-1.1791051213715642
		)], 
		underlying=IndicatorUnderlying(url='https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/1683259200000/1694822400000?limit=129&sort=desc', aggregates=[]))

You can see the signal and histogram values are swapped. This PR corrects the code and tests.

@justinpolygon justinpolygon marked this pull request as ready for review September 18, 2023 22:59
@justinpolygon justinpolygon merged commit e16370e into master Sep 23, 2023
@justinpolygon justinpolygon deleted the jw-macd-swap branch September 23, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MACDIndicatorValue has histogram and signal values reversed
2 participants