From f2e7c242fd4a78872a1bc803f918af7c6c6b7969 Mon Sep 17 00:00:00 2001 From: suremarc <8771538+suremarc@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:04:41 -0400 Subject: [PATCH 1/5] serialize boolean parameters as lowercase strings in url --- polygon/rest/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/polygon/rest/base.py b/polygon/rest/base.py index 8afbd330..9bd6850f 100644 --- a/polygon/rest/base.py +++ b/polygon/rest/base.py @@ -47,7 +47,8 @@ def __init__( ca_certs=certifi.where(), cert_reqs="CERT_REQUIRED", ) - self.timeout = urllib3.Timeout(connect=connect_timeout, read=read_timeout) + self.timeout = urllib3.Timeout( + connect=connect_timeout, read=read_timeout) self.retries = retries if verbose: logger.setLevel(logging.DEBUG) @@ -126,6 +127,8 @@ def _get_params( val = caller_locals.get(argname, v.default) if isinstance(val, Enum): val = val.value + elif isinstance(val, bool): + val = str(val).lower() elif isinstance(val, datetime): val = int(val.timestamp() * self.time_mult(datetime_res)) if val is not None: From a24d1da739a50d85344f7b15807dfee8aae30cc1 Mon Sep 17 00:00:00 2001 From: suremarc <8771538+suremarc@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:41:36 -0400 Subject: [PATCH 2/5] fix unit tests --- ...20×pan=minute&adjusted=true×tamp.gt=2022-08-18.json} | 0 ...span=quarter×tamp=1483958600&expand_underlying=true.json} | 0 ...005-04-01&adjusted=True.json => 2005-04-01&adjusted=true.json} | 0 ...005-04-04&adjusted=True.json => 2005-04-04&adjusted=true.json} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename test_rest/mocks/v1/indicators/rsi/{AAPL&window=20×pan=minute&adjusted=True×tamp.gt=2022-08-18.json => AAPL&window=20×pan=minute&adjusted=true×tamp.gt=2022-08-18.json} (100%) rename test_rest/mocks/v1/indicators/sma/{AAPL&window=30×pan=quarter×tamp=1483958600&expand_underlying=True.json => AAPL&window=30×pan=quarter×tamp=1483958600&expand_underlying=true.json} (100%) rename test_rest/mocks/v1/open-close/AAPL/{2005-04-01&adjusted=True.json => 2005-04-01&adjusted=true.json} (100%) rename test_rest/mocks/v2/aggs/grouped/locale/us/market/stocks/{2005-04-04&adjusted=True.json => 2005-04-04&adjusted=true.json} (100%) diff --git a/test_rest/mocks/v1/indicators/rsi/AAPL&window=20×pan=minute&adjusted=True×tamp.gt=2022-08-18.json b/test_rest/mocks/v1/indicators/rsi/AAPL&window=20×pan=minute&adjusted=true×tamp.gt=2022-08-18.json similarity index 100% rename from test_rest/mocks/v1/indicators/rsi/AAPL&window=20×pan=minute&adjusted=True×tamp.gt=2022-08-18.json rename to test_rest/mocks/v1/indicators/rsi/AAPL&window=20×pan=minute&adjusted=true×tamp.gt=2022-08-18.json diff --git a/test_rest/mocks/v1/indicators/sma/AAPL&window=30×pan=quarter×tamp=1483958600&expand_underlying=True.json b/test_rest/mocks/v1/indicators/sma/AAPL&window=30×pan=quarter×tamp=1483958600&expand_underlying=true.json similarity index 100% rename from test_rest/mocks/v1/indicators/sma/AAPL&window=30×pan=quarter×tamp=1483958600&expand_underlying=True.json rename to test_rest/mocks/v1/indicators/sma/AAPL&window=30×pan=quarter×tamp=1483958600&expand_underlying=true.json diff --git a/test_rest/mocks/v1/open-close/AAPL/2005-04-01&adjusted=True.json b/test_rest/mocks/v1/open-close/AAPL/2005-04-01&adjusted=true.json similarity index 100% rename from test_rest/mocks/v1/open-close/AAPL/2005-04-01&adjusted=True.json rename to test_rest/mocks/v1/open-close/AAPL/2005-04-01&adjusted=true.json diff --git a/test_rest/mocks/v2/aggs/grouped/locale/us/market/stocks/2005-04-04&adjusted=True.json b/test_rest/mocks/v2/aggs/grouped/locale/us/market/stocks/2005-04-04&adjusted=true.json similarity index 100% rename from test_rest/mocks/v2/aggs/grouped/locale/us/market/stocks/2005-04-04&adjusted=True.json rename to test_rest/mocks/v2/aggs/grouped/locale/us/market/stocks/2005-04-04&adjusted=true.json From ea82be40412aa4c644448ebb17ef2e45336c439d Mon Sep 17 00:00:00 2001 From: suremarc <8771538+suremarc@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:53:11 -0400 Subject: [PATCH 3/5] fix last unit test --- ...393873000×tamp.gte=1477972800000.json | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=False×tamp.lte=1478393873000×tamp.gte=1477972800000.json diff --git a/test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=False×tamp.lte=1478393873000×tamp.gte=1477972800000.json b/test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=False×tamp.lte=1478393873000×tamp.gte=1477972800000.json deleted file mode 100644 index 333016cb..00000000 --- a/test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=False×tamp.lte=1478393873000×tamp.gte=1477972800000.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "results": { - "underlying": { - "url": "http://localhost:8081/v2/aggs/ticker/AAPL/range/1/day/1477368000000/1478393873000?adjusted=false\u0026limit=50000\u0026sort=desc" - }, - "values": [ - { - "timestamp": 1478232000000, - "value": 110.96883950617286 - }, - { - "timestamp": 1478145600000, - "value": 112.03325925925927 - }, - { - "timestamp": 1478059200000, - "value": 113.1348888888889 - }, - { - "timestamp": 1477972800000, - "value": 113.90733333333334 - } - ] - }, - "status": "OK", - "request_id": "aaa162ba-e0b6-4c4a-aa05-dcac472aea71" -} \ No newline at end of file From bf96915e7daeee1c0bea3b3774fa7ee52e043902 Mon Sep 17 00:00:00 2001 From: suremarc <8771538+suremarc@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:53:57 -0400 Subject: [PATCH 4/5] fix last unit test, for real --- ...393873000×tamp.gte=1477972800000.json | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=false×tamp.lte=1478393873000×tamp.gte=1477972800000.json diff --git a/test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=false×tamp.lte=1478393873000×tamp.gte=1477972800000.json b/test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=false×tamp.lte=1478393873000×tamp.gte=1477972800000.json new file mode 100644 index 00000000..333016cb --- /dev/null +++ b/test_rest/mocks/v1/indicators/ema/AAPL&window=5&adjusted=false×tamp.lte=1478393873000×tamp.gte=1477972800000.json @@ -0,0 +1,27 @@ +{ + "results": { + "underlying": { + "url": "http://localhost:8081/v2/aggs/ticker/AAPL/range/1/day/1477368000000/1478393873000?adjusted=false\u0026limit=50000\u0026sort=desc" + }, + "values": [ + { + "timestamp": 1478232000000, + "value": 110.96883950617286 + }, + { + "timestamp": 1478145600000, + "value": 112.03325925925927 + }, + { + "timestamp": 1478059200000, + "value": 113.1348888888889 + }, + { + "timestamp": 1477972800000, + "value": 113.90733333333334 + } + ] + }, + "status": "OK", + "request_id": "aaa162ba-e0b6-4c4a-aa05-dcac472aea71" +} \ No newline at end of file From 203cef8535ff7007698cc2d8f13058b9372eb12b Mon Sep 17 00:00:00 2001 From: suremarc <8771538+suremarc@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:55:22 -0400 Subject: [PATCH 5/5] lint --- polygon/rest/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/polygon/rest/base.py b/polygon/rest/base.py index 9bd6850f..7e35da27 100644 --- a/polygon/rest/base.py +++ b/polygon/rest/base.py @@ -47,8 +47,7 @@ def __init__( ca_certs=certifi.where(), cert_reqs="CERT_REQUIRED", ) - self.timeout = urllib3.Timeout( - connect=connect_timeout, read=read_timeout) + self.timeout = urllib3.Timeout(connect=connect_timeout, read=read_timeout) self.retries = retries if verbose: logger.setLevel(logging.DEBUG)