saving to strategizer part 1: creating the graphql query
This commit is contained in:
1 parent
ac83fa5f5a
commit
716de14b9e
3 files changed
+191
-10
No files matched your search
+10
-10
@@ -3,7 +3,7 @@ function newStrategySpace () {
|
||||
const MODULE_NAME = 'Strategy Space'
|
||||
let thisObject = {
|
||||
sidePanel: undefined,
|
||||
tradingSystemWorkspace: undefined,
|
||||
workplace: undefined,
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
@@ -24,17 +24,17 @@ function newStrategySpace () {
|
||||
// thisObject.sidePanel = newSidePanel()
|
||||
// thisObject.sidePanel.initialize()
|
||||
|
||||
thisObject.tradingSystemWorkspace = newWorkspace()
|
||||
// thisObject.tradingSystemWorkspace.container.connectToParent(thisObject.sidePanel.container, true, true)
|
||||
thisObject.tradingSystemWorkspace.initialize()
|
||||
await thisObject.tradingSystemWorkspace.loadFromStrategyzer()
|
||||
thisObject.workplace = newWorkspace()
|
||||
// thisObject.workplace.container.connectToParent(thisObject.sidePanel.container, true, true)
|
||||
thisObject.workplace.initialize()
|
||||
await thisObject.workplace.loadFromStrategyzer()
|
||||
|
||||
// thisObject.sidePanel.areas.push(thisObject.tradingSystemWorkspace)
|
||||
// thisObject.sidePanel.areas.push(thisObject.workplace)
|
||||
}
|
||||
|
||||
function makeVisible () {
|
||||
if (thisObject.tradingSystemWorkspace.isDeployed !== true) {
|
||||
thisObject.tradingSystemWorkspace.deploydTradingSystem()
|
||||
if (thisObject.workplace.isDeployed !== true) {
|
||||
thisObject.workplace.deploydTradingSystem()
|
||||
}
|
||||
canvas.floatingSpace.makeVisible()
|
||||
visible = true
|
||||
@@ -47,8 +47,8 @@ function newStrategySpace () {
|
||||
function getContainer (point) {
|
||||
let container
|
||||
|
||||
if (thisObject.tradingSystemWorkspace !== undefined) {
|
||||
container = thisObject.tradingSystemWorkspace.getContainer(point)
|
||||
if (thisObject.workplace !== undefined) {
|
||||
container = thisObject.workplace.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
}
|
||||
|
||||
|
||||
@@ -245,6 +245,9 @@ function newTradingSystem () {
|
||||
|
||||
function onMenuItemClick (payload, action) {
|
||||
switch (action) {
|
||||
case 'Save Trading System':
|
||||
canvas.strategySpace.workplace.saveToStrategyzer()
|
||||
break
|
||||
case 'Open Settings':
|
||||
|
||||
break
|
||||
|
||||
@@ -9,7 +9,9 @@ function newWorkspace () {
|
||||
isDeployed: false,
|
||||
strategies: undefined,
|
||||
container: undefined,
|
||||
tradingSystem: undefined,
|
||||
loadFromStrategyzer: loadFromStrategyzer,
|
||||
saveToStrategyzer: saveToStrategyzer,
|
||||
deploydTradingSystem: deploydTradingSystem,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
@@ -37,6 +39,182 @@ function newWorkspace () {
|
||||
|
||||
}
|
||||
|
||||
function saveToStrategyzer () {
|
||||
let graphQL_Mutation = ''
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + 'strategy: { '
|
||||
graphQL_Mutation = graphQL_Mutation + 'subStrategies: [ '
|
||||
|
||||
for (m = 0; m < thisObject.tradingSystem.protocolData.strategies.length; m++) {
|
||||
let strategy = thisObject.tradingSystem.protocolData.strategies[m]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'active: true '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + strategy.name + '" '
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + 'entryPoint: { '
|
||||
graphQL_Mutation = graphQL_Mutation + 'situations: [ '
|
||||
|
||||
for (let k = 0; k < strategy.entryPoint.situations.length; k++) {
|
||||
let situation = strategy.entryPoint.situations[k]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + situation.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'conditions: [ '
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + condition.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'code: "' + condition.code + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + 'exitPoint: { '
|
||||
graphQL_Mutation = graphQL_Mutation + 'situations: [ '
|
||||
|
||||
for (let k = 0; k < strategy.exitPoint.situations.length; k++) {
|
||||
let situation = strategy.exitPoint.situations[k]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + situation.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'conditions: [ '
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + condition.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'code: "' + condition.code + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + 'sellPoint: { '
|
||||
graphQL_Mutation = graphQL_Mutation + 'situations: [ '
|
||||
|
||||
for (let k = 0; k < strategy.sellPoint.situations.length; k++) {
|
||||
let situation = strategy.sellPoint.situations[k]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + situation.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'conditions: [ '
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + condition.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'code: "' + condition.code + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + 'stopLoss: { '
|
||||
graphQL_Mutation = graphQL_Mutation + 'phases: [ '
|
||||
|
||||
for (let p = 0; p < strategy.stopLoss.phases.length; p++) {
|
||||
let phase = strategy.stopLoss.phases[p]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + phase.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'code: "' + phase.code + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'situations: [ '
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + situation.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'conditions: [ '
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + condition.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'code: "' + condition.code + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + 'buyOrder: { '
|
||||
graphQL_Mutation = graphQL_Mutation + 'phases: [ '
|
||||
|
||||
for (let p = 0; p < strategy.buyOrder.phases.length; p++) {
|
||||
let phase = strategy.buyOrder.phases[p]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + phase.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'code: "' + phase.code + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'situations: [ '
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + situation.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'conditions: [ '
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '{ '
|
||||
graphQL_Mutation = graphQL_Mutation + 'name: "' + condition.name + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + 'code: "' + condition.code + '" '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
}
|
||||
|
||||
graphQL_Mutation = graphQL_Mutation + '] '
|
||||
graphQL_Mutation = graphQL_Mutation + '} '
|
||||
|
||||
console.log(graphQL_Mutation)
|
||||
}
|
||||
|
||||
async function loadFromStrategyzer () {
|
||||
try {
|
||||
const accessToken = window.localStorage.getItem('xaccess_token')
|
||||
|
||||
Reference in new issue
Block a user