realmarketapi-python-sdk-beta 0.1.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Phideround
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: realmarketapi-python-sdk-beta
3
+ Version: 0.1.0b1
4
+ Summary: RealMarketAPI Python SDK beta
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: httpx>=0.27.0
9
+ Requires-Dist: websockets>=12.0
10
+ Dynamic: license-file
11
+
12
+ # RealMarketAPI Python SDK (Beta)
13
+
14
+ Official beta Python SDK for RealMarketAPI REST and WebSocket market data endpoints.
15
+
16
+ Website: [https://realmarketapi.com/](https://realmarketapi.com/)
17
+
18
+ ## Why use this SDK
19
+
20
+ - Thin Python wrapper for RealMarketAPI HTTP and streaming APIs.
21
+ - Simple class-based client for request/response usage.
22
+ - Async WebSocket streams with automatic reconnect behavior.
23
+ - Small dependency footprint (`httpx`, `websockets`).
24
+
25
+ ## Requirements
26
+
27
+ - Python 3.9+
28
+ - RealMarketAPI API key
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install realmarketapi-python-sdk-beta
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ ### REST client
39
+
40
+ ```python
41
+ from realmarketapi_sdk import RealMarketApiClient
42
+
43
+ client = RealMarketApiClient(api_key="YOUR_API_KEY")
44
+
45
+ try:
46
+ price = client.get_price("EURUSD", "M1")
47
+ print("Close:", price.get("closePrice"))
48
+ finally:
49
+ client.close()
50
+ ```
51
+
52
+ ### WebSocket client
53
+
54
+ ```python
55
+ import asyncio
56
+ from realmarketapi_sdk import RealMarketApiWebSocket
57
+
58
+ ws = RealMarketApiWebSocket(api_key="YOUR_API_KEY")
59
+
60
+ async def main() -> None:
61
+ async for tick in ws.stream_price("BTCUSDT", "M1"):
62
+ print(tick)
63
+
64
+ asyncio.run(main())
65
+ ```
66
+
67
+ ## REST API methods
68
+
69
+ All REST methods return a Python `dict` parsed from JSON and include your API key as query parameter.
70
+
71
+ ### `get_price(symbol_code, time_frame)`
72
+
73
+ Example:
74
+
75
+ ```python
76
+ price = client.get_price("EURUSD", "M1")
77
+ ```
78
+
79
+ Example response payload:
80
+
81
+ ```json
82
+ {
83
+ "symbolCode": "EURUSD",
84
+ "timeFrame": "M1",
85
+ "openPrice": 1.07874,
86
+ "highPrice": 1.07882,
87
+ "lowPrice": 1.07868,
88
+ "closePrice": 1.07879,
89
+ "openTime": "2026-05-21T09:12:00Z"
90
+ }
91
+ ```
92
+
93
+ ### `get_candles(symbol_code, time_frame)`
94
+
95
+ Example:
96
+
97
+ ```python
98
+ candles = client.get_candles("BTCUSDT", "M5")
99
+ ```
100
+
101
+ Example response payload:
102
+
103
+ ```json
104
+ {
105
+ "symbolCode": "BTCUSDT",
106
+ "timeFrame": "M5",
107
+ "candles": [
108
+ {
109
+ "openTime": "2026-05-21T09:10:00Z",
110
+ "openPrice": 68620.3,
111
+ "highPrice": 68690.1,
112
+ "lowPrice": 68588.7,
113
+ "closePrice": 68655.8,
114
+ "volume": 128.42
115
+ }
116
+ ]
117
+ }
118
+ ```
119
+
120
+ ### `get_history(symbol_code, start_time, end_time, page_number=1, page_size=20)`
121
+
122
+ Example:
123
+
124
+ ```python
125
+ history = client.get_history(
126
+ symbol_code="EURUSD",
127
+ start_time="2026-05-20T00:00:00Z",
128
+ end_time="2026-05-21T00:00:00Z",
129
+ page_number=1,
130
+ page_size=20,
131
+ )
132
+ ```
133
+
134
+ Example response payload:
135
+
136
+ ```json
137
+ {
138
+ "pageNumber": 1,
139
+ "pageSize": 20,
140
+ "totalPages": 14,
141
+ "items": [
142
+ {
143
+ "openTime": "2026-05-20T00:00:00Z",
144
+ "openPrice": 1.07913,
145
+ "highPrice": 1.07942,
146
+ "lowPrice": 1.07898,
147
+ "closePrice": 1.07920,
148
+ "volume": 241.11
149
+ }
150
+ ]
151
+ }
152
+ ```
153
+
154
+ ### `get_symbols()`
155
+
156
+ Example:
157
+
158
+ ```python
159
+ symbols = client.get_symbols()
160
+ ```
161
+
162
+ Example response payload:
163
+
164
+ ```json
165
+ {
166
+ "symbols": ["EURUSD", "BTCUSDT", "XAUUSD"]
167
+ }
168
+ ```
169
+
170
+ ### `get_sma(symbol_code, time_frame, period=20)`
171
+
172
+ Example:
173
+
174
+ ```python
175
+ sma = client.get_sma("EURUSD", "M15", period=50)
176
+ ```
177
+
178
+ Example response payload:
179
+
180
+ ```json
181
+ {
182
+ "symbolCode": "EURUSD",
183
+ "timeFrame": "M15",
184
+ "period": 50,
185
+ "value": 1.08024,
186
+ "openTime": "2026-05-21T09:00:00Z"
187
+ }
188
+ ```
189
+
190
+ ## WebSocket streaming methods
191
+
192
+ The WebSocket client exposes async generators and reconnects after transient failures.
193
+
194
+ ### `stream_price(symbol_code, time_frame)`
195
+
196
+ Example:
197
+
198
+ ```python
199
+ async for event in ws.stream_price("EURUSD", "M1"):
200
+ print(event)
201
+ ```
202
+
203
+ Example message payload:
204
+
205
+ ```json
206
+ {
207
+ "symbolCode": "EURUSD",
208
+ "timeFrame": "M1",
209
+ "closePrice": 1.07879,
210
+ "openTime": "2026-05-21T09:12:00Z"
211
+ }
212
+ ```
213
+
214
+ ### `stream_candles(symbol_code, time_frame)`
215
+
216
+ Example:
217
+
218
+ ```python
219
+ async for event in ws.stream_candles("BTCUSDT", "M5"):
220
+ print(event)
221
+ ```
222
+
223
+ Example message payload:
224
+
225
+ ```json
226
+ {
227
+ "symbolCode": "BTCUSDT",
228
+ "timeFrame": "M5",
229
+ "openTime": "2026-05-21T09:10:00Z",
230
+ "openPrice": 68620.3,
231
+ "highPrice": 68690.1,
232
+ "lowPrice": 68588.7,
233
+ "closePrice": 68655.8,
234
+ "volume": 128.42
235
+ }
236
+ ```
237
+
238
+ ## Error handling notes
239
+
240
+ - REST methods call `response.raise_for_status()`, so HTTP 4xx/5xx responses raise `httpx.HTTPStatusError`.
241
+ - WebSocket streams retry on connection errors using `reconnect_delay_seconds` (default `2.0`).
242
+ - Cancel the async task to stop streaming cleanly.
243
+
244
+ ## Beta scope and compatibility
245
+
246
+ - Current REST coverage: price, candles, history, symbols, SMA.
247
+ - Current WebSocket coverage: price and candles.
248
+ - This package is beta and may receive additive changes before stable `1.0`.
249
+
250
+ ## Links
251
+
252
+ - RealMarketAPI homepage: [https://realmarketapi.com/](https://realmarketapi.com/)
@@ -0,0 +1,241 @@
1
+ # RealMarketAPI Python SDK (Beta)
2
+
3
+ Official beta Python SDK for RealMarketAPI REST and WebSocket market data endpoints.
4
+
5
+ Website: [https://realmarketapi.com/](https://realmarketapi.com/)
6
+
7
+ ## Why use this SDK
8
+
9
+ - Thin Python wrapper for RealMarketAPI HTTP and streaming APIs.
10
+ - Simple class-based client for request/response usage.
11
+ - Async WebSocket streams with automatic reconnect behavior.
12
+ - Small dependency footprint (`httpx`, `websockets`).
13
+
14
+ ## Requirements
15
+
16
+ - Python 3.9+
17
+ - RealMarketAPI API key
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install realmarketapi-python-sdk-beta
23
+ ```
24
+
25
+ ## Quick start
26
+
27
+ ### REST client
28
+
29
+ ```python
30
+ from realmarketapi_sdk import RealMarketApiClient
31
+
32
+ client = RealMarketApiClient(api_key="YOUR_API_KEY")
33
+
34
+ try:
35
+ price = client.get_price("EURUSD", "M1")
36
+ print("Close:", price.get("closePrice"))
37
+ finally:
38
+ client.close()
39
+ ```
40
+
41
+ ### WebSocket client
42
+
43
+ ```python
44
+ import asyncio
45
+ from realmarketapi_sdk import RealMarketApiWebSocket
46
+
47
+ ws = RealMarketApiWebSocket(api_key="YOUR_API_KEY")
48
+
49
+ async def main() -> None:
50
+ async for tick in ws.stream_price("BTCUSDT", "M1"):
51
+ print(tick)
52
+
53
+ asyncio.run(main())
54
+ ```
55
+
56
+ ## REST API methods
57
+
58
+ All REST methods return a Python `dict` parsed from JSON and include your API key as query parameter.
59
+
60
+ ### `get_price(symbol_code, time_frame)`
61
+
62
+ Example:
63
+
64
+ ```python
65
+ price = client.get_price("EURUSD", "M1")
66
+ ```
67
+
68
+ Example response payload:
69
+
70
+ ```json
71
+ {
72
+ "symbolCode": "EURUSD",
73
+ "timeFrame": "M1",
74
+ "openPrice": 1.07874,
75
+ "highPrice": 1.07882,
76
+ "lowPrice": 1.07868,
77
+ "closePrice": 1.07879,
78
+ "openTime": "2026-05-21T09:12:00Z"
79
+ }
80
+ ```
81
+
82
+ ### `get_candles(symbol_code, time_frame)`
83
+
84
+ Example:
85
+
86
+ ```python
87
+ candles = client.get_candles("BTCUSDT", "M5")
88
+ ```
89
+
90
+ Example response payload:
91
+
92
+ ```json
93
+ {
94
+ "symbolCode": "BTCUSDT",
95
+ "timeFrame": "M5",
96
+ "candles": [
97
+ {
98
+ "openTime": "2026-05-21T09:10:00Z",
99
+ "openPrice": 68620.3,
100
+ "highPrice": 68690.1,
101
+ "lowPrice": 68588.7,
102
+ "closePrice": 68655.8,
103
+ "volume": 128.42
104
+ }
105
+ ]
106
+ }
107
+ ```
108
+
109
+ ### `get_history(symbol_code, start_time, end_time, page_number=1, page_size=20)`
110
+
111
+ Example:
112
+
113
+ ```python
114
+ history = client.get_history(
115
+ symbol_code="EURUSD",
116
+ start_time="2026-05-20T00:00:00Z",
117
+ end_time="2026-05-21T00:00:00Z",
118
+ page_number=1,
119
+ page_size=20,
120
+ )
121
+ ```
122
+
123
+ Example response payload:
124
+
125
+ ```json
126
+ {
127
+ "pageNumber": 1,
128
+ "pageSize": 20,
129
+ "totalPages": 14,
130
+ "items": [
131
+ {
132
+ "openTime": "2026-05-20T00:00:00Z",
133
+ "openPrice": 1.07913,
134
+ "highPrice": 1.07942,
135
+ "lowPrice": 1.07898,
136
+ "closePrice": 1.07920,
137
+ "volume": 241.11
138
+ }
139
+ ]
140
+ }
141
+ ```
142
+
143
+ ### `get_symbols()`
144
+
145
+ Example:
146
+
147
+ ```python
148
+ symbols = client.get_symbols()
149
+ ```
150
+
151
+ Example response payload:
152
+
153
+ ```json
154
+ {
155
+ "symbols": ["EURUSD", "BTCUSDT", "XAUUSD"]
156
+ }
157
+ ```
158
+
159
+ ### `get_sma(symbol_code, time_frame, period=20)`
160
+
161
+ Example:
162
+
163
+ ```python
164
+ sma = client.get_sma("EURUSD", "M15", period=50)
165
+ ```
166
+
167
+ Example response payload:
168
+
169
+ ```json
170
+ {
171
+ "symbolCode": "EURUSD",
172
+ "timeFrame": "M15",
173
+ "period": 50,
174
+ "value": 1.08024,
175
+ "openTime": "2026-05-21T09:00:00Z"
176
+ }
177
+ ```
178
+
179
+ ## WebSocket streaming methods
180
+
181
+ The WebSocket client exposes async generators and reconnects after transient failures.
182
+
183
+ ### `stream_price(symbol_code, time_frame)`
184
+
185
+ Example:
186
+
187
+ ```python
188
+ async for event in ws.stream_price("EURUSD", "M1"):
189
+ print(event)
190
+ ```
191
+
192
+ Example message payload:
193
+
194
+ ```json
195
+ {
196
+ "symbolCode": "EURUSD",
197
+ "timeFrame": "M1",
198
+ "closePrice": 1.07879,
199
+ "openTime": "2026-05-21T09:12:00Z"
200
+ }
201
+ ```
202
+
203
+ ### `stream_candles(symbol_code, time_frame)`
204
+
205
+ Example:
206
+
207
+ ```python
208
+ async for event in ws.stream_candles("BTCUSDT", "M5"):
209
+ print(event)
210
+ ```
211
+
212
+ Example message payload:
213
+
214
+ ```json
215
+ {
216
+ "symbolCode": "BTCUSDT",
217
+ "timeFrame": "M5",
218
+ "openTime": "2026-05-21T09:10:00Z",
219
+ "openPrice": 68620.3,
220
+ "highPrice": 68690.1,
221
+ "lowPrice": 68588.7,
222
+ "closePrice": 68655.8,
223
+ "volume": 128.42
224
+ }
225
+ ```
226
+
227
+ ## Error handling notes
228
+
229
+ - REST methods call `response.raise_for_status()`, so HTTP 4xx/5xx responses raise `httpx.HTTPStatusError`.
230
+ - WebSocket streams retry on connection errors using `reconnect_delay_seconds` (default `2.0`).
231
+ - Cancel the async task to stop streaming cleanly.
232
+
233
+ ## Beta scope and compatibility
234
+
235
+ - Current REST coverage: price, candles, history, symbols, SMA.
236
+ - Current WebSocket coverage: price and candles.
237
+ - This package is beta and may receive additive changes before stable `1.0`.
238
+
239
+ ## Links
240
+
241
+ - RealMarketAPI homepage: [https://realmarketapi.com/](https://realmarketapi.com/)
@@ -0,0 +1,17 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "realmarketapi-python-sdk-beta"
7
+ version = "0.1.0b1"
8
+ description = "RealMarketAPI Python SDK beta"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ dependencies = [
12
+ "httpx>=0.27.0",
13
+ "websockets>=12.0"
14
+ ]
15
+
16
+ [tool.setuptools]
17
+ packages = ["realmarketapi_sdk"]
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: realmarketapi-python-sdk-beta
3
+ Version: 0.1.0b1
4
+ Summary: RealMarketAPI Python SDK beta
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: httpx>=0.27.0
9
+ Requires-Dist: websockets>=12.0
10
+ Dynamic: license-file
11
+
12
+ # RealMarketAPI Python SDK (Beta)
13
+
14
+ Official beta Python SDK for RealMarketAPI REST and WebSocket market data endpoints.
15
+
16
+ Website: [https://realmarketapi.com/](https://realmarketapi.com/)
17
+
18
+ ## Why use this SDK
19
+
20
+ - Thin Python wrapper for RealMarketAPI HTTP and streaming APIs.
21
+ - Simple class-based client for request/response usage.
22
+ - Async WebSocket streams with automatic reconnect behavior.
23
+ - Small dependency footprint (`httpx`, `websockets`).
24
+
25
+ ## Requirements
26
+
27
+ - Python 3.9+
28
+ - RealMarketAPI API key
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install realmarketapi-python-sdk-beta
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ ### REST client
39
+
40
+ ```python
41
+ from realmarketapi_sdk import RealMarketApiClient
42
+
43
+ client = RealMarketApiClient(api_key="YOUR_API_KEY")
44
+
45
+ try:
46
+ price = client.get_price("EURUSD", "M1")
47
+ print("Close:", price.get("closePrice"))
48
+ finally:
49
+ client.close()
50
+ ```
51
+
52
+ ### WebSocket client
53
+
54
+ ```python
55
+ import asyncio
56
+ from realmarketapi_sdk import RealMarketApiWebSocket
57
+
58
+ ws = RealMarketApiWebSocket(api_key="YOUR_API_KEY")
59
+
60
+ async def main() -> None:
61
+ async for tick in ws.stream_price("BTCUSDT", "M1"):
62
+ print(tick)
63
+
64
+ asyncio.run(main())
65
+ ```
66
+
67
+ ## REST API methods
68
+
69
+ All REST methods return a Python `dict` parsed from JSON and include your API key as query parameter.
70
+
71
+ ### `get_price(symbol_code, time_frame)`
72
+
73
+ Example:
74
+
75
+ ```python
76
+ price = client.get_price("EURUSD", "M1")
77
+ ```
78
+
79
+ Example response payload:
80
+
81
+ ```json
82
+ {
83
+ "symbolCode": "EURUSD",
84
+ "timeFrame": "M1",
85
+ "openPrice": 1.07874,
86
+ "highPrice": 1.07882,
87
+ "lowPrice": 1.07868,
88
+ "closePrice": 1.07879,
89
+ "openTime": "2026-05-21T09:12:00Z"
90
+ }
91
+ ```
92
+
93
+ ### `get_candles(symbol_code, time_frame)`
94
+
95
+ Example:
96
+
97
+ ```python
98
+ candles = client.get_candles("BTCUSDT", "M5")
99
+ ```
100
+
101
+ Example response payload:
102
+
103
+ ```json
104
+ {
105
+ "symbolCode": "BTCUSDT",
106
+ "timeFrame": "M5",
107
+ "candles": [
108
+ {
109
+ "openTime": "2026-05-21T09:10:00Z",
110
+ "openPrice": 68620.3,
111
+ "highPrice": 68690.1,
112
+ "lowPrice": 68588.7,
113
+ "closePrice": 68655.8,
114
+ "volume": 128.42
115
+ }
116
+ ]
117
+ }
118
+ ```
119
+
120
+ ### `get_history(symbol_code, start_time, end_time, page_number=1, page_size=20)`
121
+
122
+ Example:
123
+
124
+ ```python
125
+ history = client.get_history(
126
+ symbol_code="EURUSD",
127
+ start_time="2026-05-20T00:00:00Z",
128
+ end_time="2026-05-21T00:00:00Z",
129
+ page_number=1,
130
+ page_size=20,
131
+ )
132
+ ```
133
+
134
+ Example response payload:
135
+
136
+ ```json
137
+ {
138
+ "pageNumber": 1,
139
+ "pageSize": 20,
140
+ "totalPages": 14,
141
+ "items": [
142
+ {
143
+ "openTime": "2026-05-20T00:00:00Z",
144
+ "openPrice": 1.07913,
145
+ "highPrice": 1.07942,
146
+ "lowPrice": 1.07898,
147
+ "closePrice": 1.07920,
148
+ "volume": 241.11
149
+ }
150
+ ]
151
+ }
152
+ ```
153
+
154
+ ### `get_symbols()`
155
+
156
+ Example:
157
+
158
+ ```python
159
+ symbols = client.get_symbols()
160
+ ```
161
+
162
+ Example response payload:
163
+
164
+ ```json
165
+ {
166
+ "symbols": ["EURUSD", "BTCUSDT", "XAUUSD"]
167
+ }
168
+ ```
169
+
170
+ ### `get_sma(symbol_code, time_frame, period=20)`
171
+
172
+ Example:
173
+
174
+ ```python
175
+ sma = client.get_sma("EURUSD", "M15", period=50)
176
+ ```
177
+
178
+ Example response payload:
179
+
180
+ ```json
181
+ {
182
+ "symbolCode": "EURUSD",
183
+ "timeFrame": "M15",
184
+ "period": 50,
185
+ "value": 1.08024,
186
+ "openTime": "2026-05-21T09:00:00Z"
187
+ }
188
+ ```
189
+
190
+ ## WebSocket streaming methods
191
+
192
+ The WebSocket client exposes async generators and reconnects after transient failures.
193
+
194
+ ### `stream_price(symbol_code, time_frame)`
195
+
196
+ Example:
197
+
198
+ ```python
199
+ async for event in ws.stream_price("EURUSD", "M1"):
200
+ print(event)
201
+ ```
202
+
203
+ Example message payload:
204
+
205
+ ```json
206
+ {
207
+ "symbolCode": "EURUSD",
208
+ "timeFrame": "M1",
209
+ "closePrice": 1.07879,
210
+ "openTime": "2026-05-21T09:12:00Z"
211
+ }
212
+ ```
213
+
214
+ ### `stream_candles(symbol_code, time_frame)`
215
+
216
+ Example:
217
+
218
+ ```python
219
+ async for event in ws.stream_candles("BTCUSDT", "M5"):
220
+ print(event)
221
+ ```
222
+
223
+ Example message payload:
224
+
225
+ ```json
226
+ {
227
+ "symbolCode": "BTCUSDT",
228
+ "timeFrame": "M5",
229
+ "openTime": "2026-05-21T09:10:00Z",
230
+ "openPrice": 68620.3,
231
+ "highPrice": 68690.1,
232
+ "lowPrice": 68588.7,
233
+ "closePrice": 68655.8,
234
+ "volume": 128.42
235
+ }
236
+ ```
237
+
238
+ ## Error handling notes
239
+
240
+ - REST methods call `response.raise_for_status()`, so HTTP 4xx/5xx responses raise `httpx.HTTPStatusError`.
241
+ - WebSocket streams retry on connection errors using `reconnect_delay_seconds` (default `2.0`).
242
+ - Cancel the async task to stop streaming cleanly.
243
+
244
+ ## Beta scope and compatibility
245
+
246
+ - Current REST coverage: price, candles, history, symbols, SMA.
247
+ - Current WebSocket coverage: price and candles.
248
+ - This package is beta and may receive additive changes before stable `1.0`.
249
+
250
+ ## Links
251
+
252
+ - RealMarketAPI homepage: [https://realmarketapi.com/](https://realmarketapi.com/)
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ realmarketapi_python_sdk_beta.egg-info/PKG-INFO
5
+ realmarketapi_python_sdk_beta.egg-info/SOURCES.txt
6
+ realmarketapi_python_sdk_beta.egg-info/dependency_links.txt
7
+ realmarketapi_python_sdk_beta.egg-info/requires.txt
8
+ realmarketapi_python_sdk_beta.egg-info/top_level.txt
9
+ realmarketapi_sdk/__init__.py
10
+ realmarketapi_sdk/client.py
11
+ realmarketapi_sdk/websocket.py
@@ -0,0 +1,2 @@
1
+ httpx>=0.27.0
2
+ websockets>=12.0
@@ -0,0 +1,4 @@
1
+ from .client import RealMarketApiClient
2
+ from .websocket import RealMarketApiWebSocket
3
+
4
+ __all__ = ["RealMarketApiClient", "RealMarketApiWebSocket"]
@@ -0,0 +1,65 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any, Dict, Optional
5
+ from urllib.parse import urlencode
6
+
7
+ import httpx
8
+
9
+
10
+ @dataclass
11
+ class RealMarketApiClient:
12
+ api_key: str
13
+ base_url: str = "https://api.realmarketapi.com"
14
+ timeout_seconds: float = 20.0
15
+
16
+ def __post_init__(self) -> None:
17
+ self.base_url = self.base_url.rstrip("/")
18
+ self._http = httpx.Client(timeout=self.timeout_seconds)
19
+
20
+ def close(self) -> None:
21
+ self._http.close()
22
+
23
+ def get_price(self, symbol_code: str, time_frame: str) -> Dict[str, Any]:
24
+ return self._get("/api/v1/price", {"symbolCode": symbol_code, "timeFrame": time_frame})
25
+
26
+ def get_candles(self, symbol_code: str, time_frame: str) -> Dict[str, Any]:
27
+ return self._get("/api/v1/candle", {"symbolCode": symbol_code, "timeFrame": time_frame})
28
+
29
+ def get_history(
30
+ self,
31
+ symbol_code: str,
32
+ start_time: str,
33
+ end_time: str,
34
+ page_number: int = 1,
35
+ page_size: int = 20,
36
+ ) -> Dict[str, Any]:
37
+ return self._get(
38
+ "/api/v1/history",
39
+ {
40
+ "symbolCode": symbol_code,
41
+ "startTime": start_time,
42
+ "endTime": end_time,
43
+ "pageNumber": str(page_number),
44
+ "pageSize": str(page_size),
45
+ },
46
+ )
47
+
48
+ def get_symbols(self) -> Dict[str, Any]:
49
+ return self._get("/api/v1/symbol", None)
50
+
51
+ def get_sma(self, symbol_code: str, time_frame: str, period: int = 20) -> Dict[str, Any]:
52
+ return self._get(
53
+ "/api/v1/indicator/sma",
54
+ {"symbolCode": symbol_code, "timeFrame": time_frame, "period": str(period)},
55
+ )
56
+
57
+ def _get(self, path: str, query: Optional[Dict[str, str]]) -> Dict[str, Any]:
58
+ params: Dict[str, str] = {"apiKey": self.api_key}
59
+ if query:
60
+ params.update(query)
61
+
62
+ url = f"{self.base_url}{path}?{urlencode(params)}"
63
+ response = self._http.get(url)
64
+ response.raise_for_status()
65
+ return response.json()
@@ -0,0 +1,45 @@
1
+ from __future__ import annotations
2
+
3
+ import asyncio
4
+ import json
5
+ from dataclasses import dataclass
6
+ from typing import Any, AsyncIterator, Dict
7
+ from urllib.parse import urlencode, urlparse
8
+
9
+ import websockets
10
+
11
+
12
+ @dataclass
13
+ class RealMarketApiWebSocket:
14
+ api_key: str
15
+ base_url: str = "https://api.realmarketapi.com"
16
+ reconnect_delay_seconds: float = 2.0
17
+
18
+ async def stream_price(self, symbol_code: str, time_frame: str) -> AsyncIterator[Dict[str, Any]]:
19
+ async for item in self._stream("price", {"symbolCode": symbol_code, "timeFrame": time_frame}):
20
+ yield item
21
+
22
+ async def stream_candles(self, symbol_code: str, time_frame: str) -> AsyncIterator[Dict[str, Any]]:
23
+ async for item in self._stream("candles", {"symbolCode": symbol_code, "timeFrame": time_frame}):
24
+ yield item
25
+
26
+ async def _stream(self, endpoint: str, params: Dict[str, str]) -> AsyncIterator[Dict[str, Any]]:
27
+ closed_by_user = False
28
+
29
+ while not closed_by_user:
30
+ url = self._to_ws_url(endpoint, params)
31
+ try:
32
+ async with websockets.connect(url) as socket:
33
+ while True:
34
+ raw = await socket.recv()
35
+ yield json.loads(raw)
36
+ except asyncio.CancelledError:
37
+ closed_by_user = True
38
+ except Exception:
39
+ await asyncio.sleep(self.reconnect_delay_seconds)
40
+
41
+ def _to_ws_url(self, endpoint: str, params: Dict[str, str]) -> str:
42
+ parsed = urlparse(self.base_url.rstrip("/"))
43
+ scheme = "wss" if parsed.scheme == "https" else "ws"
44
+ query = urlencode({"apiKey": self.api_key, **params})
45
+ return f"{scheme}://{parsed.netloc}/{endpoint}?{query}"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+