@nemesis-oss/binance-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +198 -0
- package/dist/index-D2T_Rhwj.d.cts +2055 -0
- package/dist/index-D2T_Rhwj.d.ts +2055 -0
- package/dist/index.cjs +4586 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +327 -0
- package/dist/index.d.ts +327 -0
- package/dist/index.js +4402 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.cjs +4090 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.js +4067 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/tools/index.cjs +1538 -0
- package/dist/tools/index.cjs.map +1 -0
- package/dist/tools/index.d.cts +3 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +1494 -0
- package/dist/tools/index.js.map +1 -0
- package/package.json +86 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { F as FuturesMarket, B as BinanceClient } from './index-D2T_Rhwj.cjs';
|
|
2
|
+
export { A as Account, a as AccountAsset, b as AccountAssetSchema, c as AccountPosition, d as AccountPositionSchema, e as AccountSchema, f as AggTrade, g as AggTradeSchema, h as AggTradesResponseSchema, i as AlgoOrder, j as AlgoOrderResponseSchema, k as AlgoOrderSchema, l as AlgoOrdersResponseSchema, m as ApiTradingStatus, n as ApiTradingStatusSchema, o as AuthMode, p as AvgPrice, q as AvgPriceSchema, r as Balance, s as BalanceSchema, t as BalancesResponseSchema, u as BaseWS, v as BaseWSOptions, w as BatchOrdersItem, x as BatchOrdersItemSchema, y as BatchOrdersResponseSchema, z as BinanceClientOptions, C as BookTicker, D as BookTickerSchema, E as BracketOrderParams, G as ClosePositionParams, H as CommissionRate, I as CommissionRateSchema, J as ContractType, K as CountdownCancelAll, L as CountdownCancelAllSchema, M as CreateOrderParams, N as CreateOrderParamsSchema, O as DepthSnapshot, P as DepthSnapshotSchema, Q as ExchangeInfo, R as ExchangeInfoSchema, S as ExchangeSymbol, T as ExchangeSymbolSchema, U as FeeBurnStatus, V as FeeBurnStatusSchema, W as FundingRate, X as FundingRateHistorySchema, Y as FundingRateSchema, Z as FuturesAccount, _ as FuturesData, $ as FuturesDataEndpoints, a0 as FuturesMarketWS, a1 as FuturesOps, a2 as FuturesToolkit, a3 as FuturesTrading, a4 as FuturesUserWS, a5 as FuturesUserWSOptions, a6 as HttpClient, a7 as HttpClientOptions, a8 as HttpMethod, a9 as Income, aa as IncomeHistoryResponseSchema, ab as IncomeSchema, ac as Kline, ad as KlineInterval, ae as KlineIntervalSchema, af as KlineSchema, ag as KlinesResponseSchema, ah as LeverageBracket, ai as LeverageBracketResponseSchema, aj as LeverageBracketSchema, ak as LeverageChange, al as LeverageChangeSchema, am as ListenKey, an as ListenKeySchema, ao as LongShortRatioEntry, ap as LongShortRatioEntrySchema, aq as LongShortRatioSchema, ar as MarginTypeChange, as as MarginTypeChangeSchema, at as MarkPriceSpeed, au as MarketDataBase, av as ModifyOrderParams, aw as ModifyOrderParamsSchema, ax as MultiAssetsMargin, ay as MultiAssetsMarginSchema, az as NewOrderAck, aA as NewOrderAckSchema, aB as OpenInterest, aC as OpenInterestHistEntry, aD as OpenInterestHistEntrySchema, aE as OpenInterestHistSchema, aF as OpenInterestSchema, aG as Order, aH as OrderModifyHistoryEntry, aI as OrderModifyHistoryEntrySchema, aJ as OrderModifyHistorySchema, aK as OrderResponseSchema, aL as OrderSchema, aM as OrdersResponseSchema, aN as PositionMarginChange, aO as PositionMarginChangeSchema, aP as PositionMarginHistoryEntry, aQ as PositionMarginHistoryEntrySchema, aR as PositionMarginHistorySchema, aS as PositionMode, aT as PositionModeSchema, aU as PositionRisk, aV as PositionRiskResponseSchema, aW as PositionRiskSchema, aX as PositionSizing, aY as PremiumIndex, aZ as PremiumIndexSchema, a_ as RateLimitOrder, a$ as RateLimitOrderResponseSchema, b0 as RateLimitOrderSchema, b1 as SizePositionParams, b2 as SpotAccount, b3 as SpotAccountInfo, b4 as SpotAccountSchema, b5 as SpotBalance, b6 as SpotBalanceSchema, b7 as SpotBalanceUpdate, b8 as SpotBalanceUpdateSchema, b9 as SpotExecutionReport, ba as SpotExecutionReportSchema, bb as SpotListStatus, bc as SpotListStatusSchema, bd as SpotMarket, be as SpotMarketWS, bf as SpotOCOOrderAck, bg as SpotOCOOrderAckResponseSchema, bh as SpotOCOOrderAckSchema, bi as SpotOCOOrdersResponseSchema, bj as SpotOrder, bk as SpotOrderResponseSchema, bl as SpotOrderSchema, bm as SpotOrdersResponseSchema, bn as SpotOutboundAccountPosition, bo as SpotOutboundAccountPositionSchema, bp as SpotTrade, bq as SpotTradeSchema, br as SpotTradesResponseSchema, bs as SpotTrading, bt as SpotUserDataEvent, bu as SpotUserDataStream, bv as SpotUserWS, bw as SpotUserWSOptions, bx as SymbolRules, by as TakerLongShortRatioEntry, bz as TakerLongShortRatioEntrySchema, bA as TakerLongShortRatioSchema, bB as Ticker24hr, bC as Ticker24hrSchema, bD as TickerPrice, bE as TickerPriceSchema, bF as ToolContext, bG as ToolDefinition, bH as Trade, bI as TradeSchema, bJ as TradesResponseSchema, bK as UserDataAccountUpdate, bL as UserDataAccountUpdateSchema, bM as UserDataEvent, bN as UserDataMarginCall, bO as UserDataMarginCallSchema, bP as UserDataOrderTradeUpdate, bQ as UserDataOrderTradeUpdateSchema, bR as UserDataStream, bS as UserTrade, bT as UserTradeSchema, bU as UserTradesResponseSchema, bV as WsApi, bW as WsApiOptions, bX as WsApiResponse, bY as WsApiResponseSchema, bZ as accountTools, b_ as createFuturesToolkit, b$ as createPaperContext, c0 as derivedTools, c1 as floorToStep, c2 as formatToDecimals, c3 as getBufferedWsEvents, c4 as marketDataTools, c5 as paperTools, c6 as parseSpotUserDataEvent, c7 as parseUserDataEvent, c8 as roundToStep, c9 as spotTools, ca as stepDecimals, cb as symbolRulesFrom, cc as textResult, cd as toAnthropicTool, ce as toJsonSchema, cf as toMCPTool, cg as toOpenAITool, ch as toToolList, ci as toolkitToFormats, cj as tradingTools, ck as wsTools } from './index-D2T_Rhwj.cjs';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import 'node:events';
|
|
6
|
+
|
|
7
|
+
type Environment = 'live' | 'testnet' | 'demo';
|
|
8
|
+
interface Endpoints {
|
|
9
|
+
restRoot: string;
|
|
10
|
+
restFapi: string;
|
|
11
|
+
restFuturesData: string;
|
|
12
|
+
restSpot: string;
|
|
13
|
+
wsMarket: string;
|
|
14
|
+
wsUser: string;
|
|
15
|
+
wsApi: string;
|
|
16
|
+
wsSpotMarket: string;
|
|
17
|
+
wsSpotUser: string;
|
|
18
|
+
}
|
|
19
|
+
declare function resolveEnvironment(options?: {
|
|
20
|
+
testnet?: boolean;
|
|
21
|
+
demo?: boolean;
|
|
22
|
+
apiBase?: string;
|
|
23
|
+
wsBase?: string;
|
|
24
|
+
wsUserBase?: string;
|
|
25
|
+
wsApiBase?: string;
|
|
26
|
+
}): {
|
|
27
|
+
env: Environment;
|
|
28
|
+
endpoints: Endpoints;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type PaperPositionSide = 'LONG' | 'SHORT' | 'NONE';
|
|
32
|
+
interface PaperPosition {
|
|
33
|
+
symbol: string;
|
|
34
|
+
side: PaperPositionSide;
|
|
35
|
+
entryPrice: number;
|
|
36
|
+
quantity: number;
|
|
37
|
+
leverage: number;
|
|
38
|
+
/** Margin currently allocated to this position, released proportionally as it is reduced. */
|
|
39
|
+
margin: number;
|
|
40
|
+
unrealizedPnl: number;
|
|
41
|
+
openedAt: number;
|
|
42
|
+
}
|
|
43
|
+
interface PaperOrder {
|
|
44
|
+
orderId: number;
|
|
45
|
+
symbol: string;
|
|
46
|
+
side: 'BUY' | 'SELL';
|
|
47
|
+
type: 'MARKET' | 'LIMIT';
|
|
48
|
+
quantity: number;
|
|
49
|
+
price: number;
|
|
50
|
+
status: 'FILLED';
|
|
51
|
+
filledQuantity: number;
|
|
52
|
+
avgFillPrice: number;
|
|
53
|
+
/** Realized PnL booked by this order, if it reduced or closed a position. */
|
|
54
|
+
realizedPnl: number;
|
|
55
|
+
createdAt: number;
|
|
56
|
+
}
|
|
57
|
+
interface PaperAccount {
|
|
58
|
+
/** Wallet balance: starts at initialBalance and moves only with realized PnL. */
|
|
59
|
+
balance: number;
|
|
60
|
+
/** Wallet balance minus margin currently locked in open positions. */
|
|
61
|
+
availableBalance: number;
|
|
62
|
+
/** balance + unrealized PnL. */
|
|
63
|
+
totalWalletBalance: number;
|
|
64
|
+
realizedPnl: number;
|
|
65
|
+
unrealizedPnl: number;
|
|
66
|
+
positions: Record<string, PaperPosition>;
|
|
67
|
+
orders: PaperOrder[];
|
|
68
|
+
}
|
|
69
|
+
interface PaperTradingOptions {
|
|
70
|
+
initialBalance?: number;
|
|
71
|
+
/** Injectable so tests and offline callers can supply their own price source. */
|
|
72
|
+
market?: FuturesMarket;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* In-memory simulator for USD-M futures fills. Prices come from the live public
|
|
76
|
+
* market endpoints; nothing is ever sent to the exchange.
|
|
77
|
+
*
|
|
78
|
+
* Accounting model: `balance` moves only on realized PnL. Opening a position locks
|
|
79
|
+
* `notional / leverage` of margin out of `availableBalance`; reducing it releases
|
|
80
|
+
* that margin pro-rata and books the realized PnL. Orders fill instantly at the
|
|
81
|
+
* current mark for MARKET, or at the stated limit price for LIMIT — there is no
|
|
82
|
+
* order book simulation, slippage or funding.
|
|
83
|
+
*/
|
|
84
|
+
declare class PaperTradingEngine {
|
|
85
|
+
private readonly account;
|
|
86
|
+
private readonly market;
|
|
87
|
+
private orderIdCounter;
|
|
88
|
+
constructor(options?: PaperTradingOptions);
|
|
89
|
+
/** Current mark price for any tradeable symbol. */
|
|
90
|
+
getMarketPrice(symbol: string): Promise<number>;
|
|
91
|
+
private positionFor;
|
|
92
|
+
placeOrder(params: {
|
|
93
|
+
symbol: string;
|
|
94
|
+
side: 'BUY' | 'SELL';
|
|
95
|
+
type: 'MARKET' | 'LIMIT';
|
|
96
|
+
quantity: number;
|
|
97
|
+
price?: number;
|
|
98
|
+
leverage?: number;
|
|
99
|
+
}): Promise<PaperOrder>;
|
|
100
|
+
/**
|
|
101
|
+
* Apply a fill to a position, returning the realized PnL it booked.
|
|
102
|
+
* Handles extend, partial reduce, full close, and a flip through zero.
|
|
103
|
+
*/
|
|
104
|
+
private applyFill;
|
|
105
|
+
private openExposure;
|
|
106
|
+
/** Reduce a position, releasing margin pro-rata and booking realized PnL. */
|
|
107
|
+
private reduceExposure;
|
|
108
|
+
private markToMarket;
|
|
109
|
+
private recomputeTotals;
|
|
110
|
+
/** Refresh unrealized PnL for every open position against live prices. */
|
|
111
|
+
updatePositions(): Promise<void>;
|
|
112
|
+
getAccountInfo(): PaperAccount;
|
|
113
|
+
getPosition(symbol: string): PaperPosition | undefined;
|
|
114
|
+
getAllPositions(): Record<string, PaperPosition>;
|
|
115
|
+
/** Open positions only — the zero-size entries left behind by closed trades are filtered out. */
|
|
116
|
+
getOpenPositions(): PaperPosition[];
|
|
117
|
+
getOrderHistory(symbol?: string): PaperOrder[];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare const WsKlinePayloadSchema: z.ZodObject<{
|
|
121
|
+
e: z.ZodLiteral<"kline">;
|
|
122
|
+
E: z.ZodNumber;
|
|
123
|
+
s: z.ZodString;
|
|
124
|
+
k: z.ZodObject<{
|
|
125
|
+
t: z.ZodNumber;
|
|
126
|
+
T: z.ZodNumber;
|
|
127
|
+
s: z.ZodString;
|
|
128
|
+
i: z.ZodString;
|
|
129
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
130
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
131
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
132
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
133
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
134
|
+
n: z.ZodNumber;
|
|
135
|
+
x: z.ZodBoolean;
|
|
136
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
137
|
+
V: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
138
|
+
Q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
type WsKlinePayload = z.infer<typeof WsKlinePayloadSchema>;
|
|
142
|
+
declare const WsAggTradePayloadSchema: z.ZodObject<{
|
|
143
|
+
e: z.ZodLiteral<"aggTrade">;
|
|
144
|
+
E: z.ZodNumber;
|
|
145
|
+
s: z.ZodString;
|
|
146
|
+
a: z.ZodNumber;
|
|
147
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
148
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
149
|
+
f: z.ZodNumber;
|
|
150
|
+
l: z.ZodNumber;
|
|
151
|
+
T: z.ZodNumber;
|
|
152
|
+
m: z.ZodBoolean;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
type WsAggTradePayload = z.infer<typeof WsAggTradePayloadSchema>;
|
|
155
|
+
declare const WsTradePayloadSchema: z.ZodObject<{
|
|
156
|
+
e: z.ZodLiteral<"trade">;
|
|
157
|
+
E: z.ZodNumber;
|
|
158
|
+
s: z.ZodString;
|
|
159
|
+
t: z.ZodNumber;
|
|
160
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
161
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
162
|
+
T: z.ZodNumber;
|
|
163
|
+
m: z.ZodBoolean;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
type WsTradePayload = z.infer<typeof WsTradePayloadSchema>;
|
|
166
|
+
declare const WsDepthUpdatePayloadSchema: z.ZodObject<{
|
|
167
|
+
e: z.ZodLiteral<"depthUpdate">;
|
|
168
|
+
E: z.ZodNumber;
|
|
169
|
+
s: z.ZodString;
|
|
170
|
+
U: z.ZodNumber;
|
|
171
|
+
u: z.ZodNumber;
|
|
172
|
+
T: z.ZodOptional<z.ZodNumber>;
|
|
173
|
+
pu: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
b: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
175
|
+
a: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
type WsDepthUpdatePayload = z.infer<typeof WsDepthUpdatePayloadSchema>;
|
|
178
|
+
declare const WsTicker24hrPayloadSchema: z.ZodObject<{
|
|
179
|
+
e: z.ZodLiteral<"24hrTicker">;
|
|
180
|
+
E: z.ZodNumber;
|
|
181
|
+
s: z.ZodString;
|
|
182
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
183
|
+
P: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
184
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
185
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
186
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
187
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
188
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
189
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
type WsTicker24hrPayload = z.infer<typeof WsTicker24hrPayloadSchema>;
|
|
192
|
+
declare const WsBookTickerPayloadSchema: z.ZodObject<{
|
|
193
|
+
u: z.ZodNumber;
|
|
194
|
+
s: z.ZodString;
|
|
195
|
+
b: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
196
|
+
B: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
197
|
+
a: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
198
|
+
A: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
type WsBookTickerPayload = z.infer<typeof WsBookTickerPayloadSchema>;
|
|
201
|
+
declare const WsMarkPricePayloadSchema: z.ZodObject<{
|
|
202
|
+
e: z.ZodLiteral<"markPriceUpdate">;
|
|
203
|
+
E: z.ZodNumber;
|
|
204
|
+
s: z.ZodString;
|
|
205
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
206
|
+
i: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
207
|
+
P: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
208
|
+
r: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
209
|
+
T: z.ZodNumber;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
type WsMarkPricePayload = z.infer<typeof WsMarkPricePayloadSchema>;
|
|
212
|
+
declare const WsMiniTickerPayloadSchema: z.ZodObject<{
|
|
213
|
+
e: z.ZodLiteral<"24hrMiniTicker">;
|
|
214
|
+
E: z.ZodNumber;
|
|
215
|
+
s: z.ZodString;
|
|
216
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
217
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
218
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
219
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
220
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
221
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
222
|
+
}, z.core.$strip>;
|
|
223
|
+
type WsMiniTickerPayload = z.infer<typeof WsMiniTickerPayloadSchema>;
|
|
224
|
+
declare const WsForceOrderPayloadSchema: z.ZodObject<{
|
|
225
|
+
e: z.ZodLiteral<"forceOrder">;
|
|
226
|
+
E: z.ZodNumber;
|
|
227
|
+
o: z.ZodObject<{
|
|
228
|
+
s: z.ZodString;
|
|
229
|
+
S: z.ZodString;
|
|
230
|
+
o: z.ZodString;
|
|
231
|
+
f: z.ZodString;
|
|
232
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
233
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
234
|
+
ap: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
235
|
+
X: z.ZodString;
|
|
236
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
237
|
+
z: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
238
|
+
T: z.ZodNumber;
|
|
239
|
+
}, z.core.$strip>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
type WsForceOrderPayload = z.infer<typeof WsForceOrderPayloadSchema>;
|
|
242
|
+
declare const WsCompositeIndexPayloadSchema: z.ZodObject<{
|
|
243
|
+
e: z.ZodLiteral<"compositeIndex">;
|
|
244
|
+
E: z.ZodNumber;
|
|
245
|
+
s: z.ZodString;
|
|
246
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
247
|
+
c: z.ZodArray<z.ZodObject<{
|
|
248
|
+
b: z.ZodString;
|
|
249
|
+
q: z.ZodString;
|
|
250
|
+
w: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
251
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
252
|
+
}, z.core.$strip>>;
|
|
253
|
+
}, z.core.$strip>;
|
|
254
|
+
type WsCompositeIndexPayload = z.infer<typeof WsCompositeIndexPayloadSchema>;
|
|
255
|
+
declare const WsAssetIndexPayloadSchema: z.ZodObject<{
|
|
256
|
+
e: z.ZodLiteral<"assetIndex">;
|
|
257
|
+
E: z.ZodNumber;
|
|
258
|
+
s: z.ZodString;
|
|
259
|
+
i: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
260
|
+
b: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
261
|
+
a: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
type WsAssetIndexPayload = z.infer<typeof WsAssetIndexPayloadSchema>;
|
|
264
|
+
declare const WsRollingWindowTickerPayloadSchema: z.ZodObject<{
|
|
265
|
+
e: z.ZodEnum<{
|
|
266
|
+
"1hTicker": "1hTicker";
|
|
267
|
+
"4hTicker": "4hTicker";
|
|
268
|
+
"1dTicker": "1dTicker";
|
|
269
|
+
"7dTicker": "7dTicker";
|
|
270
|
+
"30dTicker": "30dTicker";
|
|
271
|
+
}>;
|
|
272
|
+
E: z.ZodNumber;
|
|
273
|
+
s: z.ZodString;
|
|
274
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
275
|
+
P: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
276
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
277
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
278
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
279
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
280
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
281
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
282
|
+
O: z.ZodNumber;
|
|
283
|
+
C: z.ZodNumber;
|
|
284
|
+
}, z.core.$strip>;
|
|
285
|
+
type WsRollingWindowTickerPayload = z.infer<typeof WsRollingWindowTickerPayloadSchema>;
|
|
286
|
+
declare const WsSpotAvgPricePayloadSchema: z.ZodObject<{
|
|
287
|
+
e: z.ZodLiteral<"avgPrice">;
|
|
288
|
+
E: z.ZodNumber;
|
|
289
|
+
s: z.ZodString;
|
|
290
|
+
i: z.ZodString;
|
|
291
|
+
w: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
292
|
+
T: z.ZodNumber;
|
|
293
|
+
}, z.core.$strip>;
|
|
294
|
+
type WsSpotAvgPricePayload = z.infer<typeof WsSpotAvgPricePayloadSchema>;
|
|
295
|
+
type WsStreamPayload = WsKlinePayload | WsAggTradePayload | WsTradePayload | WsDepthUpdatePayload | WsTicker24hrPayload | WsBookTickerPayload | WsMarkPricePayload | WsMiniTickerPayload | WsForceOrderPayload | WsCompositeIndexPayload | WsAssetIndexPayload | WsRollingWindowTickerPayload | WsSpotAvgPricePayload;
|
|
296
|
+
declare function parseWsPayload(streamName: string, raw: unknown): WsStreamPayload;
|
|
297
|
+
|
|
298
|
+
declare class BinanceError extends Error {
|
|
299
|
+
constructor(message: string);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
declare class BinanceAuthError extends BinanceError {
|
|
303
|
+
readonly missing: 'apiKey' | 'apiSecret';
|
|
304
|
+
constructor(missing: 'apiKey' | 'apiSecret');
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare class BinanceApiError extends BinanceError {
|
|
308
|
+
readonly code: number;
|
|
309
|
+
readonly status: number;
|
|
310
|
+
constructor(message: string, code: number, status: number);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare class RateLimitError extends BinanceApiError {
|
|
314
|
+
readonly retryAfterMs?: number;
|
|
315
|
+
constructor(message: string, code: number, status: number, retryAfterMs?: number);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
declare class NetworkError extends BinanceError {
|
|
319
|
+
readonly cause?: unknown;
|
|
320
|
+
constructor(message: string, cause?: unknown);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare function createBinanceMcpServer(client: BinanceClient): McpServer;
|
|
324
|
+
|
|
325
|
+
declare const VERSION = "2.1.0";
|
|
326
|
+
|
|
327
|
+
export { BinanceApiError, BinanceAuthError, BinanceClient, BinanceError, type Endpoints, type Environment, FuturesMarket, NetworkError, type PaperAccount, type PaperOrder, type PaperPosition, type PaperPositionSide, PaperTradingEngine, type PaperTradingOptions, RateLimitError, VERSION, type WsAggTradePayload, WsAggTradePayloadSchema, type WsAssetIndexPayload, WsAssetIndexPayloadSchema, type WsBookTickerPayload, WsBookTickerPayloadSchema, type WsCompositeIndexPayload, WsCompositeIndexPayloadSchema, type WsDepthUpdatePayload, WsDepthUpdatePayloadSchema, type WsForceOrderPayload, WsForceOrderPayloadSchema, type WsKlinePayload, WsKlinePayloadSchema, type WsMarkPricePayload, WsMarkPricePayloadSchema, type WsMiniTickerPayload, WsMiniTickerPayloadSchema, type WsRollingWindowTickerPayload, WsRollingWindowTickerPayloadSchema, type WsSpotAvgPricePayload, WsSpotAvgPricePayloadSchema, type WsStreamPayload, type WsTicker24hrPayload, WsTicker24hrPayloadSchema, type WsTradePayload, WsTradePayloadSchema, createBinanceMcpServer, parseWsPayload, resolveEnvironment };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { F as FuturesMarket, B as BinanceClient } from './index-D2T_Rhwj.js';
|
|
2
|
+
export { A as Account, a as AccountAsset, b as AccountAssetSchema, c as AccountPosition, d as AccountPositionSchema, e as AccountSchema, f as AggTrade, g as AggTradeSchema, h as AggTradesResponseSchema, i as AlgoOrder, j as AlgoOrderResponseSchema, k as AlgoOrderSchema, l as AlgoOrdersResponseSchema, m as ApiTradingStatus, n as ApiTradingStatusSchema, o as AuthMode, p as AvgPrice, q as AvgPriceSchema, r as Balance, s as BalanceSchema, t as BalancesResponseSchema, u as BaseWS, v as BaseWSOptions, w as BatchOrdersItem, x as BatchOrdersItemSchema, y as BatchOrdersResponseSchema, z as BinanceClientOptions, C as BookTicker, D as BookTickerSchema, E as BracketOrderParams, G as ClosePositionParams, H as CommissionRate, I as CommissionRateSchema, J as ContractType, K as CountdownCancelAll, L as CountdownCancelAllSchema, M as CreateOrderParams, N as CreateOrderParamsSchema, O as DepthSnapshot, P as DepthSnapshotSchema, Q as ExchangeInfo, R as ExchangeInfoSchema, S as ExchangeSymbol, T as ExchangeSymbolSchema, U as FeeBurnStatus, V as FeeBurnStatusSchema, W as FundingRate, X as FundingRateHistorySchema, Y as FundingRateSchema, Z as FuturesAccount, _ as FuturesData, $ as FuturesDataEndpoints, a0 as FuturesMarketWS, a1 as FuturesOps, a2 as FuturesToolkit, a3 as FuturesTrading, a4 as FuturesUserWS, a5 as FuturesUserWSOptions, a6 as HttpClient, a7 as HttpClientOptions, a8 as HttpMethod, a9 as Income, aa as IncomeHistoryResponseSchema, ab as IncomeSchema, ac as Kline, ad as KlineInterval, ae as KlineIntervalSchema, af as KlineSchema, ag as KlinesResponseSchema, ah as LeverageBracket, ai as LeverageBracketResponseSchema, aj as LeverageBracketSchema, ak as LeverageChange, al as LeverageChangeSchema, am as ListenKey, an as ListenKeySchema, ao as LongShortRatioEntry, ap as LongShortRatioEntrySchema, aq as LongShortRatioSchema, ar as MarginTypeChange, as as MarginTypeChangeSchema, at as MarkPriceSpeed, au as MarketDataBase, av as ModifyOrderParams, aw as ModifyOrderParamsSchema, ax as MultiAssetsMargin, ay as MultiAssetsMarginSchema, az as NewOrderAck, aA as NewOrderAckSchema, aB as OpenInterest, aC as OpenInterestHistEntry, aD as OpenInterestHistEntrySchema, aE as OpenInterestHistSchema, aF as OpenInterestSchema, aG as Order, aH as OrderModifyHistoryEntry, aI as OrderModifyHistoryEntrySchema, aJ as OrderModifyHistorySchema, aK as OrderResponseSchema, aL as OrderSchema, aM as OrdersResponseSchema, aN as PositionMarginChange, aO as PositionMarginChangeSchema, aP as PositionMarginHistoryEntry, aQ as PositionMarginHistoryEntrySchema, aR as PositionMarginHistorySchema, aS as PositionMode, aT as PositionModeSchema, aU as PositionRisk, aV as PositionRiskResponseSchema, aW as PositionRiskSchema, aX as PositionSizing, aY as PremiumIndex, aZ as PremiumIndexSchema, a_ as RateLimitOrder, a$ as RateLimitOrderResponseSchema, b0 as RateLimitOrderSchema, b1 as SizePositionParams, b2 as SpotAccount, b3 as SpotAccountInfo, b4 as SpotAccountSchema, b5 as SpotBalance, b6 as SpotBalanceSchema, b7 as SpotBalanceUpdate, b8 as SpotBalanceUpdateSchema, b9 as SpotExecutionReport, ba as SpotExecutionReportSchema, bb as SpotListStatus, bc as SpotListStatusSchema, bd as SpotMarket, be as SpotMarketWS, bf as SpotOCOOrderAck, bg as SpotOCOOrderAckResponseSchema, bh as SpotOCOOrderAckSchema, bi as SpotOCOOrdersResponseSchema, bj as SpotOrder, bk as SpotOrderResponseSchema, bl as SpotOrderSchema, bm as SpotOrdersResponseSchema, bn as SpotOutboundAccountPosition, bo as SpotOutboundAccountPositionSchema, bp as SpotTrade, bq as SpotTradeSchema, br as SpotTradesResponseSchema, bs as SpotTrading, bt as SpotUserDataEvent, bu as SpotUserDataStream, bv as SpotUserWS, bw as SpotUserWSOptions, bx as SymbolRules, by as TakerLongShortRatioEntry, bz as TakerLongShortRatioEntrySchema, bA as TakerLongShortRatioSchema, bB as Ticker24hr, bC as Ticker24hrSchema, bD as TickerPrice, bE as TickerPriceSchema, bF as ToolContext, bG as ToolDefinition, bH as Trade, bI as TradeSchema, bJ as TradesResponseSchema, bK as UserDataAccountUpdate, bL as UserDataAccountUpdateSchema, bM as UserDataEvent, bN as UserDataMarginCall, bO as UserDataMarginCallSchema, bP as UserDataOrderTradeUpdate, bQ as UserDataOrderTradeUpdateSchema, bR as UserDataStream, bS as UserTrade, bT as UserTradeSchema, bU as UserTradesResponseSchema, bV as WsApi, bW as WsApiOptions, bX as WsApiResponse, bY as WsApiResponseSchema, bZ as accountTools, b_ as createFuturesToolkit, b$ as createPaperContext, c0 as derivedTools, c1 as floorToStep, c2 as formatToDecimals, c3 as getBufferedWsEvents, c4 as marketDataTools, c5 as paperTools, c6 as parseSpotUserDataEvent, c7 as parseUserDataEvent, c8 as roundToStep, c9 as spotTools, ca as stepDecimals, cb as symbolRulesFrom, cc as textResult, cd as toAnthropicTool, ce as toJsonSchema, cf as toMCPTool, cg as toOpenAITool, ch as toToolList, ci as toolkitToFormats, cj as tradingTools, ck as wsTools } from './index-D2T_Rhwj.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import 'node:events';
|
|
6
|
+
|
|
7
|
+
type Environment = 'live' | 'testnet' | 'demo';
|
|
8
|
+
interface Endpoints {
|
|
9
|
+
restRoot: string;
|
|
10
|
+
restFapi: string;
|
|
11
|
+
restFuturesData: string;
|
|
12
|
+
restSpot: string;
|
|
13
|
+
wsMarket: string;
|
|
14
|
+
wsUser: string;
|
|
15
|
+
wsApi: string;
|
|
16
|
+
wsSpotMarket: string;
|
|
17
|
+
wsSpotUser: string;
|
|
18
|
+
}
|
|
19
|
+
declare function resolveEnvironment(options?: {
|
|
20
|
+
testnet?: boolean;
|
|
21
|
+
demo?: boolean;
|
|
22
|
+
apiBase?: string;
|
|
23
|
+
wsBase?: string;
|
|
24
|
+
wsUserBase?: string;
|
|
25
|
+
wsApiBase?: string;
|
|
26
|
+
}): {
|
|
27
|
+
env: Environment;
|
|
28
|
+
endpoints: Endpoints;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type PaperPositionSide = 'LONG' | 'SHORT' | 'NONE';
|
|
32
|
+
interface PaperPosition {
|
|
33
|
+
symbol: string;
|
|
34
|
+
side: PaperPositionSide;
|
|
35
|
+
entryPrice: number;
|
|
36
|
+
quantity: number;
|
|
37
|
+
leverage: number;
|
|
38
|
+
/** Margin currently allocated to this position, released proportionally as it is reduced. */
|
|
39
|
+
margin: number;
|
|
40
|
+
unrealizedPnl: number;
|
|
41
|
+
openedAt: number;
|
|
42
|
+
}
|
|
43
|
+
interface PaperOrder {
|
|
44
|
+
orderId: number;
|
|
45
|
+
symbol: string;
|
|
46
|
+
side: 'BUY' | 'SELL';
|
|
47
|
+
type: 'MARKET' | 'LIMIT';
|
|
48
|
+
quantity: number;
|
|
49
|
+
price: number;
|
|
50
|
+
status: 'FILLED';
|
|
51
|
+
filledQuantity: number;
|
|
52
|
+
avgFillPrice: number;
|
|
53
|
+
/** Realized PnL booked by this order, if it reduced or closed a position. */
|
|
54
|
+
realizedPnl: number;
|
|
55
|
+
createdAt: number;
|
|
56
|
+
}
|
|
57
|
+
interface PaperAccount {
|
|
58
|
+
/** Wallet balance: starts at initialBalance and moves only with realized PnL. */
|
|
59
|
+
balance: number;
|
|
60
|
+
/** Wallet balance minus margin currently locked in open positions. */
|
|
61
|
+
availableBalance: number;
|
|
62
|
+
/** balance + unrealized PnL. */
|
|
63
|
+
totalWalletBalance: number;
|
|
64
|
+
realizedPnl: number;
|
|
65
|
+
unrealizedPnl: number;
|
|
66
|
+
positions: Record<string, PaperPosition>;
|
|
67
|
+
orders: PaperOrder[];
|
|
68
|
+
}
|
|
69
|
+
interface PaperTradingOptions {
|
|
70
|
+
initialBalance?: number;
|
|
71
|
+
/** Injectable so tests and offline callers can supply their own price source. */
|
|
72
|
+
market?: FuturesMarket;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* In-memory simulator for USD-M futures fills. Prices come from the live public
|
|
76
|
+
* market endpoints; nothing is ever sent to the exchange.
|
|
77
|
+
*
|
|
78
|
+
* Accounting model: `balance` moves only on realized PnL. Opening a position locks
|
|
79
|
+
* `notional / leverage` of margin out of `availableBalance`; reducing it releases
|
|
80
|
+
* that margin pro-rata and books the realized PnL. Orders fill instantly at the
|
|
81
|
+
* current mark for MARKET, or at the stated limit price for LIMIT — there is no
|
|
82
|
+
* order book simulation, slippage or funding.
|
|
83
|
+
*/
|
|
84
|
+
declare class PaperTradingEngine {
|
|
85
|
+
private readonly account;
|
|
86
|
+
private readonly market;
|
|
87
|
+
private orderIdCounter;
|
|
88
|
+
constructor(options?: PaperTradingOptions);
|
|
89
|
+
/** Current mark price for any tradeable symbol. */
|
|
90
|
+
getMarketPrice(symbol: string): Promise<number>;
|
|
91
|
+
private positionFor;
|
|
92
|
+
placeOrder(params: {
|
|
93
|
+
symbol: string;
|
|
94
|
+
side: 'BUY' | 'SELL';
|
|
95
|
+
type: 'MARKET' | 'LIMIT';
|
|
96
|
+
quantity: number;
|
|
97
|
+
price?: number;
|
|
98
|
+
leverage?: number;
|
|
99
|
+
}): Promise<PaperOrder>;
|
|
100
|
+
/**
|
|
101
|
+
* Apply a fill to a position, returning the realized PnL it booked.
|
|
102
|
+
* Handles extend, partial reduce, full close, and a flip through zero.
|
|
103
|
+
*/
|
|
104
|
+
private applyFill;
|
|
105
|
+
private openExposure;
|
|
106
|
+
/** Reduce a position, releasing margin pro-rata and booking realized PnL. */
|
|
107
|
+
private reduceExposure;
|
|
108
|
+
private markToMarket;
|
|
109
|
+
private recomputeTotals;
|
|
110
|
+
/** Refresh unrealized PnL for every open position against live prices. */
|
|
111
|
+
updatePositions(): Promise<void>;
|
|
112
|
+
getAccountInfo(): PaperAccount;
|
|
113
|
+
getPosition(symbol: string): PaperPosition | undefined;
|
|
114
|
+
getAllPositions(): Record<string, PaperPosition>;
|
|
115
|
+
/** Open positions only — the zero-size entries left behind by closed trades are filtered out. */
|
|
116
|
+
getOpenPositions(): PaperPosition[];
|
|
117
|
+
getOrderHistory(symbol?: string): PaperOrder[];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare const WsKlinePayloadSchema: z.ZodObject<{
|
|
121
|
+
e: z.ZodLiteral<"kline">;
|
|
122
|
+
E: z.ZodNumber;
|
|
123
|
+
s: z.ZodString;
|
|
124
|
+
k: z.ZodObject<{
|
|
125
|
+
t: z.ZodNumber;
|
|
126
|
+
T: z.ZodNumber;
|
|
127
|
+
s: z.ZodString;
|
|
128
|
+
i: z.ZodString;
|
|
129
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
130
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
131
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
132
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
133
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
134
|
+
n: z.ZodNumber;
|
|
135
|
+
x: z.ZodBoolean;
|
|
136
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
137
|
+
V: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
138
|
+
Q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
type WsKlinePayload = z.infer<typeof WsKlinePayloadSchema>;
|
|
142
|
+
declare const WsAggTradePayloadSchema: z.ZodObject<{
|
|
143
|
+
e: z.ZodLiteral<"aggTrade">;
|
|
144
|
+
E: z.ZodNumber;
|
|
145
|
+
s: z.ZodString;
|
|
146
|
+
a: z.ZodNumber;
|
|
147
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
148
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
149
|
+
f: z.ZodNumber;
|
|
150
|
+
l: z.ZodNumber;
|
|
151
|
+
T: z.ZodNumber;
|
|
152
|
+
m: z.ZodBoolean;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
type WsAggTradePayload = z.infer<typeof WsAggTradePayloadSchema>;
|
|
155
|
+
declare const WsTradePayloadSchema: z.ZodObject<{
|
|
156
|
+
e: z.ZodLiteral<"trade">;
|
|
157
|
+
E: z.ZodNumber;
|
|
158
|
+
s: z.ZodString;
|
|
159
|
+
t: z.ZodNumber;
|
|
160
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
161
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
162
|
+
T: z.ZodNumber;
|
|
163
|
+
m: z.ZodBoolean;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
type WsTradePayload = z.infer<typeof WsTradePayloadSchema>;
|
|
166
|
+
declare const WsDepthUpdatePayloadSchema: z.ZodObject<{
|
|
167
|
+
e: z.ZodLiteral<"depthUpdate">;
|
|
168
|
+
E: z.ZodNumber;
|
|
169
|
+
s: z.ZodString;
|
|
170
|
+
U: z.ZodNumber;
|
|
171
|
+
u: z.ZodNumber;
|
|
172
|
+
T: z.ZodOptional<z.ZodNumber>;
|
|
173
|
+
pu: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
b: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
175
|
+
a: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
type WsDepthUpdatePayload = z.infer<typeof WsDepthUpdatePayloadSchema>;
|
|
178
|
+
declare const WsTicker24hrPayloadSchema: z.ZodObject<{
|
|
179
|
+
e: z.ZodLiteral<"24hrTicker">;
|
|
180
|
+
E: z.ZodNumber;
|
|
181
|
+
s: z.ZodString;
|
|
182
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
183
|
+
P: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
184
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
185
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
186
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
187
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
188
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
189
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
type WsTicker24hrPayload = z.infer<typeof WsTicker24hrPayloadSchema>;
|
|
192
|
+
declare const WsBookTickerPayloadSchema: z.ZodObject<{
|
|
193
|
+
u: z.ZodNumber;
|
|
194
|
+
s: z.ZodString;
|
|
195
|
+
b: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
196
|
+
B: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
197
|
+
a: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
198
|
+
A: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
type WsBookTickerPayload = z.infer<typeof WsBookTickerPayloadSchema>;
|
|
201
|
+
declare const WsMarkPricePayloadSchema: z.ZodObject<{
|
|
202
|
+
e: z.ZodLiteral<"markPriceUpdate">;
|
|
203
|
+
E: z.ZodNumber;
|
|
204
|
+
s: z.ZodString;
|
|
205
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
206
|
+
i: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
207
|
+
P: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
208
|
+
r: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
209
|
+
T: z.ZodNumber;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
type WsMarkPricePayload = z.infer<typeof WsMarkPricePayloadSchema>;
|
|
212
|
+
declare const WsMiniTickerPayloadSchema: z.ZodObject<{
|
|
213
|
+
e: z.ZodLiteral<"24hrMiniTicker">;
|
|
214
|
+
E: z.ZodNumber;
|
|
215
|
+
s: z.ZodString;
|
|
216
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
217
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
218
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
219
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
220
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
221
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
222
|
+
}, z.core.$strip>;
|
|
223
|
+
type WsMiniTickerPayload = z.infer<typeof WsMiniTickerPayloadSchema>;
|
|
224
|
+
declare const WsForceOrderPayloadSchema: z.ZodObject<{
|
|
225
|
+
e: z.ZodLiteral<"forceOrder">;
|
|
226
|
+
E: z.ZodNumber;
|
|
227
|
+
o: z.ZodObject<{
|
|
228
|
+
s: z.ZodString;
|
|
229
|
+
S: z.ZodString;
|
|
230
|
+
o: z.ZodString;
|
|
231
|
+
f: z.ZodString;
|
|
232
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
233
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
234
|
+
ap: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
235
|
+
X: z.ZodString;
|
|
236
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
237
|
+
z: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
238
|
+
T: z.ZodNumber;
|
|
239
|
+
}, z.core.$strip>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
type WsForceOrderPayload = z.infer<typeof WsForceOrderPayloadSchema>;
|
|
242
|
+
declare const WsCompositeIndexPayloadSchema: z.ZodObject<{
|
|
243
|
+
e: z.ZodLiteral<"compositeIndex">;
|
|
244
|
+
E: z.ZodNumber;
|
|
245
|
+
s: z.ZodString;
|
|
246
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
247
|
+
c: z.ZodArray<z.ZodObject<{
|
|
248
|
+
b: z.ZodString;
|
|
249
|
+
q: z.ZodString;
|
|
250
|
+
w: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
251
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
252
|
+
}, z.core.$strip>>;
|
|
253
|
+
}, z.core.$strip>;
|
|
254
|
+
type WsCompositeIndexPayload = z.infer<typeof WsCompositeIndexPayloadSchema>;
|
|
255
|
+
declare const WsAssetIndexPayloadSchema: z.ZodObject<{
|
|
256
|
+
e: z.ZodLiteral<"assetIndex">;
|
|
257
|
+
E: z.ZodNumber;
|
|
258
|
+
s: z.ZodString;
|
|
259
|
+
i: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
260
|
+
b: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
261
|
+
a: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
type WsAssetIndexPayload = z.infer<typeof WsAssetIndexPayloadSchema>;
|
|
264
|
+
declare const WsRollingWindowTickerPayloadSchema: z.ZodObject<{
|
|
265
|
+
e: z.ZodEnum<{
|
|
266
|
+
"1hTicker": "1hTicker";
|
|
267
|
+
"4hTicker": "4hTicker";
|
|
268
|
+
"1dTicker": "1dTicker";
|
|
269
|
+
"7dTicker": "7dTicker";
|
|
270
|
+
"30dTicker": "30dTicker";
|
|
271
|
+
}>;
|
|
272
|
+
E: z.ZodNumber;
|
|
273
|
+
s: z.ZodString;
|
|
274
|
+
p: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
275
|
+
P: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
276
|
+
o: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
277
|
+
h: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
278
|
+
l: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
279
|
+
c: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
280
|
+
v: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
281
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
282
|
+
O: z.ZodNumber;
|
|
283
|
+
C: z.ZodNumber;
|
|
284
|
+
}, z.core.$strip>;
|
|
285
|
+
type WsRollingWindowTickerPayload = z.infer<typeof WsRollingWindowTickerPayloadSchema>;
|
|
286
|
+
declare const WsSpotAvgPricePayloadSchema: z.ZodObject<{
|
|
287
|
+
e: z.ZodLiteral<"avgPrice">;
|
|
288
|
+
E: z.ZodNumber;
|
|
289
|
+
s: z.ZodString;
|
|
290
|
+
i: z.ZodString;
|
|
291
|
+
w: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
|
|
292
|
+
T: z.ZodNumber;
|
|
293
|
+
}, z.core.$strip>;
|
|
294
|
+
type WsSpotAvgPricePayload = z.infer<typeof WsSpotAvgPricePayloadSchema>;
|
|
295
|
+
type WsStreamPayload = WsKlinePayload | WsAggTradePayload | WsTradePayload | WsDepthUpdatePayload | WsTicker24hrPayload | WsBookTickerPayload | WsMarkPricePayload | WsMiniTickerPayload | WsForceOrderPayload | WsCompositeIndexPayload | WsAssetIndexPayload | WsRollingWindowTickerPayload | WsSpotAvgPricePayload;
|
|
296
|
+
declare function parseWsPayload(streamName: string, raw: unknown): WsStreamPayload;
|
|
297
|
+
|
|
298
|
+
declare class BinanceError extends Error {
|
|
299
|
+
constructor(message: string);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
declare class BinanceAuthError extends BinanceError {
|
|
303
|
+
readonly missing: 'apiKey' | 'apiSecret';
|
|
304
|
+
constructor(missing: 'apiKey' | 'apiSecret');
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare class BinanceApiError extends BinanceError {
|
|
308
|
+
readonly code: number;
|
|
309
|
+
readonly status: number;
|
|
310
|
+
constructor(message: string, code: number, status: number);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare class RateLimitError extends BinanceApiError {
|
|
314
|
+
readonly retryAfterMs?: number;
|
|
315
|
+
constructor(message: string, code: number, status: number, retryAfterMs?: number);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
declare class NetworkError extends BinanceError {
|
|
319
|
+
readonly cause?: unknown;
|
|
320
|
+
constructor(message: string, cause?: unknown);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare function createBinanceMcpServer(client: BinanceClient): McpServer;
|
|
324
|
+
|
|
325
|
+
declare const VERSION = "2.1.0";
|
|
326
|
+
|
|
327
|
+
export { BinanceApiError, BinanceAuthError, BinanceClient, BinanceError, type Endpoints, type Environment, FuturesMarket, NetworkError, type PaperAccount, type PaperOrder, type PaperPosition, type PaperPositionSide, PaperTradingEngine, type PaperTradingOptions, RateLimitError, VERSION, type WsAggTradePayload, WsAggTradePayloadSchema, type WsAssetIndexPayload, WsAssetIndexPayloadSchema, type WsBookTickerPayload, WsBookTickerPayloadSchema, type WsCompositeIndexPayload, WsCompositeIndexPayloadSchema, type WsDepthUpdatePayload, WsDepthUpdatePayloadSchema, type WsForceOrderPayload, WsForceOrderPayloadSchema, type WsKlinePayload, WsKlinePayloadSchema, type WsMarkPricePayload, WsMarkPricePayloadSchema, type WsMiniTickerPayload, WsMiniTickerPayloadSchema, type WsRollingWindowTickerPayload, WsRollingWindowTickerPayloadSchema, type WsSpotAvgPricePayload, WsSpotAvgPricePayloadSchema, type WsStreamPayload, type WsTicker24hrPayload, WsTicker24hrPayloadSchema, type WsTradePayload, WsTradePayloadSchema, createBinanceMcpServer, parseWsPayload, resolveEnvironment };
|