Skip to content

Commit 9ce8b3e

Browse files
authored
Merge #522
2 parents 1a4b4c0 + f37bdb7 commit 9ce8b3e

86 files changed

Lines changed: 5117 additions & 597 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

clients/c2c/CHANGELOG.md

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

3+
## 4.0.0 - 2026-04-20
4+
5+
### Changed (1)
6+
7+
- Modified response for `get_c2_c_trade_history()` (`GET /sapi/v1/c2c/orderMatch/listUserOrderHistory`):
8+
- property `tradeType` added
9+
- property `totalPrice` added
10+
- property `orderNumber` added
11+
- property `takerCommissionRate` added
12+
- property `amount` added
13+
- property `asset` added
14+
- property `fiat` added
15+
- property `orderStatus` added
16+
- property `takerAmount` added
17+
- property `takerCommission` added
18+
- property `counterPartNickName` added
19+
- property `commission` added
20+
- property `payMethodName` added
21+
- property `fiatSymbol` added
22+
- property `advNo` added
23+
- property `unitPrice` added
24+
- property `createTime` added
25+
- property `additionalKycVerify` added
26+
- property `total` deleted
27+
- property `code` deleted
28+
- property `data` deleted
29+
- property `message` deleted
30+
- property `success` deleted
31+
332
## 3.6.0 - 2026-03-26
433

534
### Added (1)

clients/c2c/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "binance-sdk-c2c"
3-
version = "3.6.0"
3+
version = "4.0.0"
44
description = "Official Binance C2C SDK - A lightweight library that provides a convenient interface to Binance's C2C REST API"
55
authors = ["Binance"]
66
license = "MIT"

clients/c2c/src/binance_sdk_c2c/rest_api/models/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@
1111
from .get_c2_c_trade_history_response import (
1212
GetC2CTradeHistoryResponse as GetC2CTradeHistoryResponse,
1313
)
14-
from .get_c2_c_trade_history_response_data_inner import (
15-
GetC2CTradeHistoryResponseDataInner as GetC2CTradeHistoryResponseDataInner,
16-
)

clients/c2c/src/binance_sdk_c2c/rest_api/models/get_c2_c_trade_history_response.py

Lines changed: 65 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
import re # noqa: F401
1717
import json
1818

19-
from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr
19+
20+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
2021
from typing import Any, ClassVar, Dict, List, Optional
21-
from binance_sdk_c2c.rest_api.models.get_c2_c_trade_history_response_data_inner import (
22-
GetC2CTradeHistoryResponseDataInner,
23-
)
22+
2423
from typing import Set
2524
from typing_extensions import Self
2625

