From 4108257f6a9227fbda5cc4d3e274ad3a4ed82fea Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Tue, 18 Aug 2026 16:25:25 +0100 Subject: [PATCH 1/3] delete unused lint config --- .pre-commit-config.yaml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 3f1eb79..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,15 +0,0 @@ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.1.0 - hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace -- repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 - hooks: - - id: flake8 -- repo: https://github.com/psf/black - rev: 19.10b0 - hooks: - - id: black From 22c44aa5200fa859febce232f44d574010c9921e Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Tue, 18 Aug 2026 16:25:52 +0100 Subject: [PATCH 2/3] ignore config file, IDEA project file --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 80dffa3..c8de682 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ target/ # IntelliJ / PyCharm .idea/ +*.iml # pipenv Pipfile @@ -74,6 +75,7 @@ Pipfile.lock .github/.env .python-version .env/ +trading_ig_config.py .vscode From 81c8fc712f330abada184138f3a0ec73af34c4c7 Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Tue, 18 Aug 2026 16:26:54 +0100 Subject: [PATCH 3/3] tidy up in teardown. stop distance tweaks, enlarge search window for activities --- tests/test_integration.py | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 41c41d2..340ed00 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -70,6 +70,39 @@ def ig_service(request, retrying): pytest.fail("Integration test currently only works with a spreadbet account") yield ig_service + + # delete any watchlists created by test + wls_dict = ig_service.fetch_all_watchlists().to_dict(orient="records") + for watchlist in wls_dict: + if watchlist["name"].startswith("test_"): + print(f"Deleting watchlist with id {watchlist['id']}") + ig_service.delete_watchlist(watchlist["id"]) + + # delete any orders + wos_dict = ig_service.fetch_working_orders().to_dict(orient="records") + for working_order in wos_dict: + print(f"Deleting working order with dealId {working_order['dealId']}") + ig_service.delete_working_order(working_order["dealId"]) + + # close any positions + ops_dict = ig_service.fetch_open_positions().to_dict(orient="records") + for position in ops_dict: + if position["marketStatus"] == "TRADEABLE": + close_dir = "SELL" if position["direction"] == "BUY" else "BUY" + print(f"Closing position with dealId {position['dealId']}") + result = ig_service.close_open_position( + deal_id=position["dealId"], + direction=close_dir, + epic=None, + expiry=position["expiry"], + level=None, + order_type="MARKET", + quote_id=None, + size=position["size"], + session=None, + ) + print(f"Close result for {position['dealId']}: {result['dealStatus']}") + ig_service.logout() @@ -211,7 +244,7 @@ def test_fetch_account_activity_old(self, ig_service: IGService): assert response.shape[0] == 0 def test_fetch_account_activity_fiql(self, ig_service: IGService): - to_date = datetime.now(timezone.utc) - timedelta(days=30) + to_date = datetime.now(timezone.utc) - timedelta(hours=1) from_date = to_date - timedelta(days=120) response = ig_service.fetch_account_activity( from_date=from_date, to_date=to_date, fiql_filter="channel==PUBLIC_WEB_API" @@ -710,7 +743,7 @@ def test_create_open_position(self, ig_service: IGService): offer = market_info.snapshot.offer update_v1_result = ig_service.update_open_position( limit_level=None, - stop_level=offer - (5 * min_stop_limit), + stop_level=offer - (10 * min_stop_limit), deal_id=open_result["dealId"], version="1", ) @@ -722,7 +755,7 @@ def test_create_open_position(self, ig_service: IGService): offer = market_info.snapshot.offer update_v2_result = ig_service.update_open_position( limit_level=None, - stop_level=offer - (8 * min_stop_limit), + stop_level=offer - (15 * min_stop_limit), deal_id=open_result["dealId"], trailing_stop=True, trailing_stop_distance=(2 * min_cr_limit),