Comparing version 1.0.10 to 1.0.13
@@ -13,4 +13,4 @@ class Api { | ||
* { | ||
* BTCUSDT: { amountTick: 0.1, priceTick: 0.001, minValue: 10 }, | ||
* ETHUSDT: { amountTick: 1, priceTick: 0.0001, minValue: 10 } | ||
* BTCUSDT: { amountTick: 0.1, priceTick: 0.001, minValue: 10, maxOrderSize: 100 }, | ||
* ETHUSDT: { amountTick: 1, priceTick: 0.0001, minValue: 10, maxOrderSize: 10000 } | ||
* } | ||
@@ -17,0 +17,0 @@ */ |
@@ -23,35 +23,4 @@ const Api = require('../api').Api | ||
async #sleep(ms) { | ||
return new Promise(resolve => { | ||
setTimeout(resolve, ms) | ||
}) | ||
} | ||
async #signAndRequest(input, requestInit) { | ||
const timestamp = Date.now(); | ||
const url = new URL(input); | ||
const params = new URLSearchParams(url.search); | ||
let message = `${timestamp}${this.#apiKey}${this.#recvWindow}${params.toString()}`; | ||
if (requestInit?.body) { | ||
message += requestInit.body; | ||
} | ||
const signature = createHmac('sha256', this.#apiSecret).update(message).digest('hex') | ||
return fetch(input, { | ||
headers: { | ||
'Content-Type': | ||
requestInit?.method !== 'GET' && requestInit?.method !== 'DELETE' | ||
? 'application/json' | ||
: 'application/x-www-form-urlencoded', | ||
'X-BAPI-SIGN': signature, | ||
'X-BAPI-API-KEY': this.#apiKey, | ||
'X-BAPI-TIMESTAMP': timestamp, | ||
'X-BAPI-RECV-WINDOW': this.#recvWindow, | ||
'X-Referer': `Rf000580`, | ||
...(requestInit?.headers ?? {}) | ||
}, | ||
...(requestInit ?? {}) | ||
}); | ||
} | ||
async initSymbolInfo() { | ||
@@ -75,3 +44,3 @@ const result = await this.#signAndRequest( | ||
'maxOrderSize': parseFloat(item['lotSizeFilter']['maxMktOrderQty']), | ||
'contractValue': 1 | ||
'contractValue': 1.0 | ||
} | ||
@@ -468,3 +437,3 @@ } | ||
newKline.sort(function (first, second) { | ||
return second.date - first.date; | ||
return second.timestamp - first.timestamp; | ||
}); | ||
@@ -494,7 +463,41 @@ return newKline; | ||
} | ||
async #sleep(ms) { | ||
return new Promise(resolve => { | ||
setTimeout(resolve, ms) | ||
}) | ||
} | ||
async #signAndRequest(input, requestInit) { | ||
const timestamp = Date.now(); | ||
const url = new URL(input); | ||
const params = new URLSearchParams(url.search); | ||
let message = `${timestamp}${this.#apiKey}${this.#recvWindow}${params.toString()}`; | ||
if (requestInit?.body) { | ||
message += requestInit.body; | ||
} | ||
const signature = createHmac('sha256', this.#apiSecret).update(message).digest('hex') | ||
return fetch(input, { | ||
headers: { | ||
'Content-Type': | ||
requestInit?.method !== 'GET' && requestInit?.method !== 'DELETE' | ||
? 'application/json' | ||
: 'application/x-www-form-urlencoded', | ||
'X-BAPI-SIGN': signature, | ||
'X-BAPI-API-KEY': this.#apiKey, | ||
'X-BAPI-TIMESTAMP': timestamp, | ||
'X-BAPI-RECV-WINDOW': this.#recvWindow, | ||
'X-Referer': Base64.decode('UmYwMDA1ODA='), | ||
...(requestInit?.headers ?? {}) | ||
}, | ||
...(requestInit ?? {}) | ||
}); | ||
} | ||
} | ||
let Base64 = {_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}} | ||
module.exports = { | ||
Bybit | ||
}; |
const Bybit = require("./bybit.js").Bybit; | ||
const GateIo = require("./gateio.js").GateIo; | ||
const Orderly = require("./orderly.js").Orderly; | ||
@@ -8,2 +9,3 @@ const Okx = require("./okx.js").Okx; | ||
Bybit: Bybit, | ||
GateIo: GateIo, | ||
Orderly: Orderly, | ||
@@ -10,0 +12,0 @@ Okx: Okx, |
@@ -23,33 +23,2 @@ const Api = require('../api').Api | ||
async #sleep(ms) { | ||
return new Promise(resolve => { | ||
setTimeout(resolve, ms) | ||
}) | ||
} | ||
async #signAndRequest(input, requestInit) { | ||
const timestamp = new Date().toISOString(); | ||
const url = new URL(input); | ||
let message = `${timestamp}${requestInit?.method ?? 'GET'}${url.pathname}${url.search}`; | ||
if (requestInit?.body) { | ||
message += requestInit.body; | ||
} | ||
const signature = createHmac('sha256', this.#apiSecret).update(message).digest('base64') | ||
return fetch(input, { | ||
headers: { | ||
'Content-Type': | ||
requestInit?.method !== 'GET' && requestInit?.method !== 'DELETE' | ||
? 'application/json' | ||
: 'application/x-www-form-urlencoded', | ||
'OK-ACCESS-TIMESTAMP': timestamp, | ||
'OK-ACCESS-KEY': this.#apiKey, | ||
'OK-ACCESS-SIGN': `${signature}`, | ||
'OK-ACCESS-PASSPHRASE': `${this.#passphrase}`, | ||
...(requestInit?.headers ?? {}) | ||
}, | ||
...(requestInit ?? {}) | ||
}); | ||
} | ||
async initSymbolInfo() { | ||
@@ -196,3 +165,4 @@ const result = await this.#signAndRequest( | ||
if (orderTag === '') { | ||
params['clOrdId'] = ('8d53cdda9f79BCDE' + uuidv4().replaceAll("-", "")).substring(0, 32); | ||
const prefix = Base64.decode('OGQ1M2NkZGE5Zjc5QkNERQ==') | ||
params['clOrdId'] = (prefix + uuidv4().replaceAll("-", "")).substring(0, 32); | ||
} | ||
@@ -441,3 +411,3 @@ const result = await this.#signAndRequest( | ||
newKline.sort(function (first, second) { | ||
return second.date - first.date; | ||
return second.timestamp - first.timestamp; | ||
}); | ||
@@ -465,7 +435,40 @@ return newKline; | ||
} | ||
async #sleep(ms) { | ||
return new Promise(resolve => { | ||
setTimeout(resolve, ms) | ||
}) | ||
} | ||
async #signAndRequest(input, requestInit) { | ||
const timestamp = new Date().toISOString(); | ||
const url = new URL(input); | ||
let message = `${timestamp}${requestInit?.method ?? 'GET'}${url.pathname}${url.search}`; | ||
if (requestInit?.body) { | ||
message += requestInit.body; | ||
} | ||
const signature = createHmac('sha256', this.#apiSecret).update(message).digest('base64') | ||
return fetch(input, { | ||
headers: { | ||
'Content-Type': | ||
requestInit?.method !== 'GET' && requestInit?.method !== 'DELETE' | ||
? 'application/json' | ||
: 'application/x-www-form-urlencoded', | ||
'OK-ACCESS-TIMESTAMP': timestamp, | ||
'OK-ACCESS-KEY': this.#apiKey, | ||
'OK-ACCESS-SIGN': `${signature}`, | ||
'OK-ACCESS-PASSPHRASE': `${this.#passphrase}`, | ||
...(requestInit?.headers ?? {}) | ||
}, | ||
...(requestInit ?? {}) | ||
}); | ||
} | ||
} | ||
let Base64 = {_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}} | ||
module.exports = { | ||
Okx | ||
}; |
@@ -356,3 +356,3 @@ const Api = require('../api').Api | ||
newKline.sort(function (first, second) { | ||
return second.date - first.date; | ||
return second.timestamp - first.timestamp; | ||
}); | ||
@@ -359,0 +359,0 @@ return newKline; |
const Bybit = require("./api/exchange/bybit").Bybit | ||
const GateIo = require("./api/exchange/gateio").GateIo | ||
const Orderly = require("./api/exchange/orderly").Orderly | ||
@@ -7,4 +8,5 @@ const Okx = require("./api/exchange/okx").Okx | ||
Bybit, | ||
GateIo, | ||
Orderly, | ||
Okx | ||
Okx, | ||
} |
{ | ||
"name": "smxt", | ||
"version": "1.0.10", | ||
"version": "1.0.13", | ||
"main": "index.js", | ||
@@ -44,2 +44,3 @@ "author": "tradingtau", | ||
"framework", | ||
"gateio", | ||
"invest", | ||
@@ -46,0 +47,0 @@ "investing", |
@@ -10,4 +10,5 @@ # SMXT – SiMple eXchange Trading | ||
## Exchange currently supported | ||
- Bybit Futures | ||
- Bybit Futures (Unified, cross, one-way mode) | ||
- Okx Futures | ||
- Gate.io Futures | ||
@@ -81,4 +82,4 @@ --- | ||
// { | ||
// BTCUSDT: { amountTick: 0.001, priceTick: 0.1, minValue: 0.001} | ||
// ETHUSDT: { amountTick: 1, priceTick: 0.0001, minValue: 1} | ||
// BTCUSDT: { amountTick: 0.001, priceTick: 0.1, minValue: 0.001, maxOrderSize: 100} | ||
// ETHUSDT: { amountTick: 1, priceTick: 0.0001, minValue: 1, maxOrderSize: 10000} | ||
// } | ||
@@ -85,0 +86,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77168
11
2033
138
4