Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap signal/histogram to align correctly #520

Merged
merged 2 commits into from
Sep 23, 2023
Merged

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
9 checks passed
@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