@@ -30,13 +29,51 @@ class GetC2CTradeHistoryResponse(BaseModel):
3029
GetC2CTradeHistoryResponse
3130
""" # noqa: E501
3231

33-
code: Optional[StrictStr] = None
34-
message: Optional[StrictStr] = None
35-
data: Optional[List[GetC2CTradeHistoryResponseDataInner]] = None
36-
total: Optional[StrictInt] = None
37-
success: Optional[StrictBool] = None
32+
order_number: Optional[StrictStr] = Field(default=None, alias="orderNumber")
33+
adv_no: Optional[StrictStr] = Field(default=None, alias="advNo")
34+
trade_type: Optional[StrictStr] = Field(default=None, alias="tradeType")
35+
asset: Optional[StrictStr] = None
36+
fiat: Optional[StrictStr] = None
37+
fiat_symbol: Optional[StrictStr] = Field(default=None, alias="fiatSymbol")
38+
amount: Optional[StrictStr] = None
39+
total_price: Optional[StrictStr] = Field(default=None, alias="totalPrice")
40+
unit_price: Optional[StrictStr] = Field(default=None, alias="unitPrice")
41+
order_status: Optional[StrictStr] = Field(default=None, alias="orderStatus")
42+
create_time: Optional[StrictInt] = Field(default=None, alias="createTime")
43+
commission: Optional[StrictStr] = None
44+
taker_commission_rate: Optional[StrictStr] = Field(
45+
default=None, alias="takerCommissionRate"
46+
)
47+
taker_commission: Optional[StrictStr] = Field(default=None, alias="takerCommission")
48+
taker_amount: Optional[StrictStr] = Field(default=None, alias="takerAmount")
49+
counter_part_nick_name: Optional[StrictStr] = Field(
50+
default=None, alias="counterPartNickName"
51+
)
52+
pay_method_name: Optional[StrictStr] = Field(default=None, alias="payMethodName")
53+
additional_kyc_verify: Optional[StrictInt] = Field(
54+
default=None, alias="additionalKycVerify"
55+
)
3856
additional_properties: Dict[str, Any] = {}
39-
__properties: ClassVar[List[str]] = ["code", "message", "data", "total", "success"]
57+
__properties: ClassVar[List[str]] = [
58+
"orderNumber",
59+
"advNo",
60+
"tradeType",
61+
"asset",
62+
"fiat",
63+
"fiatSymbol",
64+
"amount",
65+
"totalPrice",
66+
"unitPrice",
67+
"orderStatus",
68+
"createTime",
69+
"commission",
70+
"takerCommissionRate",
71+
"takerCommission",
72+
"takerAmount",
73+
"counterPartNickName",
74+
"payMethodName",
75+
"additionalKycVerify",
76+
]
4077

4178
model_config = ConfigDict(
4279
populate_by_name=True,
@@ -84,13 +121,6 @@ def to_dict(self) -> Dict[str, Any]:
84121
exclude=excluded_fields,
85122
exclude_none=True,
86123
)
87-
# override the default output from pydantic by calling `to_dict()` of each item in data (list)
88-
_items = []
89-
if self.data:
90-
for _item_data in self.data:
91-
if _item_data:
92-
_items.append(_item_data.to_dict())
93-
_dict["data"] = _items
94124
# puts key-value pairs in additional_properties in the top level
95125
if self.additional_properties is not None:
96126
for _key, _value in self.additional_properties.items():
@@ -109,18 +139,24 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
109139

110140
_obj = cls.model_validate(
111141
{
112-
"code": obj.get("code"),
113-
"message": obj.get("message"),
114-
"data": (
115-
[
116-
GetC2CTradeHistoryResponseDataInner.from_dict(_item)
117-
for _item in obj["data"]
118-
]
119-
if obj.get("data") is not None
120-
else None
121-
),
122-
"total": obj.get("total"),
123-
"success": obj.get("success"),
142+
"orderNumber": obj.get("orderNumber"),
143+
"advNo": obj.get("advNo"),
144+
"tradeType": obj.get("tradeType"),
145+
"asset": obj.get("asset"),
146+
"fiat": obj.get("fiat"),
147+
"fiatSymbol": obj.get("fiatSymbol"),
148+
"amount": obj.get("amount"),
149+
"totalPrice": obj.get("totalPrice"),
150+
"unitPrice": obj.get("unitPrice"),
151+
"orderStatus": obj.get("orderStatus"),
152+
"createTime": obj.get("createTime"),
153+
"commission": obj.get("commission"),
154+
"takerCommissionRate": obj.get("takerCommissionRate"),
155+
"takerCommission": obj.get("takerCommission"),
156+
"takerAmount": obj.get("takerAmount"),
157+
"counterPartNickName": obj.get("counterPartNickName"),
158+
"payMethodName": obj.get("payMethodName"),
159+
"additionalKycVerify": obj.get("additionalKycVerify"),
124160
}
125161
)
126162
# store additional fields in additional_properties

clients/c2c/tests/unit/rest_api/test_c2_c_api.py

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,24 @@ def test_get_c2_c_trade_history_success(self, mock_get_signature):
5151
"""Test get_c2_c_trade_history() successfully with required parameters only."""
5252

5353
expected_response = {
54-
"code": "000000",
55-
"message": "success",
56-
"data": [
57-
{
58-
"orderNumber": "20219644646554779648",
59-
"advNo": "11218246497340923904",
60-
"tradeType": "SELL",
61-
"asset": "BUSD",
62-
"fiat": "CNY",
63-
"fiatSymbol": "¥",
64-
"amount": "5000.00000000",
65-
"totalPrice": "33400.00000000",
66-
"unitPrice": "6.68",
67-
"orderStatus": "COMPLETED",
68-
"createTime": 1619361369000,
69-
"commission": "0",
70-
"counterPartNickName": "ab***",
71-
"advertisementRole": "TAKER",
72-
}
73-
],
74-
"total": 1,
75-
"success": True,
54+
"orderNumber": "20219644646554779648",
55+
"advNo": "11218246497340923904",
56+
"tradeType": "SELL",
57+
"asset": "USDT",
58+
"fiat": "CNY",
59+
"fiatSymbol": "¥",
60+
"amount": "343.40000000",
61+
"totalPrice": "2500.00000000",
62+
"unitPrice": "7.28",
63+
"orderStatus": "COMPLETED",
64+
"createTime": 1722997599534,
65+
"commission": "0",
66+
"takerCommissionRate": "0",
67+
"takerCommission": "0",
68+
"takerAmount": "343.4",
69+
"counterPartNickName": "aaa-***",
70+
"payMethodName": "BANK",
71+
"additionalKycVerify": 0,
7672
}
7773
mock_get_signature.return_value = "mocked_signature"
7874
self.set_mock_response(expected_response)
@@ -124,28 +120,24 @@ def test_get_c2_c_trade_history_success_with_optional_params(
124120
}
125121

126122
expected_response = {
127-
"code": "000000",
128-
"message": "success",
129-
"data": [
130-
{
131-
"orderNumber": "20219644646554779648",
132-
"advNo": "11218246497340923904",
133-
"tradeType": "SELL",
134-
"asset": "BUSD",
135-
"fiat": "CNY",
136-
"fiatSymbol": "¥",
137-
"amount": "5000.00000000",
138-
"totalPrice": "33400.00000000",
139-
"unitPrice": "6.68",
140-
"orderStatus": "COMPLETED",
141-
"createTime": 1619361369000,
142-
"commission": "0",
143-
"counterPartNickName": "ab***",
144-
"advertisementRole": "TAKER",
145-
}
146-
],
147-
"total": 1,
148-
"success": True,
123+
"orderNumber": "20219644646554779648",
124+
"advNo": "11218246497340923904",
125+
"tradeType": "SELL",
126+
"asset": "USDT",
127+
"fiat": "CNY",
128+
"fiatSymbol": "¥",
129+
"amount": "343.40000000",
130+
"totalPrice": "2500.00000000",
131+
"unitPrice": "7.28",
132+
"orderStatus": "COMPLETED",
133+
"createTime": 1722997599534,
134+
"commission": "0",
135+
"takerCommissionRate": "0",
136+
"takerCommission": "0",
137+
"takerAmount": "343.4",
138+
"counterPartNickName": "aaa-***",
139+
"payMethodName": "BANK",
140+
"additionalKycVerify": 0,
149141
}
150142
mock_get_signature.return_value = "mocked_signature"
151143
self.set_mock_response(expected_response)

clients/derivatives_trading_portfolio_margin/CHANGELOG.md

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

3+
## 6.0.0 - 2026-04-20
4+
5+
### Added (7)
6+
7+
#### REST API
8+
9+
- `futures_tradfi_perps_contract()` (`POST /papi/v1/um/stock/contract`)
10+
- `cancel_all_um_algo_open_orders()` (`DELETE /papi/v1/um/algo/allOpenOrders`)
11+
- `cancel_um_algo_order()` (`DELETE /papi/v1/um/algo/order`)
12+
- `new_um_algo_order()` (`POST /papi/v1/um/algo/order`)
13+
- `query_all_current_um_open_algo_orders()` (`GET /papi/v1/um/algo/openAlgoOrders`)
14+
- `query_current_um_open_algo_order()` (`GET /papi/v1/um/algo/algoOrder`)
15+
- `query_um_algo_order_history()` (`GET /papi/v1/um/algo/allAlgoOrders`)
16+
17+
### Changed (8)
18+
19+
#### REST API
20+
21+
- Marked `cancel_all_um_open_conditional_orders()` (`DELETE /papi/v1/um/conditional/allOpenOrders`) as deprecated.
22+
- Marked `cancel_um_conditional_order()` (`DELETE /papi/v1/um/conditional/order`) as deprecated.
23+
- Marked `new_um_conditional_order()` (`POST /papi/v1/um/conditional/order`) as deprecated.
24+
- Marked `query_all_current_um_open_conditional_orders()` (`GET /papi/v1/um/conditional/openOrders`) as deprecated.
25+
- Marked `query_all_um_conditional_orders()` (`GET /papi/v1/um/conditional/allOrders`) as deprecated.
26+
- Marked `query_current_um_open_conditional_order()` (`GET /papi/v1/um/conditional/openOrder`) as deprecated.
27+
- Marked `query_um_conditional_order_history()` (`GET /papi/v1/um/conditional/orderHistory`) as deprecated.
28+
- Modified response for `get_um_income_history()` (`GET /papi/v1/um/income`):
29+
- items.`tranId`: type `string``integer`
30+
- items.`tranId`: type `string``integer`
31+
332
## 5.3.0 - 2026-03-26
433

534
### Added (1)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
import logging
3+
4+
from binance_sdk_derivatives_trading_portfolio_margin.derivatives_trading_portfolio_margin import (
5+
DerivativesTradingPortfolioMargin,
6+
ConfigurationRestAPI,
7+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL,
8+
)
9+
10+
11+
# Configure logging
12+
logging.basicConfig(level=logging.INFO)
13+
14+
# Create configuration for the REST API
15+
configuration_rest_api = ConfigurationRestAPI(
16+
api_key=os.getenv("API_KEY", ""),
17+
api_secret=os.getenv("API_SECRET", ""),
18+
base_path=os.getenv(
19+
"BASE_PATH", DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL
20+
),
21+
)
22+
23+
# Initialize DerivativesTradingPortfolioMargin client
24+
client = DerivativesTradingPortfolioMargin(config_rest_api=configuration_rest_api)
25+
26+
27+
def cancel_all_um_algo_open_orders():
28+
try:
29+
response = client.rest_api.cancel_all_um_algo_open_orders(
30+
symbol="symbol_example",
31+
)
32+
33+
rate_limits = response.rate_limits
34+
logging.info(f"cancel_all_um_algo_open_orders() rate limits: {rate_limits}")
35+
36+
data = response.data()
37+
logging.info(f"cancel_all_um_algo_open_orders() response: {data}")
38+
except Exception as e:
39+
logging.error(f"cancel_all_um_algo_open_orders() error: {e}")
40+
41+
42+
if __name__ == "__main__":
43+
cancel_all_um_algo_open_orders()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
import logging
3+
4+
from binance_sdk_derivatives_trading_portfolio_margin.derivatives_trading_portfolio_margin import (
5+
DerivativesTradingPortfolioMargin,
6+
ConfigurationRestAPI,
7+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL,
8+
)
9+
10+
11+
# Configure logging
12+
logging.basicConfig(level=logging.INFO)
13+
14+
# Create configuration for the REST API
15+
configuration_rest_api = ConfigurationRestAPI(
16+
api_key=os.getenv("API_KEY", ""),
17+
api_secret=os.getenv("API_SECRET", ""),
18+
base_path=os.getenv(
19+
"BASE_PATH", DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL
20+
),
21+
)
22+
23+
# Initialize DerivativesTradingPortfolioMargin client
24+
client = DerivativesTradingPortfolioMargin(config_rest_api=configuration_rest_api)
25+
26+
27+
def cancel_um_algo_order():
28+
try:
29+
response = client.rest_api.cancel_um_algo_order()
30+
31+
rate_limits = response.rate_limits
32+
logging.info(f"cancel_um_algo_order() rate limits: {rate_limits}")
33+
34+
data = response.data()
35+
logging.info(f"cancel_um_algo_order() response: {data}")
36+
except Exception as e:
37+
logging.error(f"cancel_um_algo_order() error: {e}")
38+
39+
40+
if __name__ == "__main__":
41+
cancel_um_algo_order()

0 commit comments

Comments
 (0)