ALGO node progress
This commit is contained in:
1 parent
e0b79e4b4a
commit
7e51bf8e9b
31 files changed
+645
-2609
No files matched your search
@@ -0,0 +1,47 @@
|
||||
const axios = require('axios')
|
||||
|
||||
exports.getStrategy = async function () {
|
||||
try {
|
||||
|
||||
let strategyOnlyOnce = true
|
||||
if (process.env.STRATEGY_ONLY_ONCE !== undefined)
|
||||
strategyOnlyOnce = JSON.parse(process.env.STRATEGY_ONLY_ONCE)
|
||||
|
||||
if (!global.STRATEGY || !strategyOnlyOnce) {
|
||||
|
||||
let fbSlug = process.env.BOT
|
||||
if (process.env.TEST_FB !== undefined) {
|
||||
fbSlug = process.env.TEST_FB
|
||||
}
|
||||
|
||||
const strategizerResponse = await axios({
|
||||
url: process.env.STRATEGIZER_ENDPOINT || process.env.GATEWAY_ENDPOINT,
|
||||
method: 'post',
|
||||
data: {
|
||||
query: `
|
||||
query($fbSlug: String!){
|
||||
strategizer_TradingSystemByFb(fbSlug: $fbSlug){
|
||||
data
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
fbSlug: fbSlug
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
access_token: process.env.ACCESS_TOKEN
|
||||
}
|
||||
})
|
||||
|
||||
if (strategizerResponse.data.errors)
|
||||
throw new Error(strategizerResponse.data.errors[0].message)
|
||||
|
||||
global.STRATEGY = strategizerResponse.data.data.strategizer_TradingSystemByFb.data;
|
||||
}
|
||||
return global.STRATEGY
|
||||
|
||||
} catch (error) {
|
||||
throw new Error('There has been an error getting the strategy: ' + error)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user