Skip to content

Commit cc4eb28

Browse files
Realtime Fixes
1 parent 58fba22 commit cc4eb28

5 files changed

Lines changed: 96 additions & 25 deletions

File tree

.github/release-drafter.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
4+
categories:
5+
- title: '🚀 Features'
6+
labels:
7+
- 'feature'
8+
- 'enhancement'
9+
- 'feat'
10+
- title: '🐛 Bug Fixes'
11+
labels:
12+
- 'bug'
13+
- 'fix'
14+
- title: '🧰 Maintenance'
15+
labels:
16+
- 'chore'
17+
- 'maintenance'
18+
- 'refactor'
19+
20+
change-template: '- $TITLE (#$NUMBER)'
21+
22+
no-changes-template: '- No significant changes.'
23+
24+
version-resolver:
25+
major:
26+
labels:
27+
- 'breaking'
28+
minor:
29+
labels:
30+
- 'feature'
31+
- 'enhancement'
32+
- 'feat'
33+
patch:
34+
labels:
35+
- 'bug'
36+
- 'fix'
37+
- 'chore'
38+
- 'maintenance'
39+
- 'refactor'
40+
41+
exclude-labels:
42+
- 'skip-changelog'
43+
44+
template: |
45+
## Changes
46+
$CHANGES

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
pull_request:
8+
types: [closed]
9+
10+
jobs:
11+
build-and-publish:
12+
if: startsWith(github.ref, 'refs/tags/v')
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install build tools
23+
run: |
24+
python -m pip install --upgrade pip build
25+
26+
- name: Build package
27+
run: python -m build
28+
29+
- name: Publish to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
password: ${{ secrets.PYPI_API_TOKEN }}
33+
34+
update-release-draft:
35+
if: github.event.pull_request.merged == true
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: release-drafter/release-drafter@v6
39+
with:
40+
config-name: release-drafter.yml
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

projectx_sdk/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ProjectXClient:
3333
session management, and request routing.
3434
"""
3535

36-
# Map of environment names to base URLs
36+
# Map of environment names to base URLs (only new endpoints)
3737
ENVIRONMENT_URLS = {
3838
"alphaticks": "https://api.alphaticks.projectx.com",
3939
"blueguardian": "https://api.blueguardianfutures.projectx.com",
@@ -52,7 +52,7 @@ class ProjectXClient:
5252
"demo": "https://gateway-api-demo.s2f.projectx.com",
5353
}
5454

55-
# Map of environment names to user hub URLs
55+
# Map of environment names to user hub URLs (only new endpoints)
5656
USER_HUB_URLS = {
5757
"alphaticks": "https://rtc.alphaticks.projectx.com/hubs/user",
5858
"blueguardian": "https://rtc.blueguardianfutures.projectx.com/hubs/user",
@@ -71,7 +71,7 @@ class ProjectXClient:
7171
"demo": "https://gateway-api-demo.s2f.projectx.com/hubs/user",
7272
}
7373

74-
# Map of environment names to market hub URLs
74+
# Map of environment names to market hub URLs (only new endpoints)
7575
MARKET_HUB_URLS = {
7676
"alphaticks": "https://rtc.alphaticks.projectx.com/hubs/market",
7777
"blueguardian": "https://rtc.blueguardianfutures.projectx.com/hubs/market",

projectx_sdk/realtime/__init__.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def reconnect_subscriptions(self):
9494
self.market.reconnect_subscriptions()
9595

9696

97-
# Class for backward compatibility with tests
9897
class RealtimeService:
9998
"""
10099
Legacy service class for real-time communication.
@@ -113,18 +112,8 @@ def __init__(self, client):
113112
self._client = client
114113
self._user = None
115114
self._market = None
116-
117-
# For backward compatibility with tests, always set base_hub_url
118-
self._base_hub_url = f"wss://gateway-rtc-{client.environment}.s2f.projectx.com"
119-
120-
# Check if we should use the new URL pattern from client.USER_HUB_URLS
121-
if hasattr(client, "USER_HUB_URLS") and client.environment in client.USER_HUB_URLS:
122-
self._user_hub_url = client.USER_HUB_URLS.get(client.environment)
123-
self._market_hub_url = client.MARKET_HUB_URLS.get(client.environment)
124-
else:
125-
# Fallback to old URL pattern
126-
self._user_hub_url = None
127-
self._market_hub_url = None
115+
self._user_hub_url = client.USER_HUB_URLS.get(client.environment)
116+
self._market_hub_url = client.MARKET_HUB_URLS.get(client.environment)
128117

129118
@property
130119
def user(self):
@@ -135,10 +124,7 @@ def user(self):
135124
UserHub: The user hub instance
136125
"""
137126
if self._user is None:
138-
if self._user_hub_url:
139-
self._user = UserHub(self._client, self._base_hub_url, self._user_hub_url)
140-
else:
141-
self._user = UserHub(self._client, self._base_hub_url)
127+
self._user = UserHub(self._client, None, self._user_hub_url)
142128
return self._user
143129

144130
@property
@@ -152,10 +138,7 @@ def market(self):
152138
if self._market is None:
153139
from projectx_sdk.realtime.market_hub import MarketHub
154140

155-
if self._market_hub_url:
156-
self._market = MarketHub(self._client, self._base_hub_url, self._market_hub_url)
157-
else:
158-
self._market = MarketHub(self._client, self._base_hub_url)
141+
self._market = MarketHub(self._client, None, self._market_hub_url)
159142
return self._market
160143

161144
def start(self):

tests/test_realtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_init(self, authenticated_client):
1616
assert service._client == authenticated_client
1717
assert service._user is None
1818
assert service._market is None
19-
assert service._base_hub_url is not None
19+
# _base_hub_url is no longer used or required
2020

2121
def test_user_hub_lazy_loading(self, authenticated_client):
2222
"""Test that the user hub is lazily loaded."""

0 commit comments

Comments
 (0)