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

+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
}