Skip to content

Commit c26799b

Browse files
authored
Merge pull request #61 from binance/rc-v9.0.0
Release v9.0.0
2 parents 6ed91ac + 19e0625 commit c26799b

24 files changed

+1148
-339
lines changed

CHANGELOG.md

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

3+
## 9.0.0 - 2025-07-22
4+
5+
### Added (1)
6+
7+
**Wallet**
8+
9+
- `check_questionnaire_requirements()` (`GET /sapi/v1/localentity/questionnaire-requirements`)
10+
11+
### Changed (4)
12+
13+
**Derivatives Trading Options**
14+
15+
#### REST API
16+
17+
- Modified response for `exchange_information()` method (`GET /eapi/v1/exchangeInfo`):
18+
- `optionSymbols`: item property `liquidationFeeRate` added
19+
20+
- Modified response for `option_margin_account_information()` method (`GET /eapi/v1/marginAccount`):
21+
- `asset`: item property `adjustedEquity` added
22+
- `asset`: item property `lpProfit` deleted
23+
24+
**Wallet**
25+
26+
- Added parameter `recvWindow`
27+
- affected methods:
28+
- `fetch_address_verification_list()` (`GET /sapi/v1/addressVerify/list`)
29+
- `vasp_list()` (`GET /sapi/v1/localentity/vasp`)
30+
31+
**Spot**
32+
33+
#### REST API
34+
35+
- Added missing parameters for `order_test()` (`POST /api/v3/order/test`)
36+
337
## 8.0.0 - 2025-07-14
438

539
### Added (1)

Cargo.toml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "binance-sdk"
3-
version = "8.0.0"
3+
version = "9.0.0"
44
authors = [ "Binance" ]
55
edition = "2024"
66
resolver = "3"
@@ -849,6 +849,11 @@ name = "derivatives_trading_options_rest_api_account_api_option_account_informat
849849
path = "examples/derivatives_trading_options/rest_api/account_api/option_account_information.rs"
850850
required-features = [ "derivatives_trading_options" ]
851851

852+
[[example]]
853+
name = "derivatives_trading_options_rest_api_account_api_option_margin_account_information"
854+
path = "examples/derivatives_trading_options/rest_api/account_api/option_margin_account_information.rs"
855+
required-features = [ "derivatives_trading_options" ]
856+
852857
[[example]]
853858
name = "derivatives_trading_options_rest_api_market_data_api_check_server_time"
854859
path = "examples/derivatives_trading_options/rest_api/market_data_api/check_server_time.rs"
@@ -964,11 +969,6 @@ name = "derivatives_trading_options_rest_api_market_maker_endpoints_api_get_mark
964969
path = "examples/derivatives_trading_options/rest_api/market_maker_endpoints_api/get_market_maker_protection_config.rs"
965970
required-features = [ "derivatives_trading_options" ]
966971

967-
[[example]]
968-
name = "derivatives_trading_options_rest_api_market_maker_endpoints_api_option_margin_account_information"
969-
path = "examples/derivatives_trading_options/rest_api/market_maker_endpoints_api/option_margin_account_information.rs"
970-
required-features = [ "derivatives_trading_options" ]
971-
972972
[[example]]
973973
name = "derivatives_trading_options_rest_api_market_maker_endpoints_api_reset_market_maker_protection_config"
974974
path = "examples/derivatives_trading_options/rest_api/market_maker_endpoints_api/reset_market_maker_protection_config.rs"
@@ -3989,14 +3989,19 @@ name = "wallet_rest_api_travel_rule_api_broker_withdraw"
39893989
path = "examples/wallet/rest_api/travel_rule_api/broker_withdraw.rs"
39903990
required-features = [ "wallet" ]
39913991

3992+
[[example]]
3993+
name = "wallet_rest_api_travel_rule_api_check_questionnaire_requirements"
3994+
path = "examples/wallet/rest_api/travel_rule_api/check_questionnaire_requirements.rs"
3995+
required-features = [ "wallet" ]
3996+
39923997
[[example]]
39933998
name = "wallet_rest_api_travel_rule_api_deposit_history_travel_rule"
39943999
path = "examples/wallet/rest_api/travel_rule_api/deposit_history_travel_rule.rs"
39954000
required-features = [ "wallet" ]
39964001

