Investment Plan added
This commit is contained in:
1 parent
c9ed3cb78e
commit
6eb8e0a8b7
6 files changed
+125
-117
No files matched your search
@@ -68,15 +68,15 @@ function newStrategyPart () {
|
||||
|
||||
let menuItemsInitialValues = []
|
||||
switch (thisObject.payload.node.type) {
|
||||
case 'Strategy': {
|
||||
imagePath = 'Images/icons/style-01/quality.png'
|
||||
case 'Investment Plan': {
|
||||
imagePath = 'Images/icons/style-01/analysis.png'
|
||||
menuItemsInitialValues = [
|
||||
{
|
||||
action: 'Reload Strategy',
|
||||
action: 'Reload Investment Plan',
|
||||
actionFunction: thisObject.payload.onMenuItemClick,
|
||||
label: 'Reload Last Saved',
|
||||
label: 'Reload',
|
||||
visible: false,
|
||||
imagePathOn: 'Images/icons/style-01/pixel.png',
|
||||
imagePathOn: 'Images/icons/style-01/vector.png',
|
||||
imagePathOff: 'Images/icons/style-01/target.png',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
@@ -84,7 +84,7 @@ function newStrategyPart () {
|
||||
angle: -60
|
||||
},
|
||||
{
|
||||
action: 'Save Strategy',
|
||||
action: 'Save Investment Plan',
|
||||
actionFunction: thisObject.payload.onMenuItemClick,
|
||||
label: 'Save Changes',
|
||||
visible: false,
|
||||
@@ -96,11 +96,11 @@ function newStrategyPart () {
|
||||
angle: -20
|
||||
},
|
||||
{
|
||||
action: 'Delete Strategy',
|
||||
action: 'New Strategy',
|
||||
actionFunction: thisObject.payload.onMenuItemClick,
|
||||
label: 'Delete This Strategy',
|
||||
label: 'New Strategy',
|
||||
visible: false,
|
||||
imagePathOn: 'Images/icons/style-01/trash.png',
|
||||
imagePathOn: 'Images/icons/style-01/quality.png',
|
||||
imagePathOff: 'Images/icons/style-01/target.png',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
@@ -121,6 +121,35 @@ function newStrategyPart () {
|
||||
}]
|
||||
break
|
||||
}
|
||||
case 'Strategy': {
|
||||
imagePath = 'Images/icons/style-01/quality.png'
|
||||
menuItemsInitialValues = [
|
||||
{
|
||||
action: 'Delete Strategy',
|
||||
actionFunction: thisObject.payload.onMenuItemClick,
|
||||
label: 'Delete This Strategy',
|
||||
visible: false,
|
||||
imagePathOn: 'Images/icons/style-01/trash.png',
|
||||
imagePathOff: 'Images/icons/style-01/target.png',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -20
|
||||
},
|
||||
{
|
||||
action: 'Open Settings',
|
||||
actionFunction: thisObject.payload.onMenuItemClick,
|
||||
label: 'Settings',
|
||||
visible: false,
|
||||
imagePathOn: 'Images/icons/style-01/tools.png',
|
||||
imagePathOff: 'Images/icons/style-01/target.png',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 20
|
||||
}]
|
||||
break
|
||||
}
|
||||
case 'Strategy Entry Event': {
|
||||
imagePath = 'Images/icons/style-01/startup.png'
|
||||
menuItemsInitialValues = [
|
||||
@@ -601,4 +630,3 @@ function newStrategyPart () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ function newStrategyPartConstructor () {
|
||||
const FRICTION = 0.97
|
||||
|
||||
switch (payload.node.type) {
|
||||
case 'Investment Plan': {
|
||||
level_1()
|
||||
break
|
||||
}
|
||||
case 'Strategy': {
|
||||
level_1()
|
||||
break
|
||||
|
||||
@@ -44,39 +44,6 @@ function newStrategyPartTitle () {
|
||||
function initialize (payload) {
|
||||
thisObject.payload = payload
|
||||
|
||||
switch (payload.node.type) {
|
||||
case 'Strategy': {
|
||||
break
|
||||
}
|
||||
case 'Strategy Entry Event': {
|
||||
break
|
||||
}
|
||||
case 'Strategy Exit Event': {
|
||||
break
|
||||
}
|
||||
case 'Trade Entry Event': {
|
||||
break
|
||||
}
|
||||
case 'Stop': {
|
||||
break
|
||||
}
|
||||
case 'Take Profit': {
|
||||
break
|
||||
}
|
||||
case 'Phase': {
|
||||
break
|
||||
}
|
||||
case 'Situation': {
|
||||
break
|
||||
}
|
||||
case 'Condition': {
|
||||
break
|
||||
}
|
||||
default: {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Part Type not Recognized -> type = ' + payload.node.type) }
|
||||
}
|
||||
}
|
||||
|
||||
selfFocusEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onFocus', onFocus)
|
||||
selfNotFocuskEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onNotFocus', onNotFocus)
|
||||
selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
function newStrategy () {
|
||||
const MODULE_NAME = 'Strategy'
|
||||
function newInvestmentPlan () {
|
||||
const MODULE_NAME = 'Investment Plan'
|
||||
|
||||
let thisObject = {
|
||||
strategySource: undefined,
|
||||
investmentPlan: undefined,
|
||||
container: undefined,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
@@ -28,8 +28,10 @@ function newStrategy () {
|
||||
destroyStrategyParts()
|
||||
}
|
||||
|
||||
function initialize (pStrategySource) {
|
||||
thisObject.strategySource = pStrategySource
|
||||
function initialize (strategies) {
|
||||
thisObject.investmentPlan = {
|
||||
strategies: strategies
|
||||
}
|
||||
generateStrategyParts()
|
||||
}
|
||||
|
||||
@@ -78,92 +80,98 @@ function newStrategy () {
|
||||
|
||||
function generateStrategyParts () {
|
||||
let lastPhase
|
||||
let strategy = thisObject.strategySource
|
||||
createPart('Strategy', strategy.name, strategy, undefined, undefined)
|
||||
let investmentPlan = thisObject.investmentPlan
|
||||
|
||||
createPart('Strategy Entry Event', '', strategy.entryPoint, strategy, strategy)
|
||||
for (let k = 0; k < strategy.entryPoint.situations.length; k++) {
|
||||
let situation = strategy.entryPoint.situations[k]
|
||||
createPart('Situation', situation.name, situation, strategy.entryPoint, strategy.entryPoint, 'Strategy Entry' + ' ' + 'Situation')
|
||||
createPart('Investment Plan', '', investmentPlan, undefined, undefined)
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
for (m = 0; m < investmentPlan.strategies.length; m++) {
|
||||
let strategy = investmentPlan.strategies[m]
|
||||
createPart('Strategy', strategy.name, strategy, investmentPlan, investmentPlan)
|
||||
|
||||
createPart('Strategy Exit Event', '', strategy.exitPoint, strategy, strategy)
|
||||
for (let k = 0; k < strategy.exitPoint.situations.length; k++) {
|
||||
let situation = strategy.exitPoint.situations[k]
|
||||
createPart('Situation', situation.name, situation, strategy.exitPoint, strategy.exitPoint, 'Strategy Exit' + ' ' + 'Situation')
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Trade Entry Event', '', strategy.sellPoint, strategy, strategy)
|
||||
for (let k = 0; k < strategy.sellPoint.situations.length; k++) {
|
||||
let situation = strategy.sellPoint.situations[k]
|
||||
createPart('Situation', situation.name, situation, strategy.sellPoint, strategy.sellPoint, 'Trade Entry' + ' ' + 'Situation')
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Stop', '', strategy.stopLoss, strategy, strategy)
|
||||
for (let p = 0; p < strategy.stopLoss.phases.length; p++) {
|
||||
let phase = strategy.stopLoss.phases[p]
|
||||
|
||||
let chainParent
|
||||
if (p === 0) {
|
||||
chainParent = strategy.stopLoss
|
||||
} else {
|
||||
chainParent = lastPhase
|
||||
}
|
||||
lastPhase = phase
|
||||
createPart('Phase', phase.name, phase, strategy.stopLoss, chainParent, 'Stop Phase')
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
createPart('Situation', situation.name, situation, phase, phase, 'Situation')
|
||||
createPart('Strategy Entry Event', '', strategy.entryPoint, strategy, strategy)
|
||||
for (let k = 0; k < strategy.entryPoint.situations.length; k++) {
|
||||
let situation = strategy.entryPoint.situations[k]
|
||||
createPart('Situation', situation.name, situation, strategy.entryPoint, strategy.entryPoint, 'Strategy Entry' + ' ' + 'Situation')
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Take Profit', '', strategy.buyOrder, strategy, strategy)
|
||||
for (let p = 0; p < strategy.buyOrder.phases.length; p++) {
|
||||
let phase = strategy.buyOrder.phases[p]
|
||||
let chainParent
|
||||
if (p === 0) {
|
||||
chainParent = strategy.buyOrder
|
||||
} else {
|
||||
chainParent = lastPhase
|
||||
}
|
||||
lastPhase = phase
|
||||
createPart('Phase', phase.name, phase, strategy.buyOrder, chainParent, 'Take Profit Phase')
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
createPart('Situation', situation.name, situation, phase, phase, 'Situation')
|
||||
createPart('Strategy Exit Event', '', strategy.exitPoint, strategy, strategy)
|
||||
for (let k = 0; k < strategy.exitPoint.situations.length; k++) {
|
||||
let situation = strategy.exitPoint.situations[k]
|
||||
createPart('Situation', situation.name, situation, strategy.exitPoint, strategy.exitPoint, 'Strategy Exit' + ' ' + 'Situation')
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Trade Entry Event', '', strategy.sellPoint, strategy, strategy)
|
||||
for (let k = 0; k < strategy.sellPoint.situations.length; k++) {
|
||||
let situation = strategy.sellPoint.situations[k]
|
||||
createPart('Situation', situation.name, situation, strategy.sellPoint, strategy.sellPoint, 'Trade Entry' + ' ' + 'Situation')
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Stop', '', strategy.stopLoss, strategy, strategy)
|
||||
for (let p = 0; p < strategy.stopLoss.phases.length; p++) {
|
||||
let phase = strategy.stopLoss.phases[p]
|
||||
|
||||
let chainParent
|
||||
if (p === 0) {
|
||||
chainParent = strategy.stopLoss
|
||||
} else {
|
||||
chainParent = lastPhase
|
||||
}
|
||||
lastPhase = phase
|
||||
createPart('Phase', phase.name, phase, strategy.stopLoss, chainParent, 'Stop Phase')
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
createPart('Situation', situation.name, situation, phase, phase, 'Situation')
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createPart('Take Profit', '', strategy.buyOrder, strategy, strategy)
|
||||
for (let p = 0; p < strategy.buyOrder.phases.length; p++) {
|
||||
let phase = strategy.buyOrder.phases[p]
|
||||
let chainParent
|
||||
if (p === 0) {
|
||||
chainParent = strategy.buyOrder
|
||||
} else {
|
||||
chainParent = lastPhase
|
||||
}
|
||||
lastPhase = phase
|
||||
createPart('Phase', phase.name, phase, strategy.buyOrder, chainParent, 'Take Profit Phase')
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
let situation = phase.situations[k]
|
||||
createPart('Situation', situation.name, situation, phase, phase, 'Situation')
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
let condition = situation.conditions[m]
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function destroyStrategyParts () {
|
||||
let strategy = thisObject.strategySource
|
||||
let strategy = thisObject.investmentPlan
|
||||
destroyPart(strategy)
|
||||
|
||||
destroyPart(strategy.entryPoint)
|
||||
@@ -129,7 +129,7 @@ function newStrategyCollection () {
|
||||
let collectionItem = newStrategyCollectionItem()
|
||||
|
||||
collectionItem.container.connectToParent(thisObject.container, false, false)
|
||||
collectionItem.initialize(strategy)
|
||||
collectionItem.initialize(thisObject.strategies)
|
||||
collectionItem.container.frame.position.y = i * ITEMS_SEPARATION + TOP_MARGIN
|
||||
|
||||
colletionItems.push(collectionItem)
|
||||
|
||||
@@ -44,7 +44,7 @@ function newStrategyCollectionItem () {
|
||||
function onMouseClick (event) {
|
||||
if (status === 'off') {
|
||||
canvas.floatingSpace.makeVisible()
|
||||
thisObject.strategy = newStrategy()
|
||||
thisObject.strategy = newInvestmentPlan()
|
||||
thisObject.strategy.initialize(thisObject.strategySource)
|
||||
status = 'on'
|
||||
} else {
|
||||
@@ -90,7 +90,7 @@ function newStrategyCollectionItem () {
|
||||
labelpoint = thisObject.container.frame.frameThisPoint(labelpoint)
|
||||
|
||||
let labelToPrint = strategy.name
|
||||
labelToPrint = labelToPrint.toUpperCase()
|
||||
labelToPrint = ''
|
||||
labelToPrint = labelToPrint.substring(0, 30)
|
||||
let opacity = 1
|
||||
let fontSize = 15
|
||||
@@ -175,3 +175,4 @@ function newStrategyCollectionItem () {
|
||||
browserCanvasContext.drawImage(thisObject.icon, point1.x - IMAGE_SIZE / 2, point1.y - IMAGE_SIZE / 2, IMAGE_SIZE, IMAGE_SIZE)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user