@medievalrain/binance-ts 0.11.1 → 0.13.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/dist/index.d.ts +91 -9
- package/dist/index.js +35 -11
- package/package.json +7 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CallbackOptions } from "@medievalrain/emitter";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/rest/base-rest-client.d.ts
|
|
4
4
|
type RawSearchParams = Record<string, string | undefined | null | string[] | number | boolean>;
|
|
5
5
|
declare class BaseRestClient {
|
|
6
6
|
private apiKey?;
|
|
@@ -29,7 +29,7 @@ declare class BaseRestClient {
|
|
|
29
29
|
}: {
|
|
30
30
|
endpoint: string;
|
|
31
31
|
params?: RawSearchParams;
|
|
32
|
-
method: "GET" | "POST" | "DELETE";
|
|
32
|
+
method: "GET" | "POST" | "DELETE" | "PUT";
|
|
33
33
|
}): Promise<NoInfer<T>>;
|
|
34
34
|
private sign;
|
|
35
35
|
private toSearchParams;
|
|
@@ -440,6 +440,61 @@ type FuturesNewOrder = {
|
|
|
440
440
|
type FuturesGetListenKey = {
|
|
441
441
|
listenKey: string;
|
|
442
442
|
};
|
|
443
|
+
type FuturesOrderStatus = "NEW" | "PARTIALLY_FILLED" | "FILLED" | "CANCELED" | "EXPIRED" | "EXPIRED_IN_MATCH";
|
|
444
|
+
type FuturesModifyOrder = {
|
|
445
|
+
orderId: number;
|
|
446
|
+
symbol: string;
|
|
447
|
+
pair: string;
|
|
448
|
+
status?: FuturesOrderStatus;
|
|
449
|
+
clientOrderId: string;
|
|
450
|
+
price: string;
|
|
451
|
+
avgPrice: string;
|
|
452
|
+
origQty: string;
|
|
453
|
+
executedQty: string;
|
|
454
|
+
cumQty: string;
|
|
455
|
+
cumBase: string;
|
|
456
|
+
timeInForce: FuturesTimeInForce;
|
|
457
|
+
type: FuturesOrderType;
|
|
458
|
+
reduceOnly: boolean;
|
|
459
|
+
closePosition: boolean;
|
|
460
|
+
side: FuturesOrderSide;
|
|
461
|
+
positionSide: FuturesPositionSide;
|
|
462
|
+
stopPrice: string;
|
|
463
|
+
workingType: FuturesWorkingType;
|
|
464
|
+
priceProtect: boolean;
|
|
465
|
+
origType: FuturesOrderType;
|
|
466
|
+
priceMatch: FuturesPriceMatch;
|
|
467
|
+
selfTradePreventionMode: FuturesSelfTradePrevention;
|
|
468
|
+
goodTillDate: number;
|
|
469
|
+
updateTime: number;
|
|
470
|
+
};
|
|
471
|
+
type FuturesCancelOrder = {
|
|
472
|
+
clientOrderId: string;
|
|
473
|
+
cumQty: string;
|
|
474
|
+
cumQuote: string;
|
|
475
|
+
executedQty: string;
|
|
476
|
+
orderId: number;
|
|
477
|
+
origQty: string;
|
|
478
|
+
origType: FuturesOrderType;
|
|
479
|
+
price: string;
|
|
480
|
+
reduceOnly: boolean;
|
|
481
|
+
side: FuturesOrderSide;
|
|
482
|
+
positionSide: FuturesPositionSide;
|
|
483
|
+
status: FuturesOrderStatus;
|
|
484
|
+
stopPrice: string;
|
|
485
|
+
closePosition: boolean;
|
|
486
|
+
symbol: string;
|
|
487
|
+
timeInForce: FuturesTimeInForce;
|
|
488
|
+
type: FuturesOrderType;
|
|
489
|
+
activatePrice?: string;
|
|
490
|
+
priceRate?: string;
|
|
491
|
+
updateTime: number;
|
|
492
|
+
workingType: FuturesWorkingType;
|
|
493
|
+
priceProtect: boolean;
|
|
494
|
+
priceMatch: FuturesPriceMatch;
|
|
495
|
+
selfTradePreventionMode: FuturesSelfTradePrevention;
|
|
496
|
+
goodTillDate: number;
|
|
497
|
+
};
|
|
443
498
|
//#endregion
|
|
444
499
|
//#region src/rest/futures/client.d.ts
|
|
445
500
|
declare class FuturesRestClient extends BaseRestClient {
|
|
@@ -643,6 +698,22 @@ declare class FuturesRestClient extends BaseRestClient {
|
|
|
643
698
|
recvWindow?: number;
|
|
644
699
|
}): Promise<FuturesNewOrder>;
|
|
645
700
|
getListenKey(): Promise<FuturesGetListenKey>;
|
|
701
|
+
modifyOrder(params: {
|
|
702
|
+
orderId?: number;
|
|
703
|
+
origClientOrderId?: string;
|
|
704
|
+
symbol: string;
|
|
705
|
+
side: FuturesOrderSide;
|
|
706
|
+
quantity: number;
|
|
707
|
+
price: number;
|
|
708
|
+
priceMatch?: FuturesPriceMatch;
|
|
709
|
+
recvWindow?: number;
|
|
710
|
+
}): Promise<FuturesModifyOrder>;
|
|
711
|
+
cancelOrder(params: {
|
|
712
|
+
orderId?: number;
|
|
713
|
+
origClientOrderId?: string;
|
|
714
|
+
symbol: string;
|
|
715
|
+
recvWindow?: number;
|
|
716
|
+
}): Promise<FuturesCancelOrder>;
|
|
646
717
|
}
|
|
647
718
|
//#endregion
|
|
648
719
|
//#region src/rest/spot/types.d.ts
|
|
@@ -668,8 +739,9 @@ declare class SpotRestClient extends BaseRestClient {
|
|
|
668
739
|
//#endregion
|
|
669
740
|
//#region src/rest/client.d.ts
|
|
670
741
|
declare class BinanceRestClient {
|
|
671
|
-
|
|
672
|
-
|
|
742
|
+
private options?;
|
|
743
|
+
private _futures?;
|
|
744
|
+
private _spot?;
|
|
673
745
|
constructor(options?: {
|
|
674
746
|
apiKey?: string;
|
|
675
747
|
apiSecret?: string;
|
|
@@ -677,10 +749,20 @@ declare class BinanceRestClient {
|
|
|
677
749
|
spot?: string;
|
|
678
750
|
futures?: string;
|
|
679
751
|
};
|
|
680
|
-
});
|
|
752
|
+
} | undefined);
|
|
753
|
+
get futures(): FuturesRestClient;
|
|
754
|
+
get spot(): SpotRestClient;
|
|
681
755
|
}
|
|
756
|
+
declare const createBinanceRestClient: (options?: {
|
|
757
|
+
apiKey?: string;
|
|
758
|
+
apiSecret?: string;
|
|
759
|
+
baseUrls?: {
|
|
760
|
+
spot?: string;
|
|
761
|
+
futures?: string;
|
|
762
|
+
};
|
|
763
|
+
}) => BinanceRestClient;
|
|
682
764
|
//#endregion
|
|
683
|
-
//#region src/
|
|
765
|
+
//#region src/rest/api-error.d.ts
|
|
684
766
|
declare class ApiError extends Error {
|
|
685
767
|
endpoint: string;
|
|
686
768
|
constructor({
|
|
@@ -849,7 +931,7 @@ type FuturesMarginCallEvent = {
|
|
|
849
931
|
type FuturesOrderType$1 = "LIMIT" | "MARKET" | "STOP" | "STOP_MARKET" | "TAKE_PROFIT" | "TAKE_PROFIT_MARKET" | "TRAILING_STOP_MARKET" | "LIQUIDATION";
|
|
850
932
|
type FuturesOrderTimeInForce = "GTC" | "IOC" | "FOK" | "GTX";
|
|
851
933
|
type FuturesOrderExecutionType = "NEW" | "CANCELED" | "CALCULATED" | "EXPIRED" | "TRADE" | "AMENDMENT";
|
|
852
|
-
type FuturesOrderStatus = "NEW" | "PARTIALLY_FILLED" | "FILLED" | "CANCELED" | "EXPIRED" | "EXPIRED_IN_MATCH";
|
|
934
|
+
type FuturesOrderStatus$1 = "NEW" | "PARTIALLY_FILLED" | "FILLED" | "CANCELED" | "EXPIRED" | "EXPIRED_IN_MATCH";
|
|
853
935
|
type FuturesOrderSide$1 = "BUY" | "SELL";
|
|
854
936
|
type FuturesOrderWorkingType = "CONTRACT_PRICE" | "MARK_PRICE";
|
|
855
937
|
type FuturesOrderUpdateEvent = {
|
|
@@ -867,7 +949,7 @@ type FuturesOrderUpdateEvent = {
|
|
|
867
949
|
ap: string;
|
|
868
950
|
sp: string;
|
|
869
951
|
x: FuturesOrderExecutionType;
|
|
870
|
-
X: FuturesOrderStatus;
|
|
952
|
+
X: FuturesOrderStatus$1;
|
|
871
953
|
i: number;
|
|
872
954
|
l: string;
|
|
873
955
|
z: string;
|
|
@@ -997,4 +1079,4 @@ declare const createFuturesUserWebsocketClient: ({
|
|
|
997
1079
|
apiSecret: string;
|
|
998
1080
|
}) => Promise<FuturesUserWebsocketClient>;
|
|
999
1081
|
//#endregion
|
|
1000
|
-
export { ApiError,
|
|
1082
|
+
export { ApiError, ErrorMessageParsingError, FuturesAccountAsset, FuturesAccountBalance, FuturesAccountConfig, FuturesAccountInfo, FuturesAccountPosition, type FuturesAggTradeEvent, FuturesAggregateTrade, FuturesAssetIndex, FuturesBasis, type FuturesBookDepthEvent, FuturesBookTicker, type FuturesBookTickerEvent, FuturesCancelOrder, FuturesCheckServerTime, FuturesCommissionRate, FuturesCompositeIndex, FuturesCompositeIndexAsset, FuturesContractType, FuturesDeliveryPrice, FuturesExchangeInfo, FuturesExchangeInfoAsset, FuturesExchangeInfoFilter, FuturesExchangeInfoRateLimit, FuturesExchangeInfoSymbol, FuturesFundingInfo, FuturesFundingRate, FuturesGetListenKey, FuturesIncomeHistory, FuturesIncomeType, FuturesIndexPriceConstituentItem, FuturesIndexPriceConstituents, FuturesInsuranceBalance, FuturesInsuranceBalanceAsset, FuturesKline, FuturesKlineInterval, FuturesLeverageBracket, FuturesLeverageBracketEntry, FuturesLongShortRatio, FuturesMarkPrice, FuturesModifyOrder, FuturesNewOrder, FuturesNewOrderRespType, FuturesOpenInterest, FuturesOpenInterestPeriod, FuturesOpenInterestStats, FuturesOrderBook, FuturesOrderSide, FuturesOrderStatus, FuturesOrderType, FuturesPositionMode, FuturesPositionSide, FuturesPriceMatch, FuturesSelfTradePrevention, FuturesSymbolConfig, FuturesSymbolPrice, FuturesTakerBuySellRatio, FuturesTestConnectivity, FuturesTicker24h, FuturesTimeInForce, FuturesTrade, FuturesUnderlyingType, FuturesUserRateLimit, FuturesWorkingType, MalformedParamError, PermissionSet, ResponseError, WeightError, createBinanceRestClient, createFuturesUserWebsocketClient, createFuturesWebsocketClient };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHmac } from "node:crypto";
|
|
2
2
|
import { createEmitter } from "@medievalrain/emitter";
|
|
3
3
|
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/rest/api-error.ts
|
|
5
5
|
var ApiError = class extends Error {
|
|
6
6
|
endpoint;
|
|
7
7
|
constructor({ endpoint, metadata }) {
|
|
@@ -73,7 +73,7 @@ var MalformedParamError = class extends ResponseError {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
//#region src/
|
|
76
|
+
//#region src/rest/base-rest-client.ts
|
|
77
77
|
var BaseRestClient = class {
|
|
78
78
|
apiKey;
|
|
79
79
|
apiSecret;
|
|
@@ -398,6 +398,20 @@ var FuturesRestClient = class extends BaseRestClient {
|
|
|
398
398
|
endpoint: "/fapi/v1/listenKey"
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
|
+
async modifyOrder(params) {
|
|
402
|
+
return this.privateRequest({
|
|
403
|
+
method: "PUT",
|
|
404
|
+
endpoint: "/fapi/v1/order",
|
|
405
|
+
params
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
async cancelOrder(params) {
|
|
409
|
+
return this.privateRequest({
|
|
410
|
+
method: "DELETE",
|
|
411
|
+
endpoint: "/fapi/v1/order",
|
|
412
|
+
params
|
|
413
|
+
});
|
|
414
|
+
}
|
|
401
415
|
};
|
|
402
416
|
|
|
403
417
|
//#endregion
|
|
@@ -421,17 +435,27 @@ var SpotRestClient = class extends BaseRestClient {
|
|
|
421
435
|
//#endregion
|
|
422
436
|
//#region src/rest/client.ts
|
|
423
437
|
var BinanceRestClient = class {
|
|
424
|
-
|
|
425
|
-
|
|
438
|
+
_futures;
|
|
439
|
+
_spot;
|
|
426
440
|
constructor(options) {
|
|
427
|
-
this.
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
441
|
+
this.options = options;
|
|
442
|
+
}
|
|
443
|
+
get futures() {
|
|
444
|
+
if (!this._futures) this._futures = new FuturesRestClient({
|
|
445
|
+
apiKey: this.options?.apiKey,
|
|
446
|
+
apiSecret: this.options?.apiSecret,
|
|
447
|
+
baseUrl: this.options?.baseUrls?.futures
|
|
431
448
|
});
|
|
432
|
-
this.
|
|
449
|
+
return this._futures;
|
|
450
|
+
}
|
|
451
|
+
get spot() {
|
|
452
|
+
if (!this._spot) this._spot = new SpotRestClient({ baseUrl: this.options?.baseUrls?.spot });
|
|
453
|
+
return this._spot;
|
|
433
454
|
}
|
|
434
455
|
};
|
|
456
|
+
const createBinanceRestClient = (options) => {
|
|
457
|
+
return new BinanceRestClient(options);
|
|
458
|
+
};
|
|
435
459
|
|
|
436
460
|
//#endregion
|
|
437
461
|
//#region src/websocket/base/client.ts
|
|
@@ -599,7 +623,7 @@ const symbolConverter = {
|
|
|
599
623
|
return `${symbol.toLowerCase()}@aggTrade`;
|
|
600
624
|
}
|
|
601
625
|
};
|
|
602
|
-
const createFuturesWebsocketClient = (baseUrl = "wss://
|
|
626
|
+
const createFuturesWebsocketClient = (baseUrl = "wss://fstream.binance.com/ws") => {
|
|
603
627
|
return createWebsocketClient(baseUrl, symbolConverter);
|
|
604
628
|
};
|
|
605
629
|
|
|
@@ -686,4 +710,4 @@ const createFuturesUserWebsocketClient = async ({ baseUrl = "wss://fstream.binan
|
|
|
686
710
|
};
|
|
687
711
|
|
|
688
712
|
//#endregion
|
|
689
|
-
export { ApiError,
|
|
713
|
+
export { ApiError, ErrorMessageParsingError, MalformedParamError, ResponseError, WeightError, createBinanceRestClient, createFuturesUserWebsocketClient, createFuturesWebsocketClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medievalrain/binance-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Binance API SDK",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"type": "module",
|
|
@@ -25,25 +25,24 @@
|
|
|
25
25
|
"typecheck": "tsc"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/node": "24.9.
|
|
29
|
-
"date-fns": "4.1.0",
|
|
28
|
+
"@types/node": "24.9.2",
|
|
30
29
|
"dotenv": "17.2.3",
|
|
31
|
-
"oxlint": "1.
|
|
30
|
+
"oxlint": "1.25.0",
|
|
32
31
|
"prettier": "3.6.2",
|
|
33
32
|
"ts-to-zod": "5.0.1",
|
|
34
|
-
"tsdown": "0.15.
|
|
33
|
+
"tsdown": "0.15.12",
|
|
35
34
|
"typescript": "5.9.3",
|
|
36
|
-
"vitest": "4.0.
|
|
35
|
+
"vitest": "4.0.6",
|
|
37
36
|
"zod": "4.1.12"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@medievalrain/emitter": "0.8.
|
|
39
|
+
"@medievalrain/emitter": "0.8.1"
|
|
41
40
|
},
|
|
42
41
|
"repository": {
|
|
43
42
|
"type": "git",
|
|
44
43
|
"url": "git+https://github.com/medievalrain/binance-ts.git"
|
|
45
44
|
},
|
|
46
|
-
"packageManager": "pnpm@10.
|
|
45
|
+
"packageManager": "pnpm@10.20.0",
|
|
47
46
|
"publishConfig": {
|
|
48
47
|
"access": "public",
|
|
49
48
|
"provenance": true
|