@medievalrain/binance-ts 0.10.0 → 0.12.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 +275 -2
- package/dist/index.js +98 -2
- package/package.json +7 -8
package/dist/index.d.ts
CHANGED
|
@@ -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
|
|
@@ -795,4 +866,206 @@ type FuturesChannels = {
|
|
|
795
866
|
//#region src/websocket/futures/client.d.ts
|
|
796
867
|
declare const createFuturesWebsocketClient: (baseUrl?: string) => WebsocketClient<FuturesChannels>;
|
|
797
868
|
//#endregion
|
|
798
|
-
|
|
869
|
+
//#region src/websocket/futures/types/user.d.ts
|
|
870
|
+
type FuturesListenKeyExpiredEvent = {
|
|
871
|
+
e: "listenKeyExpired";
|
|
872
|
+
E: number;
|
|
873
|
+
listenKey: string;
|
|
874
|
+
};
|
|
875
|
+
type FuturesAccountUpdateEventReason = "DEPOSIT" | "WITHDRAW" | "ORDER" | "FUNDING_FEE" | "WITHDRAW_REJECT" | "ADJUSTMENT" | "INSURANCE_CLEAR" | "ADMIN_DEPOSIT" | "ADMIN_WITHDRAW" | "MARGIN_TRANSFER" | "MARGIN_TYPE_CHANGE" | "ASSET_TRANSFER" | "OPTIONS_PREMIUM_FEE" | "OPTIONS_SETTLE_PROFIT" | "AUTO_EXCHANGE" | "COIN_SWAP_DEPOSIT" | "COIN_SWAP_WITHDRAW";
|
|
876
|
+
type FuturesAccountUpdateEventBalance = {
|
|
877
|
+
a: string;
|
|
878
|
+
wb: string;
|
|
879
|
+
cw: string;
|
|
880
|
+
bc: string;
|
|
881
|
+
};
|
|
882
|
+
type FuturesPositionSide$1 = "LONG" | "SHORT";
|
|
883
|
+
type FuturesAccountUpdateEventPosition = {
|
|
884
|
+
s: string;
|
|
885
|
+
pa: string;
|
|
886
|
+
ep: string;
|
|
887
|
+
bep: string;
|
|
888
|
+
cr: string;
|
|
889
|
+
up: string;
|
|
890
|
+
mt: "isolated" & string & {};
|
|
891
|
+
iw: string;
|
|
892
|
+
ps: FuturesPositionSide$1;
|
|
893
|
+
};
|
|
894
|
+
type FuturesAccountUpdateEvent = {
|
|
895
|
+
e: "ACCOUNT_UPDATE";
|
|
896
|
+
E: number;
|
|
897
|
+
T: number;
|
|
898
|
+
a: {
|
|
899
|
+
m: FuturesAccountUpdateEventReason;
|
|
900
|
+
B: FuturesAccountUpdateEventBalance[];
|
|
901
|
+
P: FuturesAccountUpdateEventPosition[];
|
|
902
|
+
};
|
|
903
|
+
};
|
|
904
|
+
type FuturesMarginCallPosition = {
|
|
905
|
+
s: string;
|
|
906
|
+
ps: FuturesPositionSide$1;
|
|
907
|
+
pa: string;
|
|
908
|
+
mt: "CROSSED" | "ISOLATED";
|
|
909
|
+
iw: string;
|
|
910
|
+
mp: string;
|
|
911
|
+
up: string;
|
|
912
|
+
mm: string;
|
|
913
|
+
};
|
|
914
|
+
type FuturesMarginCallEvent = {
|
|
915
|
+
e: "MARGIN_CALL";
|
|
916
|
+
E: number;
|
|
917
|
+
cw: string;
|
|
918
|
+
p: FuturesMarginCallPosition[];
|
|
919
|
+
};
|
|
920
|
+
type FuturesOrderType$1 = "LIMIT" | "MARKET" | "STOP" | "STOP_MARKET" | "TAKE_PROFIT" | "TAKE_PROFIT_MARKET" | "TRAILING_STOP_MARKET" | "LIQUIDATION";
|
|
921
|
+
type FuturesOrderTimeInForce = "GTC" | "IOC" | "FOK" | "GTX";
|
|
922
|
+
type FuturesOrderExecutionType = "NEW" | "CANCELED" | "CALCULATED" | "EXPIRED" | "TRADE" | "AMENDMENT";
|
|
923
|
+
type FuturesOrderStatus$1 = "NEW" | "PARTIALLY_FILLED" | "FILLED" | "CANCELED" | "EXPIRED" | "EXPIRED_IN_MATCH";
|
|
924
|
+
type FuturesOrderSide$1 = "BUY" | "SELL";
|
|
925
|
+
type FuturesOrderWorkingType = "CONTRACT_PRICE" | "MARK_PRICE";
|
|
926
|
+
type FuturesOrderUpdateEvent = {
|
|
927
|
+
e: "ORDER_TRADE_UPDATE";
|
|
928
|
+
E: number;
|
|
929
|
+
T: number;
|
|
930
|
+
o: {
|
|
931
|
+
s: string;
|
|
932
|
+
c: string;
|
|
933
|
+
S: FuturesOrderSide$1;
|
|
934
|
+
o: FuturesOrderType$1;
|
|
935
|
+
f: FuturesOrderTimeInForce;
|
|
936
|
+
q: string;
|
|
937
|
+
p: string;
|
|
938
|
+
ap: string;
|
|
939
|
+
sp: string;
|
|
940
|
+
x: FuturesOrderExecutionType;
|
|
941
|
+
X: FuturesOrderStatus$1;
|
|
942
|
+
i: number;
|
|
943
|
+
l: string;
|
|
944
|
+
z: string;
|
|
945
|
+
L: string;
|
|
946
|
+
N: string;
|
|
947
|
+
n: string;
|
|
948
|
+
T: number;
|
|
949
|
+
t: number;
|
|
950
|
+
b: string;
|
|
951
|
+
a: string;
|
|
952
|
+
m: boolean;
|
|
953
|
+
R: boolean;
|
|
954
|
+
wt: FuturesOrderWorkingType;
|
|
955
|
+
ot: "TRAILING_STOP_MARKET";
|
|
956
|
+
ps: FuturesPositionSide$1;
|
|
957
|
+
cp: boolean;
|
|
958
|
+
AP: string;
|
|
959
|
+
cr: string;
|
|
960
|
+
pP: boolean;
|
|
961
|
+
si: number;
|
|
962
|
+
ss: number;
|
|
963
|
+
rp: string;
|
|
964
|
+
V: "EXPIRE_TAKER";
|
|
965
|
+
pm: "OPPONENT";
|
|
966
|
+
gtd: number;
|
|
967
|
+
er: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
968
|
+
};
|
|
969
|
+
};
|
|
970
|
+
type FuturesTradeLiteEvent = {
|
|
971
|
+
e: "TRADE_LITE";
|
|
972
|
+
E: number;
|
|
973
|
+
T: number;
|
|
974
|
+
s: string;
|
|
975
|
+
q: string;
|
|
976
|
+
p: string;
|
|
977
|
+
m: boolean;
|
|
978
|
+
c: string;
|
|
979
|
+
S: FuturesPositionSide$1;
|
|
980
|
+
L: string;
|
|
981
|
+
l: string;
|
|
982
|
+
t: number;
|
|
983
|
+
i: number;
|
|
984
|
+
};
|
|
985
|
+
type AccountConfigUpdateEvent = {
|
|
986
|
+
e: "ACCOUNT_CONFIG_UPDATE";
|
|
987
|
+
E: number;
|
|
988
|
+
T: number;
|
|
989
|
+
} & ({
|
|
990
|
+
ac: {
|
|
991
|
+
s: string;
|
|
992
|
+
l: number;
|
|
993
|
+
};
|
|
994
|
+
} | {
|
|
995
|
+
ai: {
|
|
996
|
+
j: boolean;
|
|
997
|
+
};
|
|
998
|
+
});
|
|
999
|
+
type FuturesStrategyStatus = "NEW" | "WORKING" | "CANCELLED" | "EXPIRED";
|
|
1000
|
+
type FuturesStrategyUpdateEvent = {
|
|
1001
|
+
e: "STRATEGY_UPDATE";
|
|
1002
|
+
T: number;
|
|
1003
|
+
E: number;
|
|
1004
|
+
su: {
|
|
1005
|
+
si: number;
|
|
1006
|
+
st: "GRID";
|
|
1007
|
+
ss: FuturesStrategyStatus;
|
|
1008
|
+
s: string;
|
|
1009
|
+
ut: number;
|
|
1010
|
+
c: 8001 | 8002 | 8003 | 8004 | 8005 | 8006 | 8007 | 8008 | 8009 | 8010 | 8011 | 8012 | 8013 | 8014 | 8015;
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
type FuturesGridUpdateEvent = {
|
|
1014
|
+
e: "GRID_UPDATE";
|
|
1015
|
+
T: number;
|
|
1016
|
+
E: number;
|
|
1017
|
+
gu: {
|
|
1018
|
+
si: number;
|
|
1019
|
+
st: "GRID";
|
|
1020
|
+
ss: FuturesStrategyStatus;
|
|
1021
|
+
s: string;
|
|
1022
|
+
r: string;
|
|
1023
|
+
up: string;
|
|
1024
|
+
uq: string;
|
|
1025
|
+
uf: string;
|
|
1026
|
+
mp: string;
|
|
1027
|
+
ut: number;
|
|
1028
|
+
};
|
|
1029
|
+
};
|
|
1030
|
+
type FuturesConditionalOrderTriggerRejectEvent = {
|
|
1031
|
+
e: "CONDITIONAL_ORDER_TRIGGER_REJECT";
|
|
1032
|
+
T: number;
|
|
1033
|
+
E: number;
|
|
1034
|
+
or: {
|
|
1035
|
+
s: string;
|
|
1036
|
+
i: number;
|
|
1037
|
+
r: string;
|
|
1038
|
+
};
|
|
1039
|
+
};
|
|
1040
|
+
type FuturesUserEvent = FuturesListenKeyExpiredEvent | FuturesAccountUpdateEvent | FuturesMarginCallEvent | FuturesOrderUpdateEvent | FuturesTradeLiteEvent | AccountConfigUpdateEvent | FuturesStrategyUpdateEvent | FuturesGridUpdateEvent | FuturesConditionalOrderTriggerRejectEvent;
|
|
1041
|
+
declare const futuresEventRouting: {
|
|
1042
|
+
readonly listenKeyExpired: "listenKeyExpired";
|
|
1043
|
+
readonly accountUpdate: "ACCOUNT_UPDATE";
|
|
1044
|
+
readonly marginCall: "MARGIN_CALL";
|
|
1045
|
+
readonly orderTradeUpdate: "ORDER_TRADE_UPDATE";
|
|
1046
|
+
readonly tradeLite: "TRADE_LITE";
|
|
1047
|
+
readonly accountConfigUpdate: "ACCOUNT_CONFIG_UPDATE";
|
|
1048
|
+
readonly strategyUpdate: "STRATEGY_UPDATE";
|
|
1049
|
+
readonly gridUpdate: "GRID_UPDATE";
|
|
1050
|
+
readonly conditionalOrderTriggerReject: "CONDITIONAL_ORDER_TRIGGER_REJECT";
|
|
1051
|
+
};
|
|
1052
|
+
type InferFutruresUserEvent<EventName extends FuturesUserEvent["e"]> = Extract<FuturesUserEvent, {
|
|
1053
|
+
e: EventName;
|
|
1054
|
+
}>;
|
|
1055
|
+
type FuturesUserWebsocketClient = { [MethodName in keyof typeof futuresEventRouting]: {
|
|
1056
|
+
on: (callback: (data: InferFutruresUserEvent<(typeof futuresEventRouting)[MethodName]>, options?: CallbackOptions) => void) => void;
|
|
1057
|
+
off: (callback: (data: InferFutruresUserEvent<(typeof futuresEventRouting)[MethodName]>, options?: CallbackOptions) => void, options?: CallbackOptions) => void;
|
|
1058
|
+
} };
|
|
1059
|
+
//#endregion
|
|
1060
|
+
//#region src/websocket/futures/user.d.ts
|
|
1061
|
+
declare const createFuturesUserWebsocketClient: ({
|
|
1062
|
+
baseUrl,
|
|
1063
|
+
apiKey,
|
|
1064
|
+
apiSecret
|
|
1065
|
+
}: {
|
|
1066
|
+
baseUrl?: string;
|
|
1067
|
+
apiKey: string;
|
|
1068
|
+
apiSecret: string;
|
|
1069
|
+
}) => Promise<FuturesUserWebsocketClient>;
|
|
1070
|
+
//#endregion
|
|
1071
|
+
export { ApiError, BinanceRestClient, 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, createFuturesUserWebsocketClient, createFuturesWebsocketClient };
|
package/dist/index.js
CHANGED
|
@@ -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
|
|
@@ -599,9 +613,91 @@ const symbolConverter = {
|
|
|
599
613
|
return `${symbol.toLowerCase()}@aggTrade`;
|
|
600
614
|
}
|
|
601
615
|
};
|
|
602
|
-
const createFuturesWebsocketClient = (baseUrl = "wss://
|
|
616
|
+
const createFuturesWebsocketClient = (baseUrl = "wss://fstream.binance.com/ws") => {
|
|
603
617
|
return createWebsocketClient(baseUrl, symbolConverter);
|
|
604
618
|
};
|
|
605
619
|
|
|
606
620
|
//#endregion
|
|
607
|
-
|
|
621
|
+
//#region src/websocket/futures/types/user.ts
|
|
622
|
+
const futuresEventRouting = {
|
|
623
|
+
listenKeyExpired: "listenKeyExpired",
|
|
624
|
+
accountUpdate: "ACCOUNT_UPDATE",
|
|
625
|
+
marginCall: "MARGIN_CALL",
|
|
626
|
+
orderTradeUpdate: "ORDER_TRADE_UPDATE",
|
|
627
|
+
tradeLite: "TRADE_LITE",
|
|
628
|
+
accountConfigUpdate: "ACCOUNT_CONFIG_UPDATE",
|
|
629
|
+
strategyUpdate: "STRATEGY_UPDATE",
|
|
630
|
+
gridUpdate: "GRID_UPDATE",
|
|
631
|
+
conditionalOrderTriggerReject: "CONDITIONAL_ORDER_TRIGGER_REJECT"
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/websocket/futures/user.ts
|
|
636
|
+
const createFuturesUserWebsocketClient = async ({ baseUrl = "wss://fstream.binance.com/ws", apiKey, apiSecret }) => {
|
|
637
|
+
let socket;
|
|
638
|
+
const futuresRestClient = new FuturesRestClient({
|
|
639
|
+
apiKey,
|
|
640
|
+
apiSecret
|
|
641
|
+
});
|
|
642
|
+
let connectionController = new AbortController();
|
|
643
|
+
let listenKeyUpdateInterval;
|
|
644
|
+
const emitter = createEmitter();
|
|
645
|
+
const invertedRouting = Object.fromEntries(Object.entries(futuresEventRouting).map(([key, value]) => [value, key]));
|
|
646
|
+
const parseMessageEvent = (e) => {
|
|
647
|
+
if (typeof e.data !== "string") return;
|
|
648
|
+
const data = JSON.parse(e.data);
|
|
649
|
+
const routedEvent = invertedRouting[data.e];
|
|
650
|
+
emitter.emit(routedEvent, data);
|
|
651
|
+
};
|
|
652
|
+
const on = (method, callback, options) => {
|
|
653
|
+
emitter.on(method, callback, options);
|
|
654
|
+
};
|
|
655
|
+
const off = (method, callback) => {
|
|
656
|
+
emitter.off(method, callback);
|
|
657
|
+
};
|
|
658
|
+
const connect = async () => {
|
|
659
|
+
return new Promise((resolve) => {
|
|
660
|
+
if (!socket || socket.readyState === WebSocket.CLOSED) {
|
|
661
|
+
clearInterval(listenKeyUpdateInterval);
|
|
662
|
+
futuresRestClient.getListenKey().then(({ listenKey: newListenKey }) => {
|
|
663
|
+
let listenKey = newListenKey;
|
|
664
|
+
let url = `${baseUrl}/${listenKey}`;
|
|
665
|
+
listenKeyUpdateInterval = setInterval(async () => {
|
|
666
|
+
listenKey = (await futuresRestClient.getListenKey()).listenKey;
|
|
667
|
+
}, 30 * 1e3 * 60);
|
|
668
|
+
connectionController.abort();
|
|
669
|
+
socket = new WebSocket(url);
|
|
670
|
+
connectionController = new AbortController();
|
|
671
|
+
socket.addEventListener("open", () => {
|
|
672
|
+
socket.addEventListener("message", parseMessageEvent, { signal: connectionController.signal });
|
|
673
|
+
resolve();
|
|
674
|
+
}, { once: true });
|
|
675
|
+
});
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
if (socket.readyState === WebSocket.OPEN) return resolve();
|
|
679
|
+
if (socket.readyState === WebSocket.CONNECTING) socket.addEventListener("open", () => {
|
|
680
|
+
socket.addEventListener("message", parseMessageEvent, { signal: connectionController.signal });
|
|
681
|
+
resolve();
|
|
682
|
+
}, { once: true });
|
|
683
|
+
if (socket.readyState === WebSocket.CLOSING) socket.addEventListener("close", async () => {
|
|
684
|
+
await connect();
|
|
685
|
+
resolve();
|
|
686
|
+
}, { once: true });
|
|
687
|
+
});
|
|
688
|
+
};
|
|
689
|
+
await connect();
|
|
690
|
+
return new Proxy({}, { get(_target, method) {
|
|
691
|
+
return Object.freeze({
|
|
692
|
+
on: (callback, options) => {
|
|
693
|
+
on(method, callback, options);
|
|
694
|
+
},
|
|
695
|
+
off: (callback) => {
|
|
696
|
+
off(method, callback);
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
} });
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
//#endregion
|
|
703
|
+
export { ApiError, BinanceRestClient, ErrorMessageParsingError, MalformedParamError, ResponseError, WeightError, createFuturesUserWebsocketClient, createFuturesWebsocketClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medievalrain/binance-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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.
|
|
39
|
+
"@medievalrain/emitter": "0.8.0"
|
|
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
|