4 files changed
+67
-35
No files matched your search
@@ -30,6 +30,8 @@ function newRestartSimulation () {
|
||||
let counterTillNextState = 0
|
||||
|
||||
let productCardsToTurnOn = []
|
||||
|
||||
let executionFocusExists = false
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
@@ -53,7 +55,7 @@ function newRestartSimulation () {
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
if (thisObject.visible !== true || thisObject.status !== 'Ready') { return }
|
||||
if (thisObject.visible !== true || thisObject.status !== 'Ready' || executionFocusExists === false) { return }
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
@@ -165,11 +167,21 @@ function newRestartSimulation () {
|
||||
break
|
||||
case 'Calculating':
|
||||
thisObject.status = 'Refreshing'
|
||||
turnOffProductCards()
|
||||
counterTillNextState = 10
|
||||
counterTillNextState = 15
|
||||
break
|
||||
case 'Refreshing':
|
||||
thisObject.status = 'Reviewing'
|
||||
turnOffProductCards()
|
||||
turnOnProductCards()
|
||||
counterTillNextState = 150
|
||||
break
|
||||
case 'Reviewing':
|
||||
thisObject.status = '2nd Refresh'
|
||||
counterTillNextState = 25
|
||||
break
|
||||
case '2nd Refresh':
|
||||
thisObject.status = 'Ready'
|
||||
turnOffProductCards()
|
||||
turnOnProductCards()
|
||||
break
|
||||
case 'Error':
|
||||
@@ -180,6 +192,15 @@ function newRestartSimulation () {
|
||||
}
|
||||
|
||||
positionPhysics()
|
||||
executionFocusPhysics()
|
||||
}
|
||||
|
||||
function executionFocusPhysics () {
|
||||
if (canvas.strategySpace.workspace.tradingSystem !== undefined) {
|
||||
executionFocusExists = true
|
||||
} else {
|
||||
executionFocusExists = false
|
||||
}
|
||||
}
|
||||
|
||||
function positionPhysics () {
|
||||
@@ -188,7 +209,7 @@ function newRestartSimulation () {
|
||||
}
|
||||
|
||||
function draw () {
|
||||
if (thisObject.visible !== true) { return }
|
||||
if (thisObject.visible !== true || executionFocusExists === false) { return }
|
||||
drawBackground()
|
||||
drawText()
|
||||
}
|
||||
@@ -213,7 +234,7 @@ function newRestartSimulation () {
|
||||
break
|
||||
}
|
||||
case 'Saving':
|
||||
params.backgroundColor = UI_COLOR.MANGANESE_PURPLE
|
||||
params.backgroundColor = UI_COLOR.GREY
|
||||
break
|
||||
case 'Restarting':
|
||||
params.backgroundColor = UI_COLOR.GREY
|
||||
@@ -224,6 +245,12 @@ function newRestartSimulation () {
|
||||
case 'Calculating':
|
||||
params.backgroundColor = UI_COLOR.TITANIUM_YELLOW
|
||||
break
|
||||
case 'Reviewing':
|
||||
params.backgroundColor = UI_COLOR.GREY
|
||||
break
|
||||
case '2nd Refresh':
|
||||
params.backgroundColor = UI_COLOR.GOLDEN_ORANGE
|
||||
break
|
||||
case 'Error':
|
||||
params.backgroundColor = UI_COLOR.RUSTED_RED
|
||||
break
|
||||
@@ -248,7 +275,7 @@ function newRestartSimulation () {
|
||||
|
||||
switch (thisObject.status) {
|
||||
case 'Ready':
|
||||
label = 'RE-CALCULATE'
|
||||
label = 'RUN SIMULATION'
|
||||
break
|
||||
case 'Saving':
|
||||
label = 'SAVING STRATEGIES CHANGES...'
|
||||
@@ -262,6 +289,12 @@ function newRestartSimulation () {
|
||||
case 'Calculating':
|
||||
label = 'CALCULATING...'
|
||||
break
|
||||
case 'Reviewing':
|
||||
label = 'WAITING TO UPDATE...'
|
||||
break
|
||||
case '2nd Refresh':
|
||||
label = 'UPDATING...'
|
||||
break
|
||||
case 'Error':
|
||||
label = 'ERROR, RETRY LATER'
|
||||
break
|
||||
@@ -277,4 +310,3 @@ function newRestartSimulation () {
|
||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,8 +631,8 @@ function newFloatingLayer () {
|
||||
|
||||
maxTargetRepulsionForce = maxTargetRepulsionForce + pDelta / 1000
|
||||
|
||||
if (maxTargetRepulsionForce < 0.0001) {
|
||||
maxTargetRepulsionForce = 0.0001
|
||||
if (maxTargetRepulsionForce < 0.0000000001) {
|
||||
maxTargetRepulsionForce = 0.0000000001
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] changeTargetRepulsion -> err= ' + err.stack) }
|
||||
|
||||
@@ -197,83 +197,83 @@ function newStrategyPart () {
|
||||
let compatibleSubType
|
||||
switch (thisObject.payload.node.type) {
|
||||
case 'Parameters':
|
||||
compatibleType = 'Trading System'
|
||||
compatibleType = '->' + 'Trading System'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Base Asset':
|
||||
compatibleType = 'Parameters'
|
||||
compatibleType = '->' + 'Parameters'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Strategy':
|
||||
compatibleType = 'Trading System'
|
||||
compatibleType = '->' + 'Trading System'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Trigger Stage':
|
||||
compatibleType = 'Strategy'
|
||||
compatibleType = '->' + 'Strategy'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Open Stage':
|
||||
compatibleType = 'Strategy'
|
||||
compatibleType = '->' + 'Strategy'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Manage Stage':
|
||||
compatibleType = 'Strategy'
|
||||
compatibleType = '->' + 'Strategy'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Close Stage':
|
||||
compatibleType = 'Strategy'
|
||||
compatibleType = '->' + 'Strategy'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Position Size':
|
||||
compatibleType = 'Trigger Stage'
|
||||
compatibleType = '->' + 'Trigger Stage'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Take Position Event':
|
||||
compatibleType = 'Trigger Stage'
|
||||
compatibleType = '->' + 'Trigger Stage'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Trigger Off Event':
|
||||
compatibleType = 'Trigger Stage'
|
||||
compatibleType = '->' + 'Trigger Stage'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Trigger On Event':
|
||||
compatibleType = 'Trigger Stage'
|
||||
compatibleType = '->' + 'Trigger Stage'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Initial Definition':
|
||||
compatibleType = 'Open Stage'
|
||||
compatibleType = '->' + 'Open Stage'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Stop':
|
||||
compatibleType = 'Manage Stage' + '.' + 'Initial Definition'
|
||||
compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Take Profit':
|
||||
compatibleType = 'Manage Stage' + '.' + 'Initial Definition'
|
||||
compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Phase':
|
||||
compatibleType = 'Stop' + '.' + 'Take Profit' + '.' + 'Phase'
|
||||
compatibleType = '->' + 'Stop' + '->' + 'Take Profit' + '->' + 'Phase'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Formula':
|
||||
compatibleType = 'Base Asset' + '.' + 'Position Size' + '.' + 'Phase'
|
||||
compatibleType = '->' + 'Base Asset' + '->' + 'Position Size' + '->' + 'Phase'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Next Phase Event':
|
||||
compatibleType = 'Phase'
|
||||
compatibleType = '->' + 'Phase'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Situation':
|
||||
compatibleType = 'Take Position Event' + '.' + 'Trigger On Event' + '.' + 'Trigger Off Event' + '.' + 'Next Phase Event'
|
||||
compatibleType = '->' + 'Take Position Event' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Next Phase Event'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Condition':
|
||||
compatibleType = 'Situation'
|
||||
compatibleType = '->' + 'Situation'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
case 'Code':
|
||||
compatibleType = 'Condition'
|
||||
compatibleType = '->' + 'Condition'
|
||||
compatibleSubType = undefined
|
||||
break
|
||||
default:
|
||||
@@ -288,7 +288,7 @@ function newStrategyPart () {
|
||||
let distance = nearby[0]
|
||||
let floatingObject = nearby[1]
|
||||
let nearbyNode = floatingObject.payload.node
|
||||
if (compatibleType.indexOf(nearbyNode.type) >= 0) {
|
||||
if (compatibleType.indexOf('->' + nearbyNode.type) >= 0) {
|
||||
/* Discard objects with busy coonection ports */
|
||||
if (thisObject.payload.node.type === 'Parameters' && nearbyNode.parameters !== undefined) { continue }
|
||||
if (thisObject.payload.node.type === 'Base Asset' && nearbyNode.baseAsset !== undefined) { continue }
|
||||
|
||||
@@ -2070,7 +2070,7 @@ function newStrategyPartConstructor () {
|
||||
floatingObject.targetFriction = 0.93
|
||||
floatingObject.friction = INITIAL_FRICTION
|
||||
|
||||
floatingObject.initializeMass(1000)
|
||||
floatingObject.initializeMass(500)
|
||||
floatingObject.initializeRadius(45)
|
||||
floatingObject.initializeImageSize(80)
|
||||
floatingObject.initializeFontSize(10)
|
||||
@@ -2082,7 +2082,7 @@ function newStrategyPartConstructor () {
|
||||
floatingObject.targetFriction = 0.94
|
||||
floatingObject.friction = INITIAL_FRICTION
|
||||
|
||||
floatingObject.initializeMass(750)
|
||||
floatingObject.initializeMass(600)
|
||||
floatingObject.initializeRadius(45)
|
||||
floatingObject.initializeImageSize(80)
|
||||
floatingObject.initializeFontSize(10)
|
||||
@@ -2098,7 +2098,7 @@ function newStrategyPartConstructor () {
|
||||
floatingObject.targetFriction = FRICTION
|
||||
floatingObject.friction = INITIAL_FRICTION
|
||||
|
||||
floatingObject.initializeMass(500)
|
||||
floatingObject.initializeMass(300)
|
||||
floatingObject.initializeRadius(40)
|
||||
floatingObject.initializeImageSize(70)
|
||||
floatingObject.initializeFontSize(10)
|
||||
@@ -2114,7 +2114,7 @@ function newStrategyPartConstructor () {
|
||||
floatingObject.targetFriction = FRICTION
|
||||
floatingObject.friction = INITIAL_FRICTION
|
||||
|
||||
floatingObject.initializeMass(250)
|
||||
floatingObject.initializeMass(150)
|
||||
floatingObject.initializeRadius(35)
|
||||
floatingObject.initializeImageSize(60)
|
||||
floatingObject.initializeFontSize(10)
|
||||
@@ -2130,7 +2130,7 @@ function newStrategyPartConstructor () {
|
||||
floatingObject.targetFriction = FRICTION
|
||||
floatingObject.friction = INITIAL_FRICTION
|
||||
|
||||
floatingObject.initializeMass(100)
|
||||
floatingObject.initializeMass(75)
|
||||
floatingObject.initializeRadius(30)
|
||||
floatingObject.initializeImageSize(50)
|
||||
floatingObject.initializeFontSize(10)
|
||||
|
||||
Reference in new issue
Block a user