From da7f67a62696990db74e5e2ed35d8b5525f747c8 Mon Sep 17 00:00:00 2001 From: oligirling Date: Sun, 22 Feb 2026 11:30:00 +0000 Subject: [PATCH 1/2] Makefile: test and run without build (use python:3.12-slim image) Co-authored-by: Cursor --- Makefile | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index cc45eb8..78a5968 100644 --- a/Makefile +++ b/Makefile @@ -4,31 +4,33 @@ LOCAL_DOCKER_IMAGE=houseofapis/currencyapi-python CONTAINER_NAME=currencyapi-python WORKING_DIR=/app PORT=7004 -DOCKER_COMMAND=docker run --rm -v ${PWD}:${WORKING_DIR} -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT} ${LOCAL_DOCKER_IMAGE} -DOCKER_COMMAND_INTERACTIVE=docker run --rm -v ${PWD}:${WORKING_DIR} -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT} -it ${LOCAL_DOCKER_IMAGE} +# Use official image so test/run work without building +DOCKER_IMAGE ?= python:3.12-slim +DOCKER_RUN = docker run --rm -v ${PWD}:${WORKING_DIR} -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT} +DOCKER_RUN_IT = docker run --rm -v ${PWD}:${WORKING_DIR} -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT} -it build-image: ## Build docker image docker build -t ${LOCAL_DOCKER_IMAGE} . -test: ## Run the tests - ${DOCKER_COMMAND} python -m coverage run -m unittest discover +test: ## Run the tests (no build required) + ${DOCKER_RUN} ${DOCKER_IMAGE} sh -c "pip install -q -e . coverage && python -m coverage run -m unittest discover" -run: ## Run the sample testing file - ${DOCKER_COMMAND} python run.py +run: ## Run the run file (no build required) + ${DOCKER_RUN} ${DOCKER_IMAGE} sh -c "pip install -q -e . && python run.py" -test-coverage: ## Show test coverage - ${DOCKER_COMMAND} python -m coverage report +test-coverage: ## Show test coverage (no build required) + ${DOCKER_RUN} ${DOCKER_IMAGE} sh -c "pip install -q -e . coverage && python -m coverage run -m unittest discover && python -m coverage report" setup: ## Setup - ${DOCKER_COMMAND} python setup.py install + ${DOCKER_RUN} ${DOCKER_IMAGE} pip install -e . -exec: ## Run test file - ${DOCKER_COMMAND_INTERACTIVE} sh +exec: ## Shell into container + ${DOCKER_RUN_IT} ${DOCKER_IMAGE} sh build-package: ## Build pip package ${DOCKER_COMMAND} python setup.py sdist bdist_wheel -upload-package: ## Upload pip package +upload-package: ## Upload pip package (requires build-image first) docker run --rm -v ${PWD}:${WORKING_DIR} -v ${HOME}/.pypirc:/root/.pypirc -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT} ${LOCAL_DOCKER_IMAGE} python -m twine upload dist/* help: From 91f609af98d3d6b9efd3ef58e1721fcebb2a07aa Mon Sep 17 00:00:00 2001 From: oligirling Date: Sun, 22 Feb 2026 11:31:46 +0000 Subject: [PATCH 2/2] OHLC: rename currency() to quote() and param to quote (align with API response) Co-authored-by: Cursor --- CHANGELOG.md | 5 +++++ README.md | 10 +++++----- currencyapinet/endpoints/ohlc.py | 4 ++-- tests/endpoints/test_ohlc.py | 14 +++++++------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b9161..420c254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## [2.1.0] - 2026-02-22 + +### Changed +- OHLC endpoint: renamed `currency()` to `quote()` and request parameter from `currency` to `quote` to align with API response field names. + ## [2.0.0] - 2026-02-19 ### Added diff --git a/README.md b/README.md index b0a1889..1d4a21e 100644 --- a/README.md +++ b/README.md @@ -128,23 +128,23 @@ Returns OHLC (Open, High, Low, Close) data for a currency pair on a specific dat | Parameter | Required | Description | |------------|----------|-------------| -| `currency` | Yes | Target currency code (e.g. `EUR`, `GBP`, `BTC`) | +| `quote` | Yes | Quote currency code (e.g. `EUR`, `GBP`, `BTC`) | | `date` | Yes | Date in `YYYY-MM-DD` format (must be in the past) | | `base` | No | Base currency code (defaults to `USD`) | | `interval` | No | Time interval: `5m`, `15m`, `30m`, `1h`, `4h`, `12h`, `1d` (defaults to `1d`) | ```python # Basic request (1-day interval) -result = currency.ohlc().currency('EUR').date('2023-12-25').get() +result = currency.ohlc().quote('EUR').date('2023-12-25').get() # With custom interval -result = currency.ohlc().currency('GBP').date('2023-12-25').interval('1h').get() +result = currency.ohlc().quote('GBP').date('2023-12-25').interval('1h').get() # With custom base currency and interval -result = currency.ohlc().currency('JPY').date('2023-12-25').base('EUR').interval('4h').get() +result = currency.ohlc().quote('JPY').date('2023-12-25').base('EUR').interval('4h').get() # XML output -result = currency.ohlc().currency('EUR').date('2023-12-25').output('XML').get() +result = currency.ohlc().quote('EUR').date('2023-12-25').output('XML').get() ``` **Example response:** diff --git a/currencyapinet/endpoints/ohlc.py b/currencyapinet/endpoints/ohlc.py index 18c8184..e61eb96 100644 --- a/currencyapinet/endpoints/ohlc.py +++ b/currencyapinet/endpoints/ohlc.py @@ -6,8 +6,8 @@ class Ohlc(Endpoint): def __init__(self, api_key: str): super().__init__(api_key, OHLC_ENDPOINT) - def currency(self, currency: str): - self.add_param('currency', currency.upper()) + def quote(self, quote: str): + self.add_param('quote', quote.upper()) return self def date(self, date: str): diff --git a/tests/endpoints/test_ohlc.py b/tests/endpoints/test_ohlc.py index 2b77ba7..e0aef95 100644 --- a/tests/endpoints/test_ohlc.py +++ b/tests/endpoints/test_ohlc.py @@ -8,10 +8,10 @@ class Test(TestCase): def setUp(self): self.class_under_test = Ohlc('fakekey') - def test_ohlc_currency(self): - self.class_under_test.currency('eUr') - self.assertEqual('EUR', self.class_under_test.param.get('currency')) - self.assertIsInstance(self.class_under_test.currency('EUR'), Ohlc) + def test_ohlc_quote(self): + self.class_under_test.quote('eUr') + self.assertEqual('EUR', self.class_under_test.param.get('quote')) + self.assertIsInstance(self.class_under_test.quote('EUR'), Ohlc) def test_ohlc_date(self): self.class_under_test.date('2023-12-25') @@ -36,16 +36,16 @@ def test_ohlc__build_url_params(self): {'key': 'fakekey', 'output': 'JSON'}, self.class_under_test._build_url_params() ) - self.class_under_test.currency('EUR') + self.class_under_test.quote('EUR') self.class_under_test.date('2023-12-25') self.assertDictEqual( - {'key': 'fakekey', 'output': 'JSON', 'currency': 'EUR', 'date': '2023-12-25'}, + {'key': 'fakekey', 'output': 'JSON', 'quote': 'EUR', 'date': '2023-12-25'}, self.class_under_test._build_url_params() ) self.class_under_test.base('gbP') self.class_under_test.interval('1h') self.assertDictEqual( - {'key': 'fakekey', 'output': 'JSON', 'currency': 'EUR', 'date': '2023-12-25', 'base': 'GBP', 'interval': '1h'}, + {'key': 'fakekey', 'output': 'JSON', 'quote': 'EUR', 'date': '2023-12-25', 'base': 'GBP', 'interval': '1h'}, self.class_under_test._build_url_params() )