Adding the possibility of any Trading System to RUN
This commit is contained in:
1 parent
1b2dbd313b
commit
40095a0fe3
2 files changed
+55
-6
No files matched your search
@@ -17,6 +17,8 @@ function newStrategyPart () {
|
||||
codeEditor: undefined,
|
||||
partTitle: undefined,
|
||||
isExecuting: undefined,
|
||||
isRunning: undefined,
|
||||
run: run,
|
||||
getReadyToAttach: getReadyToAttach,
|
||||
showAvailabilityToAttach: showAvailabilityToAttach,
|
||||
highlight: highlight,
|
||||
@@ -50,6 +52,7 @@ function newStrategyPart () {
|
||||
|
||||
let isHighlighted
|
||||
let highlightCounter = 0
|
||||
let runningCounter = 0
|
||||
|
||||
let previousDistance
|
||||
|
||||
@@ -160,6 +163,7 @@ function newStrategyPart () {
|
||||
}
|
||||
|
||||
iconPhysics()
|
||||
runningPhisycs()
|
||||
highlightPhisycs()
|
||||
detachingPhysics()
|
||||
attachingPhysics()
|
||||
@@ -292,6 +296,25 @@ function newStrategyPart () {
|
||||
// highlightCounter = 0
|
||||
}
|
||||
|
||||
function runningPhisycs () {
|
||||
if (canvas.strategySpace.workspace.tradingSystem !== undefined) {
|
||||
if (canvas.strategySpace.workspace.tradingSystem.id !== thisObject.payload.node.id) {
|
||||
runningCounter--
|
||||
}
|
||||
}
|
||||
|
||||
if (runningCounter < 0) {
|
||||
runningCounter = 0
|
||||
thisObject.isRunning = false
|
||||
}
|
||||
}
|
||||
|
||||
function run () {
|
||||
canvas.strategySpace.workspace.tradingSystem = thisObject.payload.node
|
||||
isRunning = true
|
||||
runningCounter = 30
|
||||
}
|
||||
|
||||
function iconPhysics () {
|
||||
icon = canvas.strategySpace.iconByPartType.get(thisObject.payload.node.type)
|
||||
executingIcon = canvas.strategySpace.iconCollection.get('attractive')
|
||||
@@ -556,6 +579,21 @@ function newStrategyPart () {
|
||||
|
||||
browserCanvasContext.fill()
|
||||
|
||||
if (thisObject.isRunning === true) {
|
||||
VISIBLE_RADIUS = thisObject.container.frame.radius * 2
|
||||
let OPACITY = runningCounter / 30
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, VISIBLE_RADIUS, 0, Math.PI * 2, true)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + OPACITY + ')'
|
||||
|
||||
browserCanvasContext.lineWidth = 10
|
||||
browserCanvasContext.setLineDash([4, 20])
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
|
||||
if (isHighlighted === true) {
|
||||
VISIBLE_RADIUS = thisObject.container.frame.radius
|
||||
let OPACITY = highlightCounter / 30
|
||||
@@ -630,3 +668,4 @@ function newStrategyPart () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@ function newStrategyPartConstructor () {
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
|
||||
createStrategyPart: createStrategyPart,
|
||||
destroyStrategyPart: destroyStrategyPart,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
|
||||
}
|
||||
|
||||
let floatingLayer
|
||||
@@ -50,12 +48,12 @@ function newStrategyPartConstructor () {
|
||||
}
|
||||
|
||||
let strategyPart = newStrategyPart()
|
||||
payload.uiObject = strategyPart
|
||||
strategyPart.fitFunction = canvas.floatingSpace.fitIntoVisibleArea
|
||||
strategyPart.isVisibleFunction = canvas.floatingSpace.isThisPointVisible
|
||||
let menuItemsInitialValues = getMenuItemsInitialValues(strategyPart, floatingObject, payload)
|
||||
strategyPart.initialize(payload, menuItemsInitialValues)
|
||||
strategyPart.container.connectToParent(floatingObject.container, false, false, true, true, false, false, true, true, true, true, true)
|
||||
payload.uiObject = strategyPart
|
||||
|
||||
setFloatingObjectBasicProperties(floatingObject, payload)
|
||||
|
||||
@@ -85,6 +83,18 @@ function newStrategyPartConstructor () {
|
||||
currentRadius: 0,
|
||||
angle: -135
|
||||
},
|
||||
{
|
||||
action: 'Run Trading System',
|
||||
actionFunction: payload.uiObject.run,
|
||||
label: 'Run',
|
||||
visible: false,
|
||||
iconPathOn: 'paper-plane',
|
||||
iconPathOff: 'upload',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -60
|
||||
},
|
||||
{
|
||||
action: 'Save Trading System',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
@@ -98,7 +108,7 @@ function newStrategyPartConstructor () {
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -40
|
||||
angle: -20
|
||||
},
|
||||
{
|
||||
action: 'New Strategy',
|
||||
@@ -111,7 +121,7 @@ function newStrategyPartConstructor () {
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 0
|
||||
angle: 20
|
||||
},
|
||||
{
|
||||
action: 'Download',
|
||||
@@ -123,7 +133,7 @@ function newStrategyPartConstructor () {
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 40
|
||||
angle: 60
|
||||
}]
|
||||
break
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user