Changes to make it work Locally
This commit is contained in:
1 parent
335fd88d3c
commit
fd4344e793
4 files changed
+106
-77
No files matched your search
@@ -45,41 +45,47 @@ function newStrategizerGateway () {
|
||||
return
|
||||
}
|
||||
|
||||
user = JSON.parse(user)
|
||||
let fbSlug = 'simulator-bot-' + user.alias.replace('.', '')
|
||||
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`
|
||||
query($fbSlug: String!){
|
||||
strategizer_TradingSystemByFb(fbSlug: $fbSlug){
|
||||
id
|
||||
fbSlug
|
||||
data
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
variables: {
|
||||
fbSlug: fbSlug
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors))
|
||||
return false
|
||||
if (window.canvasApp.executingAt === 'Local') {
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, 'Local File')
|
||||
thisObject.strategizerData = JSON.parse('{"type":"Definition"}')
|
||||
thisObject.idAtStrategizer = 'Local File'
|
||||
} else {
|
||||
thisObject.strategizerData = JSON.parse(JSON.stringify(graphQLServer.data.data.strategizer_TradingSystemByFb.data))
|
||||
thisObject.idAtStrategizer = graphQLServer.data.data.strategizer_TradingSystemByFb.id
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, thisObject.idAtStrategizer)
|
||||
return true
|
||||
user = JSON.parse(user)
|
||||
let fbSlug = 'simulator-bot-' + user.alias.replace('.', '')
|
||||
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`
|
||||
query($fbSlug: String!){
|
||||
strategizer_TradingSystemByFb(fbSlug: $fbSlug){
|
||||
id
|
||||
fbSlug
|
||||
data
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
variables: {
|
||||
fbSlug: fbSlug
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> GraphQL Error: ' + JSON.stringify(graphQLServer.data.errors))
|
||||
return false
|
||||
} else {
|
||||
thisObject.strategizerData = JSON.parse(JSON.stringify(graphQLServer.data.data.strategizer_TradingSystemByFb.data))
|
||||
thisObject.idAtStrategizer = graphQLServer.data.data.strategizer_TradingSystemByFb.id
|
||||
window.localStorage.setItem(CANVAS_APP_NAME + '.' + MODULE_NAME + '.' + user.alias, thisObject.idAtStrategizer)
|
||||
return true
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.write('[ERROR] loadFromStrategyzer -> err = ' + err.stack)
|
||||
@@ -100,10 +106,6 @@ function newStrategizerGateway () {
|
||||
return
|
||||
}
|
||||
|
||||
user = JSON.parse(user)
|
||||
|
||||
/* See if we need to update or create a new record at the strategizer */
|
||||
|
||||
let tradingSystem = canvas.strategySpace.workspace.getProtocolTradingSystem()
|
||||
if (tradingSystem === undefined || tradingSystem === null) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not save when tradingSystem is null or undefined.')
|
||||
@@ -115,37 +117,52 @@ function newStrategizerGateway () {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not save when idAtStrategizer is null or undefined.')
|
||||
return
|
||||
}
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query: `
|
||||
mutation strategizer_EditTradingSystem
|
||||
(
|
||||
$id: ID!, $data: strategizer_JSON!
|
||||
)
|
||||
{
|
||||
strategizer_EditTradingSystem(id: $id, tradingSystem: { data: $data })
|
||||
{
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: idAtStrategizer,
|
||||
data: tradingSystem
|
||||
|
||||
if (window.canvasApp.executingAt === 'Local') {
|
||||
callServer(tradingSystem, 'SaveDefinition', onSaved)
|
||||
function onSaved (err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
return true
|
||||
} else {
|
||||
logger.write('[ERROR] saveToStrategyzer -> Can not save definition to local server. err = ' + err.messsage)
|
||||
return false
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
} else {
|
||||
user = JSON.parse(user)
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> GraphsQL Error -> graphQLServer.data.errors = ' + JSON.stringify(graphQLServer.data.errors))
|
||||
graphQLServer = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query: `
|
||||
mutation strategizer_EditTradingSystem
|
||||
(
|
||||
$id: ID!, $data: strategizer_JSON!
|
||||
)
|
||||
{
|
||||
strategizer_EditTradingSystem(id: $id, tradingSystem: { data: $data })
|
||||
{
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: idAtStrategizer,
|
||||
data: tradingSystem
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (graphQLServer.data.errors) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> GraphsQL Error -> graphQLServer.data.errors = ' + JSON.stringify(graphQLServer.data.errors))
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
} catch (err) {
|
||||
logger.write('[ERROR] saveToStrategyzer -> err = ' + err.stack)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user