@@ -71,8 +71,8 @@ export default class Binance {
7171
7272 userAgent = 'Mozilla/4.0 (compatible; Node Binance API)' ;
7373 contentType = 'application/x-www-form-urlencoded' ;
74- SPOT_PREFIX = "x-HNA2TXFJ " ;
75- CONTRACT_PREFIX = "x-Cb7ytekJ " ;
74+ SPOT_PREFIX = "x-B3AUXNYV " ;
75+ CONTRACT_PREFIX = "x-ftGmvgAN " ;
7676
7777 // Websockets Options
7878 isAlive = false ;
@@ -109,7 +109,7 @@ export default class Binance {
109109 userDeliveryData : this . userDeliveryData . bind ( this ) ,
110110 subscribeCombined : this . subscribeCombined . bind ( this ) ,
111111 subscribe : this . subscribe . bind ( this ) ,
112- subscriptions : ( ) => this . getSubscriptions . bind ( this ) ,
112+ subscriptions : ( ) => this . getSubscriptions . bind ( this ) ,
113113 terminate : this . terminate . bind ( this ) ,
114114 depth : this . depthStream . bind ( this ) ,
115115 depthCache : this . depthCacheStream . bind ( this ) ,
@@ -237,7 +237,7 @@ export default class Binance {
237237 return this . base ;
238238 }
239239
240- getSapiUrl ( ) {
240+ getSapiUrl ( ) {
241241 return this . sapi ;
242242 }
243243
@@ -638,6 +638,9 @@ export default class Binance {
638638 return await this . signedRequest /**/ ( this . getSpotUrl ( ) + path , data , method , noDataInSignature ) ;
639639 }
640640
641+ /**
642+ * Create a signed SAPI request
643+ */
641644 async privateSapiRequest ( path : string , data : Dict = { } , method : HttpMethod = 'GET' , noDataInSignature = false ) {
642645 return await this . signedRequest /**/ ( this . getSapiUrl ( ) + path , data , method , noDataInSignature ) ;
643646 }
@@ -661,7 +664,7 @@ export default class Binance {
661664 const query = method === 'POST' && noDataInSignature ? '' : this . makeQueryString ( data ) ;
662665
663666 const signature = this . generateSignature ( query ) ;
664-
667+
665668 if ( method === 'POST' ) {
666669 const opt = this . reqObjPOST (
667670 url ,
@@ -687,7 +690,7 @@ export default class Binance {
687690 generateSignature ( query : string , encode = true ) {
688691 const secret = this . APISECRET || this . PRIVATEKEY ;
689692 let signature = '' ;
690- if ( secret . includes ( 'PRIVATE KEY' ) ) {
693+ if ( secret . includes ( 'PRIVATE KEY' ) ) {
691694 // if less than the below length, then it can't be RSA key
692695 let keyObject : crypto . KeyObject ;
693696 try {
@@ -699,7 +702,7 @@ export default class Binance {
699702
700703 keyObject = crypto . createPrivateKey ( privateKeyObj ) ;
701704
702- } catch ( e ) {
705+ } catch ( e ) {
703706 throw new Error (
704707 'Invalid private key. Please provide a valid RSA or ED25519 private key. ' + e . toString ( )
705708 ) ;
@@ -710,7 +713,7 @@ export default class Binance {
710713 signature = crypto
711714 . sign ( 'RSA-SHA256' , Buffer . from ( query ) , keyObject )
712715 . toString ( 'base64' ) ;
713- if ( encode ) signature = encodeURIComponent ( signature ) ;
716+ if ( encode ) signature = encodeURIComponent ( signature ) ;
714717 return signature ;
715718 } else {
716719 // Ed25519 key
@@ -1089,6 +1092,16 @@ export default class Binance {
10891092 return await this . privateFuturesRequest ( 'v1/order' , params , 'POST' ) ;
10901093 }
10911094
1095+ /**
1096+ * @see https://developers.binance.com/docs/derivatives/option/trade/New-Order
1097+ * @param type type of order to create
1098+ * @param side side of the order (BUY or SELL)
1099+ * @param symbol symbol of the market to trade
1100+ * @param quantity quantity of the order to create
1101+ * @param price price of the order to create
1102+ * @param params extra parameters to be sent in the request
1103+ * @returns
1104+ */
10921105 async deliveryOrder ( type : OrderType , side : string , symbol : string , quantity : number , price ?: number , params : Dict = { } ) : Promise < FuturesOrder > {
10931106 params . symbol = symbol ;
10941107 params . side = side ;
@@ -2216,7 +2229,7 @@ export default class Binance {
22162229 if ( this . Options . verbose ) {
22172230 this . Options . log ( `deliverySubscribe: Subscribed to [${ ws . endpoint } ] ${ queryParams } ` ) ;
22182231 }
2219- ws . on ( 'open' , this . handleDeliverySocketOpen . bind ( this , ws , params . openCallback ) ) ;
2232+ ws . on ( 'open' , this . handleDeliverySocketOpen . bind ( this , ws , params . openCallback ) ) ;
22202233 ws . on ( 'pong' , this . handleDeliverySocketHeartbeat . bind ( this , ws ) ) ;
22212234 ws . on ( 'error' , this . handleDeliverySocketError . bind ( this , ws ) ) ;
22222235 ws . on ( 'close' , this . handleDeliverySocketClose . bind ( this , ws , params . reconnect ) ) ;
@@ -3851,7 +3864,7 @@ export default class Binance {
38513864 async candlesticks ( symbol : string , interval : Interval = '5m' , params : Dict = { } ) : Promise < Candle [ ] > {
38523865 if ( ! params . limit ) params . limit = 500 ;
38533866 params = Object . assign ( { symbol : symbol , interval : interval } , params ) ;
3854- const res = await this . publicSpotRequest ( 'v3/klines' , params ) ;
3867+ const res = await this . publicSpotRequest ( 'v3/klines' , params ) ;
38553868 return this . parseCandles ( res ) ;
38563869 }
38573870
@@ -4037,7 +4050,7 @@ export default class Binance {
40374050 async futuresCandles ( symbol : string , interval : Interval = "30m" , params : Dict = { } ) : Promise < Candle [ ] > {
40384051 params . symbol = symbol ;
40394052 params . interval = interval ;
4040- const res = await this . publicFuturesRequest ( 'v1/klines' , params ) ;
4053+ const res = await this . publicFuturesRequest ( 'v1/klines' , params ) ;
40414054 return this . parseCandles ( res ) ;
40424055 }
40434056
@@ -4357,7 +4370,7 @@ export default class Binance {
43574370 /**
43584371 * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Multiple-Orders
43594372 */
4360- async futuresCancelMultipleOrders ( symbol : string , params : Dict = { } ) : Promise < ( FuturesOrder | Response ) [ ] > {
4373+ async futuresCancelMultipleOrders ( symbol : string , params : Dict = { } ) : Promise < ( FuturesOrder | Response ) [ ] > {
43614374 return await this . privateFuturesRequest ( 'v1/batchOrders' , this . extend ( { 'symbol' : symbol } , params ) , 'DELETE' ) ;
43624375 }
43634376
@@ -4568,7 +4581,7 @@ export default class Binance {
45684581 async deliveryCandles ( symbol : string , interval : Interval = "30m" , params : Dict = { } ) : Promise < Candle [ ] > {
45694582 params . symbol = symbol ;
45704583 params . interval = interval ;
4571- const res = await this . publicDeliveryRequest ( 'v1/klines' , params ) ;
4584+ const res = await this . publicDeliveryRequest ( 'v1/klines' , params ) ;
45724585 return this . parseCandles ( res ) ;
45734586 }
45744587
0 commit comments