Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Luis Fernando Molina committed 2019-08-08 09:49:58 +02:00
commit 51a1f0fdae
17 files changed
+521 -450

No files matched your search

+34 -34
View File
@@ -1,51 +1,51 @@
const axios = require('axios')
let fs = require('fs')
const { promisify } = require('util')
const readFileAsync = promisify(fs.readFile);
const readFileAsync = promisify(fs.readFile)
exports.getStrategy = async function () {
try {
if (!global.STRATEGY) {
let executionOnCloud = false
if (process.env.ON_CLOUD !== undefined) {
executionOnCloud = JSON.parse(process.env.ON_CLOUD)
}
try {
if (!global.STRATEGY) {
let executionOnCloud = false
if (process.env.ON_CLOUD !== undefined) {
executionOnCloud = JSON.parse(process.env.ON_CLOUD)
}
if (executionOnCloud) {
const strategizerResponse = await axios({
url: process.env.GATEWAY_ENDPOINT_K8S,
method: 'post',
data: {
query: `
if (executionOnCloud) {
const strategizerResponse = await axios({
url: process.env.GATEWAY_ENDPOINT_K8S,
method: 'post',
data: {
query: `
query($fbSlug: String!){
strategizer_TradingSystemByFb(fbSlug: $fbSlug){
data
}
}
`,
variables: {
fbSlug: process.env.BOT
},
},
headers: {
authorization: process.env.AUTHORIZATION
}
})
if (strategizerResponse.data.errors)
throw new Error(strategizerResponse.data.errors[0].message)
global.STRATEGY = strategizerResponse.data.data.strategizer_TradingSystemByFb.data;
} else {
let fileLocation = process.env.INTER_PROCESS_FILES_PATH + '/definition.json'
let strategy = await readFileAsync(fileLocation, { encoding: 'utf8' })
global.STRATEGY = JSON.parse(strategy)
variables: {
fbSlug: process.env.BOT
}
},
headers: {
authorization: process.env.AUTHORIZATION
}
})
if (strategizerResponse.data.errors) {
throw new Error(strategizerResponse.data.errors[0].message)
}
return global.STRATEGY
} catch (error) {
throw new Error('There has been an error getting the strategy: ', JSON.stringify(error))
global.STRATEGY = strategizerResponse.data.data.strategizer_TradingSystemByFb.data
} else {
let fileLocation = process.env.INTER_PROCESS_FILES_PATH + '/definition.json'
let strategy = await readFileAsync(fileLocation, { encoding: 'utf8' })
global.STRATEGY = JSON.parse(strategy)
}
}
return global.STRATEGY
} catch (error) {
throw new Error('There has been an error getting the strategy: ', JSON.stringify(error))
}
}