From 1f76ce7b527c50f379fa251a7b57d5924ea7e991 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Fri, 21 Jun 2024 11:08:18 +0200 Subject: [PATCH 01/15] feat(deletetimezone): updated comment ref: #17577 --- src/Artesian/MarketData/_Dto/DeleteData.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Artesian/MarketData/_Dto/DeleteData.py b/src/Artesian/MarketData/_Dto/DeleteData.py index 4c9ea05..ba8df36 100644 --- a/src/Artesian/MarketData/_Dto/DeleteData.py +++ b/src/Artesian/MarketData/_Dto/DeleteData.py @@ -11,10 +11,11 @@ class DeleteData: Attributes: ID: the MarketDataIdentifier - timezone: the Timezone of the rows. Must be the OriginalTimezone - when writing Dates or must be ""UTC"" when writing Times rangeStart: LocalDateTime start of the range to be deleted rangeEnd: LocalDateTime end of the range to be deleted + timezone: Timezone of the delete range. For DateSerie must be + the OriginalTimezone of the Serie. In case null or empty + the default is CET for TimeSerie and OriginalTimezone for DateSerie product: The list of Product. Only *, is special character for 'delete all products in the range' version: the Version to operate on From 4a7246d1e7738a8b85992bf9c0cd33461f7a6094 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Fri, 21 Jun 2024 11:12:06 +0200 Subject: [PATCH 02/15] fix --- src/Artesian/MarketData/_Dto/DeleteData.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artesian/MarketData/_Dto/DeleteData.py b/src/Artesian/MarketData/_Dto/DeleteData.py index ba8df36..b0054aa 100644 --- a/src/Artesian/MarketData/_Dto/DeleteData.py +++ b/src/Artesian/MarketData/_Dto/DeleteData.py @@ -14,7 +14,7 @@ class DeleteData: rangeStart: LocalDateTime start of the range to be deleted rangeEnd: LocalDateTime end of the range to be deleted timezone: Timezone of the delete range. For DateSerie must be - the OriginalTimezone of the Serie. In case null or empty + the OriginalTimezone of the Serie. In case null or empty the default is CET for TimeSerie and OriginalTimezone for DateSerie product: The list of Product. Only *, is special character for 'delete all products in the range' From a5eef82dd292ec7d9a6b6ee35c0091e0cc9e762c Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Fri, 21 Jun 2024 17:42:09 +0200 Subject: [PATCH 03/15] fix --- src/Artesian/MarketData/_Dto/DeleteData.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Artesian/MarketData/_Dto/DeleteData.py b/src/Artesian/MarketData/_Dto/DeleteData.py index b0054aa..f3ac7ce 100644 --- a/src/Artesian/MarketData/_Dto/DeleteData.py +++ b/src/Artesian/MarketData/_Dto/DeleteData.py @@ -13,9 +13,9 @@ class DeleteData: ID: the MarketDataIdentifier rangeStart: LocalDateTime start of the range to be deleted rangeEnd: LocalDateTime end of the range to be deleted - timezone: Timezone of the delete range. For DateSerie must be - the OriginalTimezone of the Serie. In case null or empty - the default is CET for TimeSerie and OriginalTimezone for DateSerie + timezone: For DateSeries if provided must be equal to MarketData + OrignalTimezone Default:MarketData OrignalTimezone. + For TimeSeries Default:CET product: The list of Product. Only *, is special character for 'delete all products in the range' version: the Version to operate on From 439eba0522372abde3f4745cfe94dd2f778a4290 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Fri, 21 Jun 2024 17:42:22 +0200 Subject: [PATCH 04/15] fix --- src/Artesian/MarketData/_Dto/DeleteData.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artesian/MarketData/_Dto/DeleteData.py b/src/Artesian/MarketData/_Dto/DeleteData.py index f3ac7ce..8d5e743 100644 --- a/src/Artesian/MarketData/_Dto/DeleteData.py +++ b/src/Artesian/MarketData/_Dto/DeleteData.py @@ -15,7 +15,7 @@ class DeleteData: rangeEnd: LocalDateTime end of the range to be deleted timezone: For DateSeries if provided must be equal to MarketData OrignalTimezone Default:MarketData OrignalTimezone. - For TimeSeries Default:CET + For TimeSeries Default:CET product: The list of Product. Only *, is special character for 'delete all products in the range' version: the Version to operate on From b902a418b5125e29bd7eccb9c2fdf1c0a10a61d9 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Mon, 1 Jul 2024 09:43:36 +0200 Subject: [PATCH 05/15] added None in timezone delete parameter --- src/Artesian/MarketData/_Dto/DeleteData.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artesian/MarketData/_Dto/DeleteData.py b/src/Artesian/MarketData/_Dto/DeleteData.py index 8d5e743..69c967b 100644 --- a/src/Artesian/MarketData/_Dto/DeleteData.py +++ b/src/Artesian/MarketData/_Dto/DeleteData.py @@ -26,9 +26,9 @@ class DeleteData: """ ID: MarketDataIdentifier - timezone: str rangeStart: datetime rangeEnd: datetime + timezone: str | None = None product: Optional[List[str]] = None version: Optional[datetime] = None deferCommandExecution: bool = False From 1f95c132080966e31d3dd41f2d89ddfd6577f463 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Mon, 1 Jul 2024 09:46:01 +0200 Subject: [PATCH 06/15] fix --- tests/TestMarketDataDeleteData.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/TestMarketDataDeleteData.py b/tests/TestMarketDataDeleteData.py index 33f42cd..7e942af 100644 --- a/tests/TestMarketDataDeleteData.py +++ b/tests/TestMarketDataDeleteData.py @@ -34,7 +34,7 @@ async def test_deleteDateSerie(self): } delete = DeleteData( MarketDataIdentifier("PROVIDER", "CURVENAME"), - "CET", + timezone="CET", rangeStart=datetime(2020, 1, 1, 1), rangeEnd=datetime(2020, 1, 3, 1), ) @@ -65,7 +65,7 @@ async def test_deleteDateSerieWithProduct(self): } delete = DeleteData( MarketDataIdentifier("PROVIDER", "CURVENAME"), - "CET", + timezone="CET", product=["Jan-15"], rangeStart=datetime(2020, 1, 1, 1), rangeEnd=datetime(2020, 1, 3, 1), @@ -97,7 +97,7 @@ async def test_deleteVersionedSerie(self): } delete = DeleteData( MarketDataIdentifier("PROVIDER", "CURVENAME"), - "CET", + timezone="CET", rangeStart=datetime(2020, 1, 1, 1), rangeEnd=datetime(2020, 1, 3, 1), version=datetime(2020, 1, 1, 1) From ad5ed6354a58ba1ee6ec6f8ffd32052e0fed4ece Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Mon, 1 Jul 2024 09:50:21 +0200 Subject: [PATCH 07/15] fix --- src/Artesian/MarketData/_Dto/DeleteData.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artesian/MarketData/_Dto/DeleteData.py b/src/Artesian/MarketData/_Dto/DeleteData.py index 69c967b..2605837 100644 --- a/src/Artesian/MarketData/_Dto/DeleteData.py +++ b/src/Artesian/MarketData/_Dto/DeleteData.py @@ -28,7 +28,7 @@ class DeleteData: ID: MarketDataIdentifier rangeStart: datetime rangeEnd: datetime - timezone: str | None = None + timezone: Optional[str] = None product: Optional[List[str]] = None version: Optional[datetime] = None deferCommandExecution: bool = False From 67b3f1511303b112c53160aa25e0f4b1158ae597 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Mon, 1 Jul 2024 12:32:14 +0200 Subject: [PATCH 08/15] fix --- .github/workflows/python-tests.yml | 118 ++++++++++++++--------------- 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 1a3bd92..46bdb23 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,87 +1,85 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Artesian SDK Python +name: Artesian SDK Python on: push: - branches: [ master ] - tags: - - 'v[0-9]+\.[0-9]+\.[0-9]+' + branches: [master] + tags: + - 'v[0-9]+\.[0-9]+\.[0-9]+' pull_request: - branches: [ master ] + branches: [master] jobs: build: - runs-on: ${{ matrix.os }} - + strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - os: ['ubuntu-latest', 'windows-latest', 'macos-latest'] + python-version: ["3.8", "3.9", "3.10", "3.11"] + os: ["ubuntu-latest", "windows-latest", "macos-latest"] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e ".[dev]" + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" - - name: Run flake8 - run: | - flake8 . + - name: Run flake8 + run: | + flake8 . - - uses: jordemort/action-pyright@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - reporter: github-check - lib: - level: warning - filter_mode: file + - uses: jordemort/action-pyright@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-check + lib: + level: warning + filter_mode: file + reviewdog_flags: false - - name: Test Pytest - run: | - pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml + - name: Test Pytest + run: | + pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml - - name: Upload pytest test results - uses: actions/upload-artifact@v3 - with: - name: pytest-results-${{ matrix.python-version }} - path: junit/test-results-${{ matrix.python-version }}.xml - # Use always() to always run this step to publish test results when there are test failures - if: ${{ always() }} + - name: Upload pytest test results + uses: actions/upload-artifact@v3 + with: + name: pytest-results-${{ matrix.python-version }} + path: junit/test-results-${{ matrix.python-version }}.xml + # Use always() to always run this step to publish test results when there are test failures + if: ${{ always() }} publish: if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) runs-on: ubuntu-latest needs: build env: - python-version: '3.11' + python-version: "3.11" steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python ${{ env.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ env.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install build - - name: Build package - run: | - python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - - + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python ${{ env.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ env.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build + - name: Build package + run: | + python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} From 0ca8ac0c0802cd7b5477fe96b37948685610ee1d Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Mon, 1 Jul 2024 12:38:01 +0200 Subject: [PATCH 09/15] fix --- .github/workflows/python-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 46bdb23..7ed51ec 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -42,7 +42,7 @@ jobs: lib: level: warning filter_mode: file - reviewdog_flags: false + permissions: pull-requests: write - name: Test Pytest run: | From c2127090a1a51faece374b0d4f210b56333a5892 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Mon, 1 Jul 2024 12:52:05 +0200 Subject: [PATCH 10/15] fix --- .github/workflows/python-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 7ed51ec..a818deb 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -42,7 +42,6 @@ jobs: lib: level: warning filter_mode: file - permissions: pull-requests: write - name: Test Pytest run: | From bf9f2517301933227cf5633387742006cb7c9cdd Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Thu, 4 Jul 2024 09:46:35 +0200 Subject: [PATCH 11/15] commented reviewdog --- .github/workflows/python-tests.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index a818deb..6fee30a 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -35,13 +35,14 @@ jobs: run: | flake8 . - - uses: jordemort/action-pyright@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - reporter: github-check - lib: - level: warning - filter_mode: file + # commented because it is failing under windows for reviewdog version missing + # - uses: jordemort/action-pyright@v1 + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # reporter: github-check + # lib: + # level: warning + # filter_mode: file - name: Test Pytest run: | From d4ca3f1d51754d05db6a1cbf0aab2b45cd3ab13a Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Thu, 4 Jul 2024 10:57:22 +0200 Subject: [PATCH 12/15] commented action-pyright under windows --- .github/workflows/python-tests.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 6fee30a..8bfd2e8 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -35,14 +35,18 @@ jobs: run: | flake8 . - # commented because it is failing under windows for reviewdog version missing - # - uses: jordemort/action-pyright@v1 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # reporter: github-check - # lib: - # level: warning - # filter_mode: file + # Execute jordemort/action-pyright only into Ubuntu and macOS. + # windows started to fail for reviewdog not found. issue opened + # https://github.com/jordemort/action-pyright/issues/51 + - name: Run Pyright + if: matrix.os != 'windows-latest' + uses: jordemort/action-pyright@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-check + lib: + level: warning + filter_mode: file - name: Test Pytest run: | From d8916d588c3abb1696037b49b0275b22eb6f8aac Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Thu, 4 Jul 2024 17:39:40 +0200 Subject: [PATCH 13/15] fix: added Delete tests without timezone ref: #17577 --- samples/TestWriteDataAndDeleteActual.py | 25 +++++- samples/TestWriteDataAndDeleteAuction.py | 23 +++++- samples/TestWriteDataAndDeleteBidAsk.py | 25 +++++- samples/TestWriteDataAndDeleteMas.py | 25 +++++- samples/TestWriteDataAndDeleteVersioned.py | 26 ++++++- tests/TestMarketDataDeleteData.py | 88 ++++++++++++++++++++++ 6 files changed, 202 insertions(+), 10 deletions(-) diff --git a/samples/TestWriteDataAndDeleteActual.py b/samples/TestWriteDataAndDeleteActual.py index 4300e42..e20360f 100644 --- a/samples/TestWriteDataAndDeleteActual.py +++ b/samples/TestWriteDataAndDeleteActual.py @@ -45,7 +45,7 @@ print(res) -#Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 +# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 deleteData = Artesian.MarketData.DeleteData( ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), timezone="CET", @@ -66,5 +66,26 @@ print(res) -#Delete the curve completely + +# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 without Timezone +deleteData = Artesian.MarketData.DeleteData( + ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), + rangeStart=datetime(2020, 1, 1, 6), + rangeEnd=datetime(2020, 1, 1, 18), +) + +mkdservice.deleteData(deleteData) + +res = ( + query.createActual() + .forMarketData([registered.marketDataId]) + .inAbsoluteDateRange("2020-01-01", "2020-01-02") + .inTimeZone("CET") + .inGranularity(Granularity.Hour) + .execute() +) + +print(res) + +# Delete the curve completely mkdservice.deleteMarketData(registered.marketDataId) diff --git a/samples/TestWriteDataAndDeleteAuction.py b/samples/TestWriteDataAndDeleteAuction.py index 74c56c6..40c9fac 100644 --- a/samples/TestWriteDataAndDeleteAuction.py +++ b/samples/TestWriteDataAndDeleteAuction.py @@ -58,7 +58,7 @@ print(res) -#Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 +# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 deleteData = Artesian.MarketData.DeleteData( ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), timezone="CET", @@ -78,5 +78,24 @@ print(res) -#Delete the curve completely +# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 without Timezone +deleteData = Artesian.MarketData.DeleteData( + ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), + rangeStart=datetime(2020, 1, 1, 6), + rangeEnd=datetime(2020, 1, 1, 18), +) + +mkdservice.deleteData(deleteData) + +res = ( + query.createAuction() + .forMarketData([registered.marketDataId]) + .inAbsoluteDateRange("2020-01-01", "2020-01-02") + .inTimeZone("CET") + .execute() +) + +print(res) + +# Delete the curve completely mkdservice.deleteMarketData(registered.marketDataId) diff --git a/samples/TestWriteDataAndDeleteBidAsk.py b/samples/TestWriteDataAndDeleteBidAsk.py index 46665a0..52ebace 100644 --- a/samples/TestWriteDataAndDeleteBidAsk.py +++ b/samples/TestWriteDataAndDeleteBidAsk.py @@ -56,7 +56,7 @@ print(res) -#Delete data between 2020-01-01 6am and 2020-01-01 6pm for product Feb-18 +# Delete data between 2020-01-01 6am and 2020-01-01 6pm for product Feb-18 deleteData = Artesian.MarketData.DeleteData( ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), timezone="CET", @@ -78,5 +78,26 @@ print(res) -#Delete the curve completely +# Delete data between 2020-01-01 6am and 2020-01-01 6pm for product Feb-18 without Timezone +deleteData = Artesian.MarketData.DeleteData( + ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), + rangeStart=datetime(2020, 1, 1, 6), + rangeEnd=datetime(2020, 1, 1, 18), + product=["Feb-20"] +) + +mkdservice.deleteData(deleteData) + +res = ( + query.createBidAsk() + .forMarketData([registered.marketDataId]) + .inAbsoluteDateRange("2020-01-01", "2020-01-31") + .forProducts(["Feb-20", "Mar-20"]) + .inTimeZone("CET") + .execute() +) + +print(res) + +# Delete the curve completely mkdservice.deleteMarketData(registered.marketDataId) \ No newline at end of file diff --git a/samples/TestWriteDataAndDeleteMas.py b/samples/TestWriteDataAndDeleteMas.py index bf902c1..35d1cbf 100644 --- a/samples/TestWriteDataAndDeleteMas.py +++ b/samples/TestWriteDataAndDeleteMas.py @@ -56,7 +56,7 @@ print(res) -#Delete data with product Feb-20 between 2020-01-01 and 2020-01-03 +# Delete data with product Feb-20 between 2020-01-01 and 2020-01-03 deleteData = Artesian.MarketData.DeleteData( ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), timezone="CET", @@ -78,5 +78,26 @@ print(res) -#Delete the curve completely +# Delete data with product Feb-20 between 2020-01-01 and 2020-01-03 without Timezone +deleteData = Artesian.MarketData.DeleteData( + ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), + rangeStart=datetime(2020, 1, 1, 0), + rangeEnd=datetime(2020, 1, 3, 0), + product=["Feb-20"] +) + +mkdservice.deleteData(deleteData) + +res = ( + query.createMarketAssessment() + .forMarketData([registered.marketDataId]) + .inAbsoluteDateRange("2020-01-01", "2020-01-02") + .forProducts(["Feb-20", "Mar-20"]) + .inTimeZone("CET") + .execute() +) + +print(res) + +# Delete the curve completely mkdservice.deleteMarketData(registered.marketDataId) diff --git a/samples/TestWriteDataAndDeleteVersioned.py b/samples/TestWriteDataAndDeleteVersioned.py index 544949f..d0e042a 100644 --- a/samples/TestWriteDataAndDeleteVersioned.py +++ b/samples/TestWriteDataAndDeleteVersioned.py @@ -50,7 +50,7 @@ print(res) -#Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 +# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 deleteData = Artesian.MarketData.DeleteData( ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), timezone="CET", @@ -73,5 +73,27 @@ print(res) -#Delete the curve completely +# Delete data between 2020-01-01 06:00 and 2020-01-01 18:00 without Timezone +deleteData = Artesian.MarketData.DeleteData( + ID=Artesian.MarketData.MarketDataIdentifier(registered.providerName, registered.marketDataName), + rangeStart=datetime(2020, 1, 1, 6), + rangeEnd=datetime(2020, 1, 1, 18), + version=testVersion +) + +mkdservice.deleteData(deleteData) + +res = ( + query.createVersioned() + .forMarketData([registered.marketDataId]) + .inAbsoluteDateRange("2020-01-01", "2020-01-02") + .inTimeZone("CET") + .inGranularity(Granularity.Hour) + .forVersion("2020-01-01T12:00:00") + .execute() +) + +print(res) + +# Delete the curve completely mkdservice.deleteMarketData(registered.marketDataId) diff --git a/tests/TestMarketDataDeleteData.py b/tests/TestMarketDataDeleteData.py index 7e942af..8a993c0 100644 --- a/tests/TestMarketDataDeleteData.py +++ b/tests/TestMarketDataDeleteData.py @@ -53,6 +53,34 @@ async def test_deleteDateSerie(self): self.assertEqual(len(rsps.calls), 1) + async def test_deleteDateSerieWithoutTimezone(self): + expectedJson = { + "ID": {"Provider": "PROVIDER", "Name": "CURVENAME"}, + "RangeStart": "2020-01-01T01:00:00.000000", + "RangeEnd": "2020-01-03T01:00:00.000000", + "DeferCommandExecution": False, + "DeferDataGeneration": True, + } + delete = DeleteData( + MarketDataIdentifier("PROVIDER", "CURVENAME"), + rangeStart=datetime(2020, 1, 1, 1), + rangeEnd=datetime(2020, 1, 3, 1), + ) + ser = artesianJsonSerialize(delete) + self.assertEqual(ser, expectedJson) + + with responses.RequestsMock() as rsps: + rsps.add( + "POST", + self.__baseurl + "/marketdata/deletedata", + match=[responses.matchers.json_params_matcher(expectedJson)], + status=200, + ) + + await self.__service.deleteDataAsync(delete) + + self.assertEqual(len(rsps.calls), 1) + async def test_deleteDateSerieWithProduct(self): expectedJson = { "ID": {"Provider": "PROVIDER", "Name": "CURVENAME"}, @@ -85,6 +113,36 @@ async def test_deleteDateSerieWithProduct(self): self.assertEqual(len(rsps.calls), 1) + async def test_deleteDateSerieWithProductWithoutTimezone(self): + expectedJson = { + "ID": {"Provider": "PROVIDER", "Name": "CURVENAME"}, + "Product": ["Jan-15"], + "RangeStart": "2020-01-01T01:00:00.000000", + "RangeEnd": "2020-01-03T01:00:00.000000", + "DeferCommandExecution": False, + "DeferDataGeneration": True, + } + delete = DeleteData( + MarketDataIdentifier("PROVIDER", "CURVENAME"), + product=["Jan-15"], + rangeStart=datetime(2020, 1, 1, 1), + rangeEnd=datetime(2020, 1, 3, 1), + ) + ser = artesianJsonSerialize(delete) + self.assertEqual(ser, expectedJson) + + with responses.RequestsMock() as rsps: + rsps.add( + "POST", + self.__baseurl + "/marketdata/deletedata", + match=[responses.matchers.json_params_matcher(expectedJson)], + status=200, + ) + + await self.__service.deleteDataAsync(delete) + + self.assertEqual(len(rsps.calls), 1) + async def test_deleteVersionedSerie(self): expectedJson = { "ID": {"Provider": "PROVIDER", "Name": "CURVENAME"}, @@ -116,3 +174,33 @@ async def test_deleteVersionedSerie(self): await self.__service.deleteDataAsync(delete) self.assertEqual(len(rsps.calls), 1) + + async def test_deleteVersionedSerieWithoutTimezone(self): + expectedJson = { + "ID": {"Provider": "PROVIDER", "Name": "CURVENAME"}, + "Version": "2020-01-01T01:00:00.000000", + "RangeStart": "2020-01-01T01:00:00.000000", + "RangeEnd": "2020-01-03T01:00:00.000000", + "DeferCommandExecution": False, + "DeferDataGeneration": True, + } + delete = DeleteData( + MarketDataIdentifier("PROVIDER", "CURVENAME"), + rangeStart=datetime(2020, 1, 1, 1), + rangeEnd=datetime(2020, 1, 3, 1), + version=datetime(2020, 1, 1, 1) + ) + ser = artesianJsonSerialize(delete) + self.assertEqual(ser, expectedJson) + + with responses.RequestsMock() as rsps: + rsps.add( + "POST", + self.__baseurl + "/marketdata/deletedata", + match=[responses.matchers.json_params_matcher(expectedJson)], + status=200, + ) + + await self.__service.deleteDataAsync(delete) + + self.assertEqual(len(rsps.calls), 1) From 83e105e173ca476cf37414d773a1eb416b7758e1 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Thu, 4 Jul 2024 17:48:20 +0200 Subject: [PATCH 14/15] fix --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index befff94..fcd4b85 100644 --- a/README.md +++ b/README.md @@ -787,7 +787,6 @@ auctionRows = MarketData.UpsertData(MarketData.MarketDataIdentifier('PROVIDER', ``` - ## Delete Data in Artesian Using the MarketDataService is possible to delete MarketData and its curves. @@ -808,7 +807,7 @@ mkservice.deleteMarketData(100042422) ``` -Depending on the Type of the MarketData, the DeletData should be composed as per example below. +Depending on the Type of the MarketData, the DeletData should be composed as per example below. The timezone is optional: for DateSeries if provided must be equal to MarketData OrignalTimezone Default:MarketData OrignalTimezone. For TimeSeries Default:CET ### Delete Data in an Actual Time Series From bff5d7b17b3d38ff421fce858cca17affe1e3742 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Fri, 5 Jul 2024 09:01:18 +0200 Subject: [PATCH 15/15] fix comments --- README.md | 2 +- src/Artesian/MarketData/_Dto/DeleteData.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcd4b85..2cfafa0 100644 --- a/README.md +++ b/README.md @@ -807,7 +807,7 @@ mkservice.deleteMarketData(100042422) ``` -Depending on the Type of the MarketData, the DeletData should be composed as per example below. The timezone is optional: for DateSeries if provided must be equal to MarketData OrignalTimezone Default:MarketData OrignalTimezone. For TimeSeries Default:CET +Depending on the Type of the MarketData, the DeletData should be composed as per example below. The timezone is optional: for DateSeries if provided must be equal to MarketData OriginalTimezone Default:MarketData OriginalTimezone. For TimeSeries Default:CET ### Delete Data in an Actual Time Series diff --git a/src/Artesian/MarketData/_Dto/DeleteData.py b/src/Artesian/MarketData/_Dto/DeleteData.py index 2605837..5b1addb 100644 --- a/src/Artesian/MarketData/_Dto/DeleteData.py +++ b/src/Artesian/MarketData/_Dto/DeleteData.py @@ -14,7 +14,7 @@ class DeleteData: rangeStart: LocalDateTime start of the range to be deleted rangeEnd: LocalDateTime end of the range to be deleted timezone: For DateSeries if provided must be equal to MarketData - OrignalTimezone Default:MarketData OrignalTimezone. + OriginalTimezone Default:MarketData OriginalTimezone. For TimeSeries Default:CET product: The list of Product. Only *, is special character for 'delete all products in the range'