1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//! Error codes for Binance (version 2024-08-16).
//!
//! See [docs](https://developers.binance.com/docs/binance-spot-api-docs/errors)
//! for more information.
use serde::Deserialize;
use serde_repr::Deserialize_repr;
#[derive(Debug, Deserialize)]
pub struct BinanceError {
pub code: BinanceErrorCode,
pub msg: String,
}
#[derive(Debug, Deserialize_repr)]
#[serde(untagged)]
#[repr(i32)]
pub enum BinanceErrorCode {
/// An unknown error occurred while processing the request.
Unknown = -1000,
/// Internal error; unable to process your request. Please try again.
Disconnected = -1001,
/// You are not authorized to execute this request.
Unauthorized = -1002,
/// - Too many requests queued.
/// - Too much request weight used; current limit is %s request weight per %s.
/// Please use WebSocket Streams for live updates to avoid polling the API.
/// - Way too much request weight used; IP banned until %s. Please use
/// WebSocket Streams for live updates to avoid bans.
TooManyRequests = -1003,
/// An unexpected response was received from the message bus. Execution
/// status unknown.
UnexpectedResp = -1006,
/// Timeout waiting for response from backend server. Send status unknown;
/// execution status unknown.
Timeout = -1007,
/// Server is currently overloaded with other requests. Please try again in
/// a few minutes.
ServerBusy = -1008,
/// ERROR_MSG_RECEIVED
ErrorMsgReceived = -1010,
/// Filter failure
FilterFailure = -1013,
/// Unsupported order combination.
UnknownOrderComposition = -1014,
/// - Too many new orders.
/// - Too many new orders; current limit is %s orders per %s.
TooManyOrders = -1015,
/// This service is no longer available.
ServiceShuttingDown = -1016,
/// This operation is not supported.
UnsupportedOperation = -1020,
/// - Timestamp for this request is outside of the recvWindow.
/// - Timestamp for this request was 1000ms ahead of the server's time.
InvalidTimestamp = -1021,
/// Signature for this request is not valid.
InvalidSignature = -1022,
/// Not found, authenticated, or authorized.
NotFound = -1099,
/// - Illegal characters found in a parameter.
/// - Illegal characters found in parameter '%s'; legal range is '%s'.
IllegalChars = -1100,
/// - Too many parameters sent for this endpoint.
/// - Too many parameters; expected '%s' and received '%s'.
/// - Duplicate values for a parameter detected.
TooManyParameters = -1101,
/// - A mandatory parameter was not sent, was empty/null, or malformed.
/// - Mandatory parameter '%s' was not sent, was empty/null, or malformed.
/// - Param '%s' or '%s' must be sent, but both were empty/null!
MandatoryParamEmptyOrMalformed = -1102,
/// An unknown parameter was sent.
UnknownParam = -1103,
/// - Not all sent parameters were read.
/// - Not all sent parameters were read; read '%s' parameter(s) but was sent '%s'.
UnreadParameters = -1104,
/// - A parameter was empty.
/// - Parameter '%s' was empty.
ParamEmpty = -1105,
/// - A parameter was sent when not required.
/// - Parameter '%s' sent when not required.
ParamNotRequired = -1106,
/// Parameter '%s' overflowed.
ParamOverflow = -1108,
/// Parameter '%s' has too much precision.
BadPrecision = -1111,
/// No orders on book for symbol.
NoDepth = -1112,
/// TimeInForce parameter sent when not required.
TifNotRequired = -1114,
/// Invalid timeInForce.
InvalidTif = -1115,
/// Invalid orderType.
InvalidOrderType = -1116,
/// Invalid side.
InvalidSide = -1117,
/// New client order ID was empty.
EmptyNewClOrdId = -1118,
/// Original client order ID was empty.
EmptyOrigClOrdId = -1119,
/// Invalid interval.
BadInterval = -1120,
/// Invalid symbol.
BadSymbol = -1121,
/// This listenKey does not exist.
InvalidListenKey = -1125,
/// - Lookup interval is too big.
/// - More than %s hours between startTime and endTime.
MoreThanXxHours = -1127,
/// Combination of optional parameters invalid.
OptionalParamsBadCombo = -1128,
/// - Invalid data sent for a parameter.
/// - Data sent for parameter '%s' is not valid.
InvalidParameter = -1130,
/// `recvWindow` must be less than 60000.
BadRecvWindow = -1131,
/// `strategyType` was less than 1000000.
BadStrategyType = -1134,
/// - Invalid JSON Request
/// - JSON sent for parameter '%s' is not valid
InvalidJson = -1135,
/// Invalid ticker type.
InvalidTickerType = -1139,
/// `cancelRestrictions` has to be either `ONLY_NEW` or
/// `ONLY_PARTIALLY_FILLED`.
InvalidCancelRestrictions = -1145,
/// Symbol is present multiple times in the list.
DuplicateSymbol = -1151,
/// Invalid `X-MBX-SBE` header; expected `<SCHEMA_ID>:<VERSION>`.
InvalidSbeHeader = -1152,
/// Unsupported SBE schema ID or version specified in the `X-MBX-SBE` header.
UnsupportedSchemaId = -1153,
/// SBE is not enabled.
SbeDisabled = -1155,
/// - Order type not supported in OCO.
/// - If the order type provided in the aboveType and/or belowType is not
/// supported.
OcoOrderTypeRejected = -1158,
/// - Parameter '%s' is not supported if `aboveTimeInForce`/`belowTimeInForce`
/// is not GTC.
/// - If the order type for the above or below leg is `STOP_LOSS_LIMIT`, and
/// `icebergQty` is provided for that leg, the `timeInForce` has to be `GTC`
/// else it will throw an error.
OcoIcebergqtyTimeinforce = -1160,
/// Requested operation is not allowed in DropCopy sessions.
NotAllowedInDropCopySessions = -1183,
/// DropCopy sessions are not supported on this server. Please reconnect to a
/// drop copy server.
DropCopySessionNotAllowed = -1184,
/// Only DropCopy sessions are supported on this server. Either reconnect to
/// order entry server or send `DropCopyFlag (9406)` field.
DropCopySessionRequired = -1185,
/// NEW_ORDER_REJECTED
NewOrderRejected = -2010,
/// CANCEL_REJECTED
CancelRejected = -2011,
/// Order does not exist.
NoSuchOrder = -2013,
/// API-key format invalid.
BadApiKeyFmt = -2014,
/// Invalid API-key, IP, or permissions for action.
RejectedMbxKey = -2015,
/// No trading window could be found for the symbol. Try ticker/24hrs
/// instead.
NoTradingWindow = -2016,
/// This code is sent when either the cancellation of the order failed or the new order placement failed but not both.
OrderCancelReplacePartiallyFailed = -2021,
/// This code is sent when both the cancellation of the order failed and the new order placement failed.
OrderCancelReplaceFailed = -2022,
/// Order was canceled or expired with no executed qty over 90 days ago and
/// has been archived.
OrderArchived = -2026,
}