Equilibrium reached
This commit is contained in:
1 parent
69cce193bb
commit
4e579df61e
7 files changed
+195
-41
No files matched your search
@@ -64,7 +64,7 @@ function newFloatingObject () {
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize (pType, callBackFunction) {
|
||||
function initialize (pType, floatingLayer, callBackFunction) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
@@ -92,7 +92,7 @@ function newFloatingObject () {
|
||||
|
||||
case 'Strategy Part': {
|
||||
underlayingObject = newStrategyPart()
|
||||
underlayingObject.initialize(onInitialized)
|
||||
underlayingObject.initialize(floatingLayer, onInitialized)
|
||||
|
||||
function onInitialized (err) {
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ function newNoteSets () {
|
||||
*/
|
||||
|
||||
let floatingObject = newFloatingObject()
|
||||
floatingObject.initialize('Note', onInitialized)
|
||||
floatingObject.initialize('Note', floatingLayer, onInitialized)
|
||||
|
||||
function onInitialized (err) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Entering function.') }
|
||||
|
||||
@@ -41,7 +41,7 @@ function newProfileBalls () {
|
||||
|
||||
function createNewProfileBall (pPayload, callBackFunction) {
|
||||
let floatingObject = newFloatingObject()
|
||||
floatingObject.initialize('Profile Ball', onInitialized)
|
||||
floatingObject.initialize('Profile Ball', floatingLayer, onInitialized)
|
||||
|
||||
function onInitialized (err) {
|
||||
floatingObject.payload = pPayload
|
||||
|
||||
@@ -51,9 +51,13 @@ function newStrategyPart () {
|
||||
}
|
||||
]
|
||||
|
||||
let floatingLayer
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize (callBackFunction) {
|
||||
function initialize (pFloatingLayer, callBackFunction) {
|
||||
floatingLayer = pFloatingLayer
|
||||
|
||||
for (let i = 0; i < ballStringMenu.length; i++) {
|
||||
let menuItem = ballStringMenu[i]
|
||||
|
||||
@@ -168,6 +172,17 @@ function newStrategyPart () {
|
||||
}
|
||||
|
||||
function drawBackground (pFloatingObject) {
|
||||
/* Here we do the trick of recalculation the position of the anchor by setting it to the position of its parent */
|
||||
|
||||
if (pFloatingObject.payload.parentNode !== undefined) {
|
||||
let parentFloatingObject = floatingLayer.getFloatingObject(pFloatingObject.payload.parentNode.handle)
|
||||
|
||||
pFloatingObject.payload.profile.position.x = parentFloatingObject.currentPosition.x
|
||||
pFloatingObject.payload.profile.position.y = parentFloatingObject.currentPosition.y
|
||||
}
|
||||
|
||||
/* Here I continue painting the background */
|
||||
|
||||
let point = {
|
||||
x: pFloatingObject.payload.profile.position.x,
|
||||
y: pFloatingObject.payload.profile.position.y
|
||||
|
||||
@@ -32,19 +32,73 @@ function newStrategyParts () {
|
||||
floatingLayer = pFloatingLayer
|
||||
}
|
||||
|
||||
function createNewStrategyPart (pPayload, callBackFunction) {
|
||||
function createNewStrategyPart (type, pPayload, callBackFunction) {
|
||||
let floatingObject = newFloatingObject()
|
||||
floatingObject.initialize('Strategy Part', onInitialized)
|
||||
floatingObject.initialize('Strategy Part', floatingLayer, onInitialized)
|
||||
|
||||
function onInitialized (err) {
|
||||
floatingObject.payload = pPayload
|
||||
|
||||
floatingObject.friction = 0.995
|
||||
switch (type) {
|
||||
case 'Strategy': {
|
||||
level_1()
|
||||
break
|
||||
}
|
||||
case 'Strategy Entry': {
|
||||
level_2()
|
||||
break
|
||||
}
|
||||
case 'Strategy Exit': {
|
||||
level_2()
|
||||
break
|
||||
}
|
||||
case 'Trade Entry': {
|
||||
level_2()
|
||||
break
|
||||
}
|
||||
case 'Trade Exit': {
|
||||
level_2()
|
||||
break
|
||||
}
|
||||
case 'Stop': {
|
||||
level_2()
|
||||
break
|
||||
}
|
||||
case 'Take Profit': {
|
||||
level_2()
|
||||
break
|
||||
}
|
||||
default: {
|
||||
level_3()
|
||||
}
|
||||
}
|
||||
|
||||
floatingObject.initializeMass(50)
|
||||
floatingObject.initializeRadius(15)
|
||||
floatingObject.initializeImageSize(25)
|
||||
floatingObject.initializeFontSize(10)
|
||||
function level_1 () {
|
||||
floatingObject.friction = 0.9
|
||||
|
||||
floatingObject.initializeMass(100)
|
||||
floatingObject.initializeRadius(50)
|
||||
floatingObject.initializeImageSize(60)
|
||||
floatingObject.initializeFontSize(10)
|
||||
}
|
||||
|
||||
function level_2 () {
|
||||
floatingObject.friction = 0.85
|
||||
|
||||
floatingObject.initializeMass(50)
|
||||
floatingObject.initializeRadius(30)
|
||||
floatingObject.initializeImageSize(50)
|
||||
floatingObject.initializeFontSize(10)
|
||||
}
|
||||
|
||||
function level_3 () {
|
||||
floatingObject.friction = 0.8
|
||||
|
||||
floatingObject.initializeMass(10)
|
||||
floatingObject.initializeRadius(10)
|
||||
floatingObject.initializeImageSize(50)
|
||||
floatingObject.initializeFontSize(10)
|
||||
}
|
||||
|
||||
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)'
|
||||
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)'
|
||||
@@ -59,4 +113,3 @@ function newStrategyParts () {
|
||||
floatingLayer.killFloatingObject(pFloatingObjectHandle)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ function newStrategyCollection () {
|
||||
})
|
||||
.then(response => {
|
||||
window.localStorage.setItem('userStrategies', JSON.stringify(response.data.strategizer_StrategyByFb.subStrategies))
|
||||
thisObject.strategies = response.data.strategizer_StrategyByFb.subStrategies
|
||||
thisObject.strategies = JSON.parse(JSON.stringify(response.data.strategizer_StrategyByFb.subStrategies))
|
||||
createCollectionItems()
|
||||
resolve({ strategies: response.data.strategizer_StrategyByFb.subStrategies})
|
||||
})
|
||||
|
||||
@@ -17,6 +17,8 @@ function newStrategyCollectionItem () {
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
|
||||
let visible = false
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
@@ -37,13 +39,20 @@ function newStrategyCollectionItem () {
|
||||
}
|
||||
|
||||
function onMouseClick (event) {
|
||||
canvas.chartSpace.visible = false
|
||||
canvas.panelsSpace.visible = false
|
||||
generateStrategyParts()
|
||||
if (visible === false) {
|
||||
canvas.chartSpace.visible = false
|
||||
canvas.panelsSpace.visible = false
|
||||
generateStrategyParts()
|
||||
visible = true
|
||||
} else {
|
||||
canvas.chartSpace.visible = true
|
||||
canvas.panelsSpace.visible = true
|
||||
destroyStrategyParts()
|
||||
visible = false
|
||||
}
|
||||
}
|
||||
|
||||
function createPart (upLabel, downLabel) {
|
||||
let handle
|
||||
function createPart (partType, name, node, parentNode) {
|
||||
let payload = {
|
||||
profile: {
|
||||
position: {
|
||||
@@ -57,83 +66,160 @@ function newStrategyCollectionItem () {
|
||||
|
||||
let imageId // 'My Image.png'
|
||||
|
||||
payload.profile.upLabel = upLabel
|
||||
payload.profile.downLabel = downLabel
|
||||
payload.profile.upLabel = partType
|
||||
payload.profile.downLabel = name
|
||||
payload.profile.imageId = imageId
|
||||
payload.profile.botAvatar = 'dont know what this is'
|
||||
payload.parentNode = parentNode
|
||||
|
||||
canvas.floatingSpace.strategyParts.createNewStrategyPart(payload, onStrategyPartCreated)
|
||||
node.payload = payload
|
||||
|
||||
canvas.floatingSpace.strategyParts.createNewStrategyPart(partType, payload, onStrategyPartCreated)
|
||||
|
||||
function onStrategyPartCreated (err, pPartHandle) {
|
||||
handle = pPartHandle
|
||||
node.handle = pPartHandle
|
||||
}
|
||||
}
|
||||
|
||||
function destroyPart (node) {
|
||||
canvas.floatingSpace.strategyParts.destroyStrategyPart(node.handle)
|
||||
}
|
||||
|
||||
function generateStrategyParts () {
|
||||
let strategy = thisObject.strategy
|
||||
createPart('Strategy', strategy.name)
|
||||
createPart('Strategy', strategy.name, strategy, undefined)
|
||||
|
||||
createPart('Strategy Entry', '')
|
||||
createPart('Strategy Entry', '', strategy.entryPoint, strategy)
|
||||
for (let k = 0; k < strategy.entryPoint.situations.length; k++) {
|
||||
let situation = strategy.entryPoint.situations[k]
|
||||
createPart('Situation', situation.name)
|
||||
createPart('Situation', situation.name, situation, strategy.entryPoint)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name)
|
||||
createPart('Condition', condition.name, condition, situation)
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Strategy Exit', '')
|
||||
createPart('Strategy Exit', '', strategy.exitPoint, strategy)
|
||||
for (let k = 0; k < strategy.exitPoint.situations.length; k++) {
|
||||
let situation = strategy.exitPoint.situations[k]
|
||||
createPart('Situation', situation.name)
|
||||
createPart('Situation', situation.name, situation, strategy.exitPoint)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name)
|
||||
createPart('Condition', condition.name, condition, situation)
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Trade Entry', '')
|
||||
createPart('Trade Entry', '', strategy.sellPoint, strategy)
|
||||
for (let k = 0; k < strategy.sellPoint.situations.length; k++) {
|
||||
let situation = strategy.sellPoint.situations[k]
|
||||
createPart('Situation', situation.name)
|
||||
createPart('Situation', situation.name, situation, strategy.sellPoint)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name)
|
||||
createPart('Condition', condition.name, condition, situation)
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Stop', '')
|
||||
createPart('Stop', '', strategy.stopLoss, strategy)
|
||||
for (let p = 0; p < strategy.stopLoss.phases.length; p++) {
|
||||
let phase = strategy.stopLoss.phases[p]
|
||||
createPart('Phase', phase.name)
|
||||
createPart('Phase', phase.name, phase, strategy.stopLoss)
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
createPart('Situation', situation.name)
|
||||
createPart('Situation', situation.name, situation, phase)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name)
|
||||
createPart('Condition', condition.name, condition, situation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Take Profit', '')
|
||||
createPart('Take Profit', '', strategy.buyOrder, strategy)
|
||||
for (let p = 0; p < strategy.buyOrder.phases.length; p++) {
|
||||
let phase = strategy.buyOrder.phases[p]
|
||||
createPart('Phase', phase.name)
|
||||
createPart('Phase', phase.name, phase, strategy.buyOrder)
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
createPart('Situation', situation.name)
|
||||
createPart('Situation', situation.name, situation, phase)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name)
|
||||
createPart('Condition', condition.name, condition, situation)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function destroyStrategyParts () {
|
||||
let strategy = thisObject.strategy
|
||||
destroyPart(strategy)
|
||||
|
||||
destroyPart(strategy.entryPoint)
|
||||
for (let k = 0; k < strategy.entryPoint.situations.length; k++) {
|
||||
let situation = strategy.entryPoint.situations[k]
|
||||
destroyPart(situation)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
destroyPart(condition)
|
||||
}
|
||||
}
|
||||
|
||||
destroyPart(strategy.exitPoint)
|
||||
for (let k = 0; k < strategy.exitPoint.situations.length; k++) {
|
||||
let situation = strategy.exitPoint.situations[k]
|
||||
destroyPart(situation)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
destroyPart(condition)
|
||||
}
|
||||
}
|
||||
|
||||
destroyPart(strategy.sellPoint)
|
||||
for (let k = 0; k < strategy.sellPoint.situations.length; k++) {
|
||||
let situation = strategy.sellPoint.situations[k]
|
||||
destroyPart(situation)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
destroyPart(condition)
|
||||
}
|
||||
}
|
||||
|
||||
destroyPart(strategy.stopLoss)
|
||||
for (let p = 0; p < strategy.stopLoss.phases.length; p++) {
|
||||
let phase = strategy.stopLoss.phases[p]
|
||||
destroyPart(strategy.stopLoss)
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
destroyPart(situation)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
destroyPart(condition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
destroyPart(strategy.buyOrder)
|
||||
for (let p = 0; p < strategy.buyOrder.phases.length; p++) {
|
||||
let phase = strategy.buyOrder.phases[p]
|
||||
destroyPart(strategy.buyOrder)
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
destroyPart(situation)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
destroyPart(condition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user