Sessions Concept Implemented

This commit is contained in:
Luis Fernando Molina committed 2019-10-02 17:52:36 +02:00
1 parent abf95065f6
commit fcc2407e01
8 files changed
+425 -2

No files matched your search

+2 -1
View File
@@ -812,7 +812,7 @@ function newStrategyPart () {
let label
if (radius > 6) {
const MAX_LABEL_LENGTH = 20
const MAX_LABEL_LENGTH = 30
label = thisObject.payload.subTitle
label = addIndexNumber(label)
@@ -1130,3 +1130,4 @@ function newStrategyPart () {
}
}
}
@@ -102,6 +102,26 @@ function newAttachDetach () {
completeDetachment(node, rootNodes)
return
}
case 'Backtesting Session': {
node.payload.parentNode.session = undefined
completeDetachment(node, rootNodes)
return
}
case 'Live Trading Session': {
node.payload.parentNode.session = undefined
completeDetachment(node, rootNodes)
return
}
case 'Fordward Testing Session': {
node.payload.parentNode.session = undefined
completeDetachment(node, rootNodes)
return
}
case 'Paper Trading Session': {
node.payload.parentNode.session = undefined
completeDetachment(node, rootNodes)
return
}
case 'Process': {
let payload = node.payload
for (let i = 0; i < payload.parentNode.processes.length; i++) {
@@ -348,6 +368,34 @@ function newAttachDetach () {
completeAttachment(node, rootNodes)
}
break
case 'Backtesting Session': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.session = node
completeAttachment(node, rootNodes)
}
break
case 'Live Trading Session': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.session = node
completeAttachment(node, rootNodes)
}
break
case 'Fordward Testing Session': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.session = node
completeAttachment(node, rootNodes)
}
break
case 'Paper Trading Session': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.session = node
completeAttachment(node, rootNodes)
}
break
case 'Personal Data': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
@@ -35,6 +35,18 @@ function newNodeChildren () {
case 'Process': {
return countChildrenProcess(parentNode, childNode)
}
case 'Backtesting Session': {
return countBacktestingSession(parentNode, childNode)
}
case 'Live Trading Session': {
return countLiveTradingSession(parentNode, childNode)
}
case 'Fordward Testing Session': {
return countFordwardTestingSession(parentNode, childNode)
}
case 'Paper Trading Session': {
return countPaperTradingSession(parentNode, childNode)
}
case 'Personal Data': {
return countChildrenPersonalData(parentNode, childNode)
}
@@ -276,6 +288,62 @@ function newNodeChildren () {
}
function countChildrenProcess (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.session !== undefined) {
response.childrenCount++
if (parentNode.session.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countBacktestingSession (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.parameters !== undefined) {
response.childrenCount++
if (parentNode.parameters.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countLiveTradingSession (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.parameters !== undefined) {
response.childrenCount++
if (parentNode.parameters.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countFordwardTestingSession (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
}
if (parentNode.parameters !== undefined) {
response.childrenCount++
if (parentNode.parameters.id === childNode.id) {
response.childIndex = response.childrenCount
}
}
return response
}
function countPaperTradingSession (parentNode, childNode) {
let response = {
childrenCount: 0,
childIndex: undefined
@@ -15,6 +15,10 @@ function newNodeDeleter () {
deleteExchangeAccountKey: deleteExchangeAccountKey,
deleteWorkspace: deleteWorkspace,
deleteTradingSystem: deleteTradingSystem,
deleteBacktestingSession: deleteBacktestingSession,
deleteLiveTradingSession: deleteLiveTradingSession,
deleteFordwardTestingSession: deleteFordwardTestingSession,
deletePaperTradingSession: deletePaperTradingSession,
deleteParameters: deleteParameters,
deleteBaseAsset: deleteBaseAsset,
deleteTimeRange: deleteTimeRange,
@@ -108,6 +112,22 @@ function newNodeDeleter () {
deleteTradingSystem(rootNode, rootNodes)
break
}
case 'Backtesting Session': {
deleteBacktestingSession(rootNode, rootNodes)
break
}
case 'Live Trading Session': {
deleteLiveTradingSession(rootNode, rootNodes)
break
}
case 'Fordward Testing Session': {
deleteFordwardTestingSession(rootNode, rootNodes)
break
}
case 'Paper Trading Session': {
deletePaperTradingSession(rootNode, rootNodes)
break
}
case 'Parameters': {
deleteParameters(rootNode, rootNodes)
break
@@ -365,10 +385,87 @@ function newNodeDeleter () {
}
}
if (node.session !== undefined) {
switch (node.session.type) {
case 'Backtesting Session': {
deleteBacktestingSession(node.session, rootNodes)
break
}
case 'Live Trading Session': {
deleteLiveTradingSession(node.session, rootNodes)
break
}
case 'Fordward Testing Session': {
deleteFordwardTestingSession(node.session, rootNodes)
break
}
case 'Paper Trading Session': {
deletePaperTradingSession(node.session, rootNodes)
break
}
}
}
completeDeletion(node, rootNodes)
destroyPart(node)
cleanNode(node)
}
function deleteBacktestingSession (node, rootNodes) {
let payload = node.payload
if (payload.parentNode !== undefined) {
payload.parentNode.session = undefined
}
if (node.parameters !== undefined) {
deleteParameters(node.parameters, rootNodes)
}
completeDeletion(node, rootNodes)
destroyPart(node)
cleanNode(node)
}
function deleteLiveTradingSession (node, rootNodes) {
let payload = node.payload
if (payload.parentNode !== undefined) {
payload.parentNode.session = undefined
}
if (node.parameters !== undefined) {
deleteParameters(node.parameters, rootNodes)
}
completeDeletion(node, rootNodes)
destroyPart(node)
cleanNode(node)
}
function deleteFordwardTestingSession (node, rootNodes) {
let payload = node.payload
if (payload.parentNode !== undefined) {
payload.parentNode.session = undefined
}
if (node.parameters !== undefined) {
deleteParameters(node.parameters, rootNodes)
}
completeDeletion(node, rootNodes)
destroyPart(node)
cleanNode(node)
}
function deletePaperTradingSession (node, rootNodes) {
let payload = node.payload
if (payload.parentNode !== undefined) {
payload.parentNode.session = undefined
}
if (node.parameters !== undefined) {
deleteParameters(node.parameters, rootNodes)
}
completeDeletion(node, rootNodes)
destroyPart(node)
cleanNode(node)
@@ -9,6 +9,10 @@ function newPartsFromNodes () {
addIndicator: addIndicator,
addTradingEngine: addTradingEngine,
addProcess: addProcess,
addBacktestingSession: addBacktestingSession,
addLiveTradingSession: addLiveTradingSession,
addFordwardTestingSession: addFordwardTestingSession,
addPaperTradingSession: addPaperTradingSession,
addTradingSystem: addTradingSystem,
addPersonalData: addPersonalData,
addExchangeAccount: addExchangeAccount,
@@ -424,6 +428,34 @@ function newPartsFromNodes () {
}
}
createPart('Process', node.name, node, parentNode, chainParent, 'Process')
if (node.session !== undefined) {
createPartFromNode(node.session, node, node)
}
return
}
case 'Backtesting Session': {
createPart('Backtesting Session', node.name, node, parentNode, chainParent, 'Backtesting Session')
if (node.parameters !== undefined) {
createPartFromNode(node.parameters, node, node)
}
return
}
case 'Live Trading Session': {
createPart('Live Trading Session', node.name, node, parentNode, chainParent, 'Live Trading Session')
if (node.parameters !== undefined) {
createPartFromNode(node.parameters, node, node)
}
return
}
case 'Fordward Testing Session': {
createPart('Fordward Testing Session', node.name, node, parentNode, chainParent, 'Fordward Testing Session')
if (node.parameters !== undefined) {
createPartFromNode(node.parameters, node, node)
}
return
}
case 'Paper Trading Session': {
createPart('Paper Trading Session', node.name, node, parentNode, chainParent, 'Paper Trading Session')
if (node.parameters !== undefined) {
createPartFromNode(node.parameters, node, node)
}
@@ -537,6 +569,50 @@ function newPartsFromNodes () {
return process
}
function addBacktestingSession (node) {
if (node.session === undefined) {
node.session = {
name: 'New Backtesting Session'
}
createPart('Backtesting Session', '', node.session, node, node)
}
return node.session
}
function addLiveTradingSession (node) {
if (node.session === undefined) {
node.session = {
name: 'New Live Trading Session'
}
createPart('Live Trading Session', '', node.session, node, node)
}
return node.session
}
function addFordwardTestingSession (node) {
if (node.session === undefined) {
node.session = {
name: 'New Fordward Testing Session'
}
createPart('Fordward Testing Session', '', node.session, node, node)
}
return node.session
}
function addPaperTradingSession (node) {
if (node.session === undefined) {
node.session = {
name: 'New Paper Trading Session'
}
createPart('Paper Trading Session', '', node.session, node, node)
}
return node.session
}
function addTradingSystem (node) {
if (node.tradingSystem === undefined) {
node.tradingSystem = {
@@ -444,7 +444,7 @@ function newProtocolNode () {
subType: node.subType,
name: node.name,
code: node.code,
parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds)
session: getProtocolNode(node.session, removePersonalData, parseJSONStrings, includeIds)
}
if (parseJSONStrings) {
object.code = JSON.parse(object.code)
@@ -454,6 +454,59 @@ function newProtocolNode () {
}
return object
}
case 'Backtesting Session': {
let object = {
type: node.type,
subType: node.subType,
name: node.name,
parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds)
}
if (includeIds) {
object.id = node.id
}
return object
}
case 'Live Trading Session': {
let object = {
type: node.type,
subType: node.subType,
name: node.name,
parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds)
}
if (includeIds) {
object.id = node.id
}
return object
}
case 'Fordward Testing Session': {
let object = {
type: node.type,
subType: node.subType,
name: node.name,
parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds)
}
if (includeIds) {
object.id = node.id
}
return object
}
case 'Paper Trading Session': {
let object = {
type: node.type,
subType: node.subType,
name: node.name,
parameters: getProtocolNode(node.parameters, removePersonalData, parseJSONStrings, includeIds)
}
if (includeIds) {
object.id = node.id
}
return object
}
case 'Network Node': {
let object = {
type: node.type,
@@ -524,6 +524,50 @@ function newStringifyNode () {
subType: node.subType,
name: node.name,
code: node.code,
session: prepareForStringify(node.session, removePersonalData),
savedPayload: getSavedPayload(node)
}
return object
}
case 'Backtesting Session': {
let object = {
id: node.id,
type: node.type,
subType: node.subType,
name: node.name,
parameters: prepareForStringify(node.parameters, removePersonalData),
savedPayload: getSavedPayload(node)
}
return object
}
case 'Live Trading Session': {
let object = {
id: node.id,
type: node.type,
subType: node.subType,
name: node.name,
parameters: prepareForStringify(node.parameters, removePersonalData),
savedPayload: getSavedPayload(node)
}
return object
}
case 'Fordward Testing Session': {
let object = {
id: node.id,
type: node.type,
subType: node.subType,
name: node.name,
parameters: prepareForStringify(node.parameters, removePersonalData),
savedPayload: getSavedPayload(node)
}
return object
}
case 'Paper Trading Session': {
let object = {
id: node.id,
type: node.type,
subType: node.subType,
name: node.name,
parameters: prepareForStringify(node.parameters, removePersonalData),
savedPayload: getSavedPayload(node)
}
+36
View File
@@ -286,6 +286,26 @@ function newWorkspace () {
functionLibraryPartsFromNodes.addProcess(payload.node)
}
break
case 'Add Backtesting Session':
{
functionLibraryPartsFromNodes.addBacktestingSession(payload.node)
}
break
case 'Add Live Trading Session':
{
functionLibraryPartsFromNodes.addLiveTradingSession(payload.node)
}
break
case 'Add Fordward Testing Session':
{
functionLibraryPartsFromNodes.addFordwardTestingSession(payload.node)
}
break
case 'Add Paper Trading Session':
{
functionLibraryPartsFromNodes.addPaperTradingSession(payload.node)
}
break
case 'Add Strategy':
{
functionLibraryPartsFromNodes.addStrategy(payload.node)
@@ -418,6 +438,22 @@ function newWorkspace () {
functionLibraryNodeDeleter.deleteProcess(payload.node, workspaceNode.rootNodes)
break
}
case 'Delete Backtesting Session': {
functionLibraryNodeDeleter.deleteBacktestingSession(payload.node, workspaceNode.rootNodes)
break
}
case 'Delete Live Trading Session': {
functionLibraryNodeDeleter.deleteLiveTradingSession(payload.node, workspaceNode.rootNodes)
break
}
case 'Delete Fordward Testing Session': {
functionLibraryNodeDeleter.deleteFordwardTestingSession(payload.node, workspaceNode.rootNodes)
break
}
case 'Delete Paper Trading Session': {
functionLibraryNodeDeleter.deletePaperTradingSession(payload.node, workspaceNode.rootNodes)
break
}
case 'Delete Trading System': {
functionLibraryNodeDeleter.deleteTradingSystem(payload.node, workspaceNode.rootNodes)
break