Adding Missing Exchanges and Markets

This commit is contained in:
Luis Fernando Molina committed 2020-03-05 19:13:27 +01:00
1 parent f724d4f260
commit d26d54466b
1926 files changed
+241463 -163648

No files matched your search

+95 -9
View File
@@ -121,6 +121,99 @@ function onBrowserRequest (request, response) {
switch (requestParameters[1]) {
case 'CCXT':
{
getBody(processRequest)
function getBody(callback) {
let body = ''
request.on('data', function (data) {
body += data
// Too much POST data
if (body.length > 1e6) {
request.connection.destroy()
}
})
request.on('end', function () {
callback(body)
})
}
async function processRequest(body) {
try {
let params = JSON.parse(body)
const ccxt = require('ccxt')
switch (params.method) {
case 'fetchMarkets': {
const exchangeClass = ccxt[params.exchangeId]
const exchangeConstructorParams = {
'timeout': 30000,
'enableRateLimit': true,
verbose: false
}
let ccxtExchange = new exchangeClass(exchangeConstructorParams)
let ccxtMarkets = []
if (ccxtExchange.has.fetchMarkets === true) {
ccxtMarkets = await ccxtExchange.fetchMarkets()
}
respondWithContent(JSON.stringify(ccxtMarkets), response)
return
}
case 'listExchanges': {
let exchanges = []
for (let i = 0; i < ccxt.exchanges.length; i++) {
let exchangeId = ccxt.exchanges[i]
const exchangeClass = ccxt[exchangeId]
const exchangeConstructorParams = {
'timeout': 30000,
'enableRateLimit': true,
verbose: false
}
let ccxtExchange
try { ccxtExchange = new exchangeClass(exchangeConstructorParams)}
catch (err) {}
if (ccxtExchange === undefined) {continue}
if (ccxtExchange.has.fetchOHLCV === params.has.fetchOHLCV) {
if (ccxtExchange.has.fetchMarkets === params.has.fetchMarkets) {
if (ccxtExchange.timeframes['1m'] !== undefined) {
let exchange = {
name: ccxtExchange.name,
id: ccxtExchange.id
}
exchanges.push(exchange)
}
}
}
}
respondWithContent(JSON.stringify(exchanges), response)
return
}
}
let content = {
err: global.DEFAULT_FAIL_RESPONSE // method not supported
}
} catch (err) {
if (CONSOLE_LOG === true) { console.log('[INFO] server -> CCXT FetchMarkets -> Could not fetch markets.') }
let error = {
result: 'Fail Because',
message: err.message
}
respondWithContent(JSON.stringify(error), response)
}
}
break
}
case 'ResetLogsAndData':
{
try {
@@ -171,13 +264,6 @@ function onBrowserRequest (request, response) {
}
break
}
case 'MQService':
{
let filePath = process.env.PATH_TO_WEB_SERVER + 'node_modules/@superalgos/mqservice/orderLifeCicle/webDependency.js'
respondWithFile(filePath, response)
break
}
case 'LegacyPlotter.js':
{
@@ -339,7 +425,7 @@ function onBrowserRequest (request, response) {
let fs = require('fs')
try {
let filePath = './AppSchema.json'
let filePath = process.env.APP_SCHEMA_PATH + 'AppSchema.json'
fs.readFile(filePath, onFileRead)
} catch (e) {
console.log('[ERROR] Error reading the App Schema.', e)
@@ -361,7 +447,7 @@ function onBrowserRequest (request, response) {
let fs = require('fs')
try {
let filePath = './Workspace.json'
let filePath = process.env.WORKSPACE_PATH + 'Workspace.json'
fs.readFile(filePath, onFileRead)
} catch (e) {
console.log('[ERROR] Error reading the Workspace.', e)