Refactoring to Trading System

This commit is contained in:
Luis Fernando Molina committed 2019-05-12 14:07:41 +02:00
1 parent a4f199f792
commit 2fcd49ff13
8 files changed
+31 -32

No files matched your search

+3 -3
View File
@@ -72,11 +72,11 @@ function newStrategyPart () {
let menuItemsInitialValues = []
switch (thisObject.payload.node.type) {
case 'Investment Plan': {
case 'Trading System': {
imagePath = 'Images/icons/style-01/analysis.png'
menuItemsInitialValues = [
{
action: 'Reload Investment Plan',
action: 'Reload Trading System',
actionFunction: thisObject.payload.onMenuItemClick,
label: 'Reload',
visible: false,
@@ -88,7 +88,7 @@ function newStrategyPart () {
angle: -60
},
{
action: 'Save Investment Plan',
action: 'Save Trading System',
actionFunction: thisObject.payload.onMenuItemClick,
label: 'Save Changes',
visible: false,
+1 -1
View File
@@ -46,7 +46,7 @@ function newStrategyPartConstructor () {
const FRICTION = 0.97
switch (payload.node.type) {
case 'Investment Plan': {
case 'Trading System': {
level_0()
break
}
+1 -1
View File
@@ -48,7 +48,7 @@ function newStrategyPartTitle () {
thisObject.payload = payload
switch (payload.node.type) {
case 'Investment Plan': {
case 'Trading System': {
break
}
case 'Strategy': {
+1 -1
View File
@@ -44,7 +44,7 @@
}
function onMouseClick (event) {
// canvas.strategySpace.investmentPlanWorkspace.showUp()
// canvas.strategySpace.tradingSystemWorkspace.showUp()
}
function resize () {
+9 -9
View File
@@ -3,7 +3,7 @@ function newStrategySpace () {
const MODULE_NAME = 'Strategy Space'
let thisObject = {
sidePanel: undefined,
investmentPlanWorkspace: undefined,
tradingSystemWorkspace: undefined,
container: undefined,
draw: draw,
getContainer: getContainer,
@@ -24,16 +24,16 @@ function newStrategySpace () {
// thisObject.sidePanel = newSidePanel()
// thisObject.sidePanel.initialize()
thisObject.investmentPlanWorkspace = newInvestmentPlanWorkspace()
// thisObject.investmentPlanWorkspace.container.connectToParent(thisObject.sidePanel.container, true, true)
await thisObject.investmentPlanWorkspace.initialize()
thisObject.tradingSystemWorkspace = newTradingSystemWorkspace()
// thisObject.tradingSystemWorkspace.container.connectToParent(thisObject.sidePanel.container, true, true)
await thisObject.tradingSystemWorkspace.initialize()
// thisObject.sidePanel.areas.push(thisObject.investmentPlanWorkspace)
// thisObject.sidePanel.areas.push(thisObject.tradingSystemWorkspace)
}
function makeVisible () {
if (thisObject.investmentPlanWorkspace.isDeployed !== true) {
thisObject.investmentPlanWorkspace.deploydInvestmentPlan()
if (thisObject.tradingSystemWorkspace.isDeployed !== true) {
thisObject.tradingSystemWorkspace.deploydTradingSystem()
}
canvas.floatingSpace.makeVisible()
visible = true
@@ -46,8 +46,8 @@ function newStrategySpace () {
function getContainer (point) {
let container
if (thisObject.investmentPlanWorkspace !== undefined) {
container = thisObject.investmentPlanWorkspace.getContainer(point)
if (thisObject.tradingSystemWorkspace !== undefined) {
container = thisObject.tradingSystemWorkspace.getContainer(point)
if (container !== undefined) { return container }
}
+1 -2
View File
@@ -44,7 +44,7 @@ function newStrategyCollectionItem () {
function onMouseClick (event) {
if (status === 'off') {
canvas.floatingSpace.makeVisible()
thisObject.strategy = newInvestmentPlan()
thisObject.strategy = newTradingSystem()
thisObject.strategy.initialize(thisObject.strategySource)
status = 'on'
} else {
@@ -175,4 +175,3 @@ function newStrategyCollectionItem () {
browserCanvasContext.drawImage(thisObject.icon, point1.x - IMAGE_SIZE / 2, point1.y - IMAGE_SIZE / 2, IMAGE_SIZE, IMAGE_SIZE)
}
}
@@ -1,9 +1,9 @@
function newInvestmentPlan () {
const MODULE_NAME = 'Investment Plan'
function newTradingSystem () {
const MODULE_NAME = 'Trading System'
let thisObject = {
investmentPlan: undefined,
tradingSystem: undefined,
container: undefined,
getContainer: getContainer,
initialize: initialize,
@@ -29,7 +29,7 @@ function newInvestmentPlan () {
}
function initialize (strategies) {
thisObject.investmentPlan = {
thisObject.tradingSystem = {
strategies: strategies
}
generateStrategyParts()
@@ -80,13 +80,13 @@ function newInvestmentPlan () {
function generateStrategyParts () {
let lastPhase
let investmentPlan = thisObject.investmentPlan
let tradingSystem = thisObject.tradingSystem
createPart('Investment Plan', '', investmentPlan, undefined, undefined)
createPart('Trading System', '', tradingSystem, undefined, undefined)
for (m = 0; m < investmentPlan.strategies.length; m++) {
let strategy = investmentPlan.strategies[m]
createPart('Strategy', strategy.name, strategy, investmentPlan, investmentPlan)
for (m = 0; m < tradingSystem.strategies.length; m++) {
let strategy = tradingSystem.strategies[m]
createPart('Strategy', strategy.name, strategy, tradingSystem, tradingSystem)
createPart('Strategy Entry Event', '', strategy.entryPoint, strategy, strategy)
for (let k = 0; k < strategy.entryPoint.situations.length; k++) {
@@ -171,7 +171,7 @@ function newInvestmentPlan () {
}
function destroyStrategyParts () {
let strategy = thisObject.investmentPlan
let strategy = thisObject.tradingSystem
destroyPart(strategy)
destroyPart(strategy.entryPoint)
@@ -1,6 +1,6 @@
function newInvestmentPlanWorkspace () {
const MODULE_NAME = 'Investment Plan Workspace'
function newTradingSystemWorkspace () {
const MODULE_NAME = 'Trading System Workspace'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
@@ -9,7 +9,7 @@ function newInvestmentPlanWorkspace () {
isDeployed: false,
strategies: undefined,
container: undefined,
deploydInvestmentPlan: deploydInvestmentPlan,
deploydTradingSystem: deploydTradingSystem,
draw: draw,
getContainer: getContainer,
initialize: initialize
@@ -122,8 +122,8 @@ function newInvestmentPlanWorkspace () {
}
}
function deploydInvestmentPlan () {
thisObject.strategy = newInvestmentPlan()
function deploydTradingSystem () {
thisObject.strategy = newTradingSystem()
thisObject.strategy.initialize(thisObject.strategies)
thisObject.isDeployed = true
}