Skip to content

Commit 80dbfb8

Browse files
committed
Release v1.2.0
1 parent 7c14351 commit 80dbfb8

27 files changed

Lines changed: 1354 additions & 173 deletions

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
# Changelog
22

3+
## 1.2.0 - 2026-02-02
4+
5+
### Added
6+
- Added a `restart` flag to the `FixConnector` connector to restart when receiving a `NEWS` message.
7+
8+
### Updated
9+
- Updated `retrieve_messages_until` method to accept a list of message types.
10+
- Fixed messages parsing issue that caused the error: `Field missing '=' separator`.
11+
312
## 1.1.0 - 2025-10-27
13+
414
### Updated
515
- Added parameters `min_price`, `max_price` and `min_price_increment` to `InstrumentList` response.
616

717
## 1.0.1 - 2025-05-08
18+
819
### Removed
920
- Removed the references for `auto-reconnect` in the dropcopy session to fix the following [issue](https://github.com/binance/binance-fix-connector-python/issues/2).
1021

README.md

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,29 @@ pip install binance-fix-connector
1919
All the FIX messages can be created with the `BinanceFixConnector` class. The following example demonstrates how to create a simple order using the FIX API:
2020
```python
2121
import time
22-
import os
23-
from pathlib import Path
2422

2523
from binance_fix_connector.fix_connector import create_order_entry_session
2624
from binance_fix_connector.utils import get_api_key, get_private_key
25+
from constants import (
26+
path,
27+
FIX_OE_URL,
28+
INSTRUMENT,
29+
ORD_REJECT_REASON,
30+
ORD_STATUS,
31+
ORD_TYPES,
32+
SIDES,
33+
TIME_IN_FORCE,
34+
)
2735

2836
# Credentials
29-
path = config_path = os.path.join(
30-
Path(__file__).parent.resolve(), "..", "config.ini"
31-
)
3237
API_KEY, PATH_TO_PRIVATE_KEY_PEM_FILE = get_api_key(path)
3338

34-
# FIX URL
35-
FIX_OE_URL = "tcp+tls://fix-oe.testnet.binance.vision:9000"
36-
37-
# Response types
38-
ORD_STATUS = {
39-
"0": "NEW",
40-
"1": "PARTIALLY_FILLED",
41-
"2": "FILLED",
42-
"4": "CANCELED",
43-
"6": "PENDING_CANCEL",
44-
"8": "REJECTED",
45-
"A": "PENDING_NEW",
46-
"C": "EXPIRED",
47-
}
48-
ORD_TYPES = {"1": "MARKET", "2": "LIMIT", "3": "STOP", "4": "STOP_LIMIT"}
49-
SIDES = {"1": "BUY", "2": "SELL"}
50-
TIME_IN_FORCE = {
51-
"1": "GOOD_TILL_CANCEL",
52-
"3": "IMMEDIATE_OR_CANCEL",
53-
"4": "FILL_OR_KILL",
54-
}
55-
ORD_REJECT_REASON = {"99": "OTHER"}
56-
57-
# Parameter
58-
INSTRUMENT = "BNBUSDT"
59-
6039
client_oe = create_order_entry_session(
6140
api_key=API_KEY,
6241
private_key=get_private_key(PATH_TO_PRIVATE_KEY_PEM_FILE),
6342
endpoint=FIX_OE_URL,
6443
)
65-
client_oe.retrieve_messages_until(message_type="A")
44+
client_oe.retrieve_messages_until(message_type=["A"])
6645

6746
example = "This example shows how to place a single order. Order type LIMIT.\nCheck https://github.com/binance/binance-spot-api-docs/blob/master/fix-api.md#newordersingled for additional types."
6847
client_oe.logger.info(example)
@@ -79,7 +58,7 @@ msg.append_pair(59, 1) # TIME IN FORCE
7958
client_oe.send_message(msg)
8059

8160

82-
responses = client_oe.retrieve_messages_until(message_type="8")
61+
responses = client_oe.retrieve_messages_until(message_type=["8"])
8362
resp = next(
8463
(x for x in responses if x.message_type.decode("utf-8") == "8"),
8564
None,
@@ -118,7 +97,7 @@ client_oe.logger.info(f"Error code: {error_code} | Reason: {text}")
11897
# LOGOUT
11998
client_oe.logger.info("LOGOUT (5)")
12099
client_oe.logout()
121-
client_oe.retrieve_messages_until(message_type="5")
100+
client_oe.retrieve_messages_until(message_type=["5"])
122101
client_oe.logger.info(
123102
"Closing the connection with server as we already sent the logout message"
124103
)

examples/config.ini.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
[keys]
88
API_KEY =
9-
PATH_TO_PRIVATE_KEY_PEM_FILE =
9+
PATH_TO_PRIVATE_KEY_PEM_FILE =

examples/constants.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os
2+
from pathlib import Path
3+
4+
# FIX URLs
5+
FIX_OE_URL = "tcp+tls://fix-oe.testnet.binance.vision:9000"
6+
FIX_MD_URL = "tcp+tls://fix-md.testnet.binance.vision:9000"
7+
8+
# Credentials
9+
path = os.path.join(Path(__file__).parent.resolve(), "config.ini")
10+
11+
# Response types
12+
ACTION = {"0": "NEW", "1": "CHANGE", "2": "DELETE"}
13+
AGGRESSOR_SIDE = {"1": "BUY", "2": "SELL"}
14+
CONTINGENCY_TYPE = {
15+
"1": "ONE_CANCELS_THE_OTHER ",
16+
"2": "ONE_TRIGGERS_THE_OTHER",
17+
}
18+
LIMIT_TYPES = {"1": "ORDER_LIMIT", "2": "MESSAGE_LIMIT", "3": "SUBSCRIPTION_LIMIT"}
19+
LIST_ORD_STATUS = {"3": "EXECUTING", "6": "ALL_DONE", "7": "REJECT"}
20+
LIST_ORD_TYPE = {"1": "ONE_CANCELS_THE_OTHER", "2": "ONE_TRIGGERS_THE_OTHER"}
21+
LIST_STATUS_TYPE = {
22+
"2": "RESPONSE",
23+
"4": "EXEC_STARTED",
24+
"5": "ALL_DONE",
25+
"100": "UPDATED",
26+
}
27+
LIST_TRIG_TYPE = {"ACTIVATED": "1", "PARTIALLY_FILLED": "2", "FILLED": "3"}
28+
LIST_TRIG_ACTION = {"RELEASE": "1", "CANCEL": "2"}
29+
ORD_STATUS = {
30+
"0": "NEW",
31+
"1": "PARTIALLY_FILLED",
32+
"2": "FILLED",
33+
"4": "CANCELED",
34+
"6": "PENDING_CANCEL",
35+
"8": "REJECTED",
36+
"A": "PENDING_NEW",
37+
"C": "EXPIRED",
38+
}
39+
ORD_TYPES = {"1": "MARKET", "2": "LIMIT", "3": "STOP", "4": "STOP_LIMIT", "P": "PEGGED"}
40+
ORD_REJECT_REASON = {"99": "OTHER"}
41+
RESOLUTIONS = {"s": "SECOND", "m": "MINUTE", "h": "HOUR", "d": "DAY"}
42+
SIDES = {"1": "BUY", "2": "SELL"}
43+
TIME_IN_FORCE = {
44+
"1": "GOOD_TILL_CANCEL",
45+
"3": "IMMEDIATE_OR_CANCEL",
46+
"4": "FILL_OR_KILL",
47+
}
48+
UPDATE = {"0": "BID", "1": "OFFER", "2": "TRADE"}
49+
50+
# Parameters
51+
INSTRUMENT = "BNBUSDT"
52+
TIMEOUT_SECONDS = 20

examples/general/__init__.py

Whitespace-only changes.

examples/general/current_messages_limit_rate.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
#!/usr/bin/env python3
22

3-
import os
4-
from pathlib import Path
5-
63
from binance_fix_connector.fix_connector import (
74
BinanceFixConnector,
85
create_market_data_session,
96
create_order_entry_session,
107
)
118
from binance_fix_connector.utils import get_api_key, get_private_key
9+
from constants import path, RESOLUTIONS, LIMIT_TYPES, FIX_OE_URL, FIX_MD_URL
1210

1311
# Credentials
14-
path = config_path = os.path.join(Path(__file__).parent.resolve(), "..", "config.ini")
1512
API_KEY, PATH_TO_PRIVATE_KEY_PEM_FILE = get_api_key(path)
1613

17-
# FIX URLs
18-
FIX_OE_URL = "tcp+tls://fix-oe.testnet.binance.vision:9000"
19-
FIX_MD_URL = "tcp+tls://fix-md.testnet.binance.vision:9000"
20-
21-
# Response types
22-
RESOLUTIONS = {"s": "SECOND", "m": "MINUTE", "h": "HOUR", "d": "DAY"}
23-
LIMIT_TYPES = {"1": "ORDER_LIMIT", "2": "MESSAGE_LIMIT", "3": "SUBSCRIPTION_LIMIT"}
24-
2514

2615
def show_rendered_limit_session(client: BinanceFixConnector) -> None:
2716
"""Show the current LIMITS the session has."""
28-
responses = client.retrieve_messages_until(message_type="XLR")
17+
responses = client.retrieve_messages_until(message_type=["XLR"])
2918
for msg in responses:
3019
if msg.message_type.decode("utf-8") == "XLR":
3120
limits = 0 if not msg.get(25003) else int(msg.get(25003).decode("utf-8"))
@@ -73,7 +62,7 @@ def show_rendered_limit_session(client: BinanceFixConnector) -> None:
7362
private_key=get_private_key(PATH_TO_PRIVATE_KEY_PEM_FILE),
7463
endpoint=FIX_OE_URL,
7564
)
76-
client_oe.retrieve_messages_until(message_type="A")
65+
client_oe.retrieve_messages_until(message_type=["A"])
7766

7867
example = "This example shows how to query for current session limits and how to parse it's data. Check https://github.com/binance/binance-spot-api-docs/blob/master/fix-api.md#limitqueryxlq for additional information."
7968
client_oe.logger.info(example)
@@ -87,7 +76,7 @@ def show_rendered_limit_session(client: BinanceFixConnector) -> None:
8776
# LOGOUT
8877
client_oe.logger.info("LOGOUT (5)")
8978
client_oe.logout()
90-
client_oe.retrieve_messages_until(message_type="5")
79+
client_oe.retrieve_messages_until(message_type=["5"])
9180
client_oe.logger.info(
9281
"Closing the connection with server as we already sent the logout message"
9382
)
@@ -99,7 +88,7 @@ def show_rendered_limit_session(client: BinanceFixConnector) -> None:
9988
private_key=get_private_key(PATH_TO_PRIVATE_KEY_PEM_FILE),
10089
endpoint=FIX_MD_URL,
10190
)
102-
client_md.retrieve_messages_until(message_type="A")
91+
client_md.retrieve_messages_until(message_type=["A"])
10392

10493
example = "This example shows how to query for current session limits and how to parse it's data. Check https://github.com/binance/binance-spot-api-docs/blob/master/fix-api.md for additional information."
10594
client_md.logger.info(example)
@@ -113,7 +102,7 @@ def show_rendered_limit_session(client: BinanceFixConnector) -> None:
113102
# LOGOUT
114103
client_md.logger.info("LOGOUT (5)")
115104
client_md.logout()
116-
client_md.retrieve_messages_until(message_type="5")
105+
client_md.retrieve_messages_until(message_type=["5"])
117106
client_md.logger.info(
118107
"Closing the connection with server as we already sent the logout message"
119108
)

examples/general/instrument_list.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
#!/usr/bin/env python3
22

33
import time
4-
import os
5-
from pathlib import Path
64

75
from binance_fix_connector.fix_connector import (
86
BinanceFixConnector,
97
create_market_data_session,
108
)
119
from binance_fix_connector.utils import get_api_key, get_private_key
10+
from constants import path, FIX_MD_URL
1211

1312
# Credentials
14-
path = config_path = os.path.join(Path(__file__).parent.resolve(), "..", "config.ini")
1513
API_KEY, PATH_TO_PRIVATE_KEY_PEM_FILE = get_api_key(path)
1614

17-
# FIX URL
18-
FIX_MD_URL = "tcp+tls://fix-md.testnet.binance.vision:9000"
19-
20-
# Parameters
21-
INSTRUMENT = "BNBUSDT"
22-
2315

2416
def show_rendered_instrument_list(client: BinanceFixConnector) -> None:
2517
"""Show the instrument list messages received."""
@@ -102,7 +94,7 @@ def show_rendered_instrument_list(client: BinanceFixConnector) -> None:
10294
private_key=get_private_key(PATH_TO_PRIVATE_KEY_PEM_FILE),
10395
endpoint=FIX_MD_URL,
10496
)
105-
client_md.retrieve_messages_until(message_type="A")
97+
client_md.retrieve_messages_until(message_type=["A"])
10698

10799
example = "This example shows how to query information about active instruments.\nCheck https://github.com/binance/binance-spot-api-docs/blob/master/fix-api.md#instrumentlistrequestx for additional types."
108100
client_md.logger.info(example)
@@ -125,7 +117,7 @@ def show_rendered_instrument_list(client: BinanceFixConnector) -> None:
125117
# LOGOUT
126118
client_md.logger.info("LOGOUT (5)")
127119
client_md.logout()
128-
client_md.retrieve_messages_until(message_type="5")
120+
client_md.retrieve_messages_until(message_type=["5"])
129121
client_md.logger.info(
130122
"Closing the connection with server as we already sent the logout message"
131123
)

examples/market_stream/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)