Skip to content

Commit 8e4bc0f

Browse files
committed
Improve OKXHttpClient with RetryManager
1 parent 58e8781 commit 8e4bc0f

File tree

9 files changed

+279
-76
lines changed

9 files changed

+279
-76
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/adapters/okx/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ strum = { workspace = true }
6868
thiserror = { workspace = true }
6969
tokio = { workspace = true }
7070
tokio-tungstenite = { workspace = true }
71+
tokio-util = { workspace = true }
7172
tracing = { workspace = true }
7273
tracing-subscriber = { workspace = true } # Needed for example binaries
7374
ustr = { workspace = true }

crates/adapters/okx/src/common/consts.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
// limitations under the License.
1414
// -------------------------------------------------------------------------------------------------
1515

16-
use std::{collections::HashSet, sync::LazyLock};
16+
use std::sync::LazyLock;
1717

18+
use ahash::AHashSet;
1819
use nautilus_model::{
1920
enums::{OrderType, TimeInForce},
2021
identifiers::Venue,
@@ -59,10 +60,14 @@ pub const OKX_SUPPORTED_ORDER_TYPES: &[OrderType] = &[
5960
];
6061

6162
/// OKX error codes that should trigger retries.
62-
/// Based on OKX API documentation: <https://www.okx.com/docs-v5/en/#error-codes>
63+
///
6364
/// Only retry on temporary network/system issues.
64-
pub static OKX_RETRY_ERROR_CODES: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
65-
let mut codes = HashSet::new();
65+
///
66+
/// # References
67+
///
68+
/// Based on OKX API documentation: <https://www.okx.com/docs-v5/en/#error-codes>
69+
pub static OKX_RETRY_ERROR_CODES: LazyLock<AHashSet<&'static str>> = LazyLock::new(|| {
70+
let mut codes = AHashSet::new();
6671

6772
// Temporary system errors
6873
codes.insert("50001"); // Service temporarily unavailable

0 commit comments

Comments
 (0)