39974002
[[example]]
3998-
name = "wallet_rest_api_travel_rule_api_onboarded_vasp_list"
3999-
path = "examples/wallet/rest_api/travel_rule_api/onboarded_vasp_list.rs"
4003+
name = "wallet_rest_api_travel_rule_api_fetch_address_verification_list"
4004+
path = "examples/wallet/rest_api/travel_rule_api/fetch_address_verification_list.rs"
40004005
required-features = [ "wallet" ]
40014006

40024007
[[example]]
@@ -4009,6 +4014,11 @@ name = "wallet_rest_api_travel_rule_api_submit_deposit_questionnaire"
40094014
path = "examples/wallet/rest_api/travel_rule_api/submit_deposit_questionnaire.rs"
40104015
required-features = [ "wallet" ]
40114016

4017+
[[example]]
4018+
name = "wallet_rest_api_travel_rule_api_vasp_list"
4019+
path = "examples/wallet/rest_api/travel_rule_api/vasp_list.rs"
4020+
required-features = [ "wallet" ]
4021+
40124022
[[example]]
40134023
name = "wallet_rest_api_travel_rule_api_withdraw_history_v1"
40144024
path = "examples/wallet/rest_api/travel_rule_api/withdraw_history_v1.rs"

examples/spot/rest_api/trade_api/order_test.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use std::env;
33
use tracing::info;
44

55
use binance_sdk::config::ConfigurationRestApi;
6-
use binance_sdk::spot::{SpotRestApi, rest_api::OrderTestParams};
6+
use binance_sdk::spot::{
7+
SpotRestApi,
8+
rest_api::{OrderTestParams, OrderTestSideEnum, OrderTestTypeEnum},
9+
};
710

811
#[tokio::main]
912
async fn main() -> Result<()> {
@@ -21,7 +24,12 @@ async fn main() -> Result<()> {
2124
let rest_client = SpotRestApi::production(rest_conf);
2225

2326
// Setup the API parameters
24-
let params = OrderTestParams::default();
27+
let params = OrderTestParams::builder(
28+
"BNBUSDT".to_string(),
29+
OrderTestSideEnum::Buy,
30+
OrderTestTypeEnum::Market,
31+
)
32+
.build()?;
2533

2634
// Make the API call
2735
let response = rest_client
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use anyhow::{Context, Result};
2+
use std::env;
3+
use tracing::info;
4+
5+
use binance_sdk::config::ConfigurationRestApi;
6+
use binance_sdk::wallet::{WalletRestApi, rest_api::CheckQuestionnaireRequirementsParams};
7+
8+
#[tokio::main]
9+
async fn main() -> Result<()> {
10+
// Load credentials from env
11+
let api_key = env::var("API_KEY").context("API_KEY must be set")?;
12+
let api_secret = env::var("API_SECRET").context("API_SECRET must be set")?;
13+
14+
// Build REST config
15+
let rest_conf = ConfigurationRestApi::builder()
16+
.api_key(api_key)
17+
.api_secret(api_secret)
18+
.build()?;
19+
20+
// Create the Wallet REST API client
21+
let rest_client = WalletRestApi::production(rest_conf);
22+
23+
// Setup the API parameters
24+
let params = CheckQuestionnaireRequirementsParams::default();
25+
26+
// Make the API call
27+
let response = rest_client
28+
.check_questionnaire_requirements(params)
29+
.await
30+
.context("check_questionnaire_requirements request failed")?;
31+
32+
info!(?response.rate_limits, "check_questionnaire_requirements rate limits");
33+
let data = response.data().await?;
34+
info!(?data, "check_questionnaire_requirements data");
35+
36+
Ok(())
37+
}

examples/wallet/rest_api/travel_rule_api/fetch_address_verification_list.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::env;
33
use tracing::info;
44

55
use binance_sdk::config::ConfigurationRestApi;
6-
use binance_sdk::wallet::WalletRestApi;
6+
use binance_sdk::wallet::{WalletRestApi, rest_api::FetchAddressVerificationListParams};
77

88
#[tokio::main]
99
async fn main() -> Result<()> {
@@ -20,9 +20,12 @@ async fn main() -> Result<()> {
2020
// Create the Wallet REST API client
2121
let rest_client = WalletRestApi::production(rest_conf);
2222

23+
// Setup the API parameters
24+
let params = FetchAddressVerificationListParams::default();
25+
2326
// Make the API call
2427
let response = rest_client
25-
.fetch_address_verification_list()
28+
.fetch_address_verification_list(params)
2629
.await
2730
.context("fetch_address_verification_list request failed")?;
2831

examples/wallet/rest_api/travel_rule_api/onboarded_vasp_list.rs renamed to examples/wallet/rest_api/travel_rule_api/vasp_list.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::env;
33
use tracing::info;
44

55
use binance_sdk::config::ConfigurationRestApi;
6-
use binance_sdk::wallet::WalletRestApi;
6+
use binance_sdk::wallet::{WalletRestApi, rest_api::VaspListParams};
77

88
#[tokio::main]
99
async fn main() -> Result<()> {
@@ -20,15 +20,18 @@ async fn main() -> Result<()> {
2020
// Create the Wallet REST API client
2121
let rest_client = WalletRestApi::production(rest_conf);
2222

23+
// Setup the API parameters
24+
let params = VaspListParams::default();
25+
2326
// Make the API call
2427
let response = rest_client
25-
.onboarded_vasp_list()
28+
.vasp_list(params)
2629
.await
27-
.context("onboarded_vasp_list request failed")?;
30+
.context("vasp_list request failed")?;
2831

29-
info!(?response.rate_limits, "onboarded_vasp_list rate limits");
32+
info!(?response.rate_limits, "vasp_list rate limits");
3033
let data = response.data().await?;
31-
info!(?data, "onboarded_vasp_list data");
34+
info!(?data, "vasp_list data");
3235

3336
Ok(())
3437
}

src/derivatives_trading_options/rest_api/apis/account_api.rs

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ pub trait AccountApi: Send + Sync {
4747
&self,
4848
params: OptionAccountInformationParams,
4949
) -> anyhow::Result<RestApiResponse<models::OptionAccountInformationResponse>>;
50+
async fn option_margin_account_information(
51+
&self,
52+
params: OptionMarginAccountInformationParams,
53+
) -> anyhow::Result<RestApiResponse<models::OptionMarginAccountInformationResponse>>;
5054
}
5155

5256
#[derive(Debug, Clone)]
@@ -212,6 +216,29 @@ impl OptionAccountInformationParams {
212216
OptionAccountInformationParamsBuilder::default()
213217
}
214218
}
219+
/// Request parameters for the [`option_margin_account_information`] operation.
220+
///
221+
/// This struct holds all of the inputs you can pass when calling
222+
/// [`option_margin_account_information`](#method.option_margin_account_information).
223+
#[derive(Clone, Debug, Builder, Default)]
224+
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
225+
pub struct OptionMarginAccountInformationParams {
226+
///
227+
/// The `recv_window` parameter.
228+
///
229+
/// This field is **optional.
230+
#[builder(setter(into), default)]
231+
pub recv_window: Option<i64>,
232+
}
233+
234+
impl OptionMarginAccountInformationParams {
235+
/// Create a builder for [`option_margin_account_information`].
236+
///
237+
#[must_use]
238+
pub fn builder() -> OptionMarginAccountInformationParamsBuilder {
239+
OptionMarginAccountInformationParamsBuilder::default()
240+
}
241+
}
215242

216243
#[async_trait]
217244
impl AccountApi for AccountApiClient {
@@ -362,6 +389,33 @@ impl AccountApi for AccountApiClient {
362389
)
363390
.await
364391
}
392+
393+
async fn option_margin_account_information(
394+
&self,
395+
params: OptionMarginAccountInformationParams,
396+
) -> anyhow::Result<RestApiResponse<models::OptionMarginAccountInformationResponse>> {
397+
let OptionMarginAccountInformationParams { recv_window } = params;
398+
399+
let mut query_params = BTreeMap::new();
400+
401+
if let Some(rw) = recv_window {
402+
query_params.insert("recvWindow".to_string(), json!(rw));
403+
}
404+
405+
send_request::<models::OptionMarginAccountInformationResponse>(
406+
&self.configuration,
407+
"/eapi/v1/marginAccount",
408+
reqwest::Method::GET,
409+
query_params,
410+
if HAS_TIME_UNIT {
411+
self.configuration.time_unit
412+
} else {
413+
None
414+
},
415+
true,
416+
)
417+
.await
418+
}
365419
}
366420

367421
#[cfg(all(test, feature = "derivatives_trading_options"))]
@@ -503,6 +557,32 @@ mod tests {
503557

504558
Ok(dummy.into())
505559
}
560+
561+
async fn option_margin_account_information(
562+
&self,
563+
_params: OptionMarginAccountInformationParams,
564+
) -> anyhow::Result<RestApiResponse<models::OptionMarginAccountInformationResponse>>
565+
{
566+
if self.force_error {
567+
return Err(
568+
ConnectorError::ConnectorClientError("ResponseError".to_string()).into(),
569+
);
570+
}
571+
572+
let resp_json: Value = serde_json::from_str(r#"{"asset":[{"asset":"USDT","marginBalance":"10099.448","equity":"10094.44662","available":"8725.92524","initialMargin":"1084.52138","maintMargin":"151.00138","unrealizedPNL":"-5.00138","adjustedEquity":"34.13282285"}],"greek":[{"underlying":"BTCUSDT","delta":"-0.05","gamma":"-0.002","theta":"-0.05","vega":"-0.002"}],"time":1592449455993}"#).unwrap();
573+
let dummy_response: models::OptionMarginAccountInformationResponse =
574+
serde_json::from_value(resp_json.clone())
575+
.expect("should parse into models::OptionMarginAccountInformationResponse");
576+
577+
let dummy = DummyRestApiResponse {
578+
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
579+
status: 200,
580+
headers: HashMap::new(),
581+
rate_limits: None,
582+
};
583+
584+
Ok(dummy.into())
585+
}
506586
}
507587

508588
#[test]
@@ -749,4 +829,56 @@ mod tests {
749829
}
750830
});
751831
}
832+
833+
#[test]
834+
fn option_margin_account_information_required_params_success() {
835+
TOKIO_SHARED_RT.block_on(async {
836+
let client = MockAccountApiClient { force_error: false };
837+
838+
let params = OptionMarginAccountInformationParams::builder().build().unwrap();
839+
840+
let resp_json: Value = serde_json::from_str(r#"{"asset":[{"asset":"USDT","marginBalance":"10099.448","equity":"10094.44662","available":"8725.92524","initialMargin":"1084.52138","maintMargin":"151.00138","unrealizedPNL":"-5.00138","adjustedEquity":"34.13282285"}],"greek":[{"underlying":"BTCUSDT","delta":"-0.05","gamma":"-0.002","theta":"-0.05","vega":"-0.002"}],"time":1592449455993}"#).unwrap();
841+
let expected_response : models::OptionMarginAccountInformationResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OptionMarginAccountInformationResponse");
842+
843+
let resp = client.option_margin_account_information(params).await.expect("Expected a response");
844+
let data_future = resp.data();
845+
let actual_response = data_future.await.unwrap();
846+
assert_eq!(actual_response, expected_response);
847+
});
848+
}
849+
850+
#[test]
851+
fn option_margin_account_information_optional_params_success() {
852+
TOKIO_SHARED_RT.block_on(async {
853+
let client = MockAccountApiClient { force_error: false };
854+
855+
let params = OptionMarginAccountInformationParams::builder().recv_window(5000).build().unwrap();
856+
857+
let resp_json: Value = serde_json::from_str(r#"{"asset":[{"asset":"USDT","marginBalance":"10099.448","equity":"10094.44662","available":"8725.92524","initialMargin":"1084.52138","maintMargin":"151.00138","unrealizedPNL":"-5.00138","adjustedEquity":"34.13282285"}],"greek":[{"underlying":"BTCUSDT","delta":"-0.05","gamma":"-0.002","theta":"-0.05","vega":"-0.002"}],"time":1592449455993}"#).unwrap();
858+
let expected_response : models::OptionMarginAccountInformationResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OptionMarginAccountInformationResponse");
859+
860+
let resp = client.option_margin_account_information(params).await.expect("Expected a response");
861+
let data_future = resp.data();
862+
let actual_response = data_future.await.unwrap();
863+
assert_eq!(actual_response, expected_response);
864+
});
865+
}
866+
867+
#[test]
868+
fn option_margin_account_information_response_error() {
869+
TOKIO_SHARED_RT.block_on(async {
870+
let client = MockAccountApiClient { force_error: true };
871+
872+
let params = OptionMarginAccountInformationParams::builder()
873+
.build()
874+
.unwrap();
875+
876+
match client.option_margin_account_information(params).await {
877+
Ok(_) => panic!("Expected an error"),
878+
Err(err) => {
879+
assert_eq!(err.to_string(), "Connector client error: ResponseError");
880+
}
881+
}
882+
});
883+
}
752884
}

0 commit comments

Comments
 (0)