10 files changed
+79
-244
No files matched your search
@@ -78,7 +78,10 @@ function newRestartSimulation () {
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
if (thisObject.visible !== true || (thisObject.status !== 'Ready' && thisObject.status !== 'Calculating') || executionFocusExists === false) { return }
|
||||
if (
|
||||
thisObject.visible !== true ||
|
||||
(thisObject.status !== 'Ready' && thisObject.status !== 'Backtesting' && thisObject.status !== 'Live Trading') ||
|
||||
executionFocusExists === false) { return }
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
@@ -112,27 +115,26 @@ function newRestartSimulation () {
|
||||
thisObject.status = 'Error'
|
||||
counterTillNextState = 500
|
||||
} else {
|
||||
if (idleLabel === 'START LIVE TRADING') {
|
||||
callServer('', 'ResetLogsAndData', onSaved)
|
||||
function onSaved (err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
logger.write('[INFO] Restart Simulation -> Logs and Simulation data Deleted.')
|
||||
} else {
|
||||
logger.write('[ERROR] Restart Simulation -> Can not delete Logs and Simulation data. err = ' + err.messsage)
|
||||
}
|
||||
callServer('', 'ResetLogsAndData', onSaved)
|
||||
function onSaved (err) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
logger.write('[ERROR] Restart Simulation -> Can not delete Logs and Simulation data. err = ' + err.messsage)
|
||||
}
|
||||
}
|
||||
if (idleLabel === 'START LIVE TRADING') {
|
||||
let event = {
|
||||
definition: getDefinition()
|
||||
}
|
||||
systemEventHandler.raiseEvent('Cockpit-Restart-Button', 'Live-Trading Started', event)
|
||||
thisObject.status = 'Live Trading'
|
||||
} else {
|
||||
let event = {
|
||||
definition: getDefinition()
|
||||
}
|
||||
systemEventHandler.raiseEvent('Cockpit-Restart-Button', 'Backstesting Started', event)
|
||||
thisObject.status = 'Backtesting'
|
||||
}
|
||||
|
||||
thisObject.status = 'Calculating'
|
||||
isRunning = true
|
||||
}
|
||||
} else {
|
||||
@@ -190,9 +192,6 @@ function newRestartSimulation () {
|
||||
break
|
||||
case 'Saving':
|
||||
|
||||
break
|
||||
case 'Calculating':
|
||||
|
||||
break
|
||||
case 'Stopping':
|
||||
|
||||
@@ -269,7 +268,10 @@ function newRestartSimulation () {
|
||||
case 'Saving':
|
||||
params.backgroundColor = UI_COLOR.GREY
|
||||
break
|
||||
case 'Calculating':
|
||||
case 'Backtesting':
|
||||
params.backgroundColor = UI_COLOR.GREEN
|
||||
break
|
||||
case 'Live Trading':
|
||||
params.backgroundColor = UI_COLOR.TITANIUM_YELLOW
|
||||
break
|
||||
case 'Stopping':
|
||||
@@ -304,8 +306,11 @@ function newRestartSimulation () {
|
||||
case 'Saving':
|
||||
label = 'SAVING STRATEGIES CHANGES...'
|
||||
break
|
||||
case 'Calculating':
|
||||
label = 'STOP CALCULATING'
|
||||
case 'Backtesting':
|
||||
label = 'STOP BACKTESTING'
|
||||
break
|
||||
case 'Live Trading':
|
||||
label = 'STOP LIVE TRADING'
|
||||
break
|
||||
case 'Stopping':
|
||||
label = 'STOPPING...'
|
||||
|
||||
+18
-9
@@ -2,16 +2,7 @@ let canvas
|
||||
let markets
|
||||
let ecosystem = newEcosystem()
|
||||
let systemEventHandler
|
||||
|
||||
let viewPort
|
||||
try {
|
||||
viewPort = newViewPort()
|
||||
} catch (e) {
|
||||
setTimeout(() => {
|
||||
console.log('Loading deferred.')
|
||||
viewPort = newViewPort()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function newDashboard () {
|
||||
const MODULE_NAME = 'Dashboard'
|
||||
@@ -33,6 +24,9 @@ function newDashboard () {
|
||||
|
||||
function start () {
|
||||
try {
|
||||
setBrowserEvents()
|
||||
viewPort = newViewPort()
|
||||
|
||||
systemEventHandler = newSystemEventHandler()
|
||||
systemEventHandler.initialize(startCanvas)
|
||||
|
||||
@@ -107,4 +101,19 @@ function newDashboard () {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] browserResized -> err = ' + err.stack) }
|
||||
}
|
||||
}
|
||||
|
||||
function setBrowserEvents () {
|
||||
window.onbeforeunload = onBrowserClosed
|
||||
function onBrowserClosed () {
|
||||
stopAllRunningTasks()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllRunningTasks () {
|
||||
let definition = canvas.strategySpace.workspace.definition
|
||||
for (let i = 0; i < definition.taskManagers.length; i++) {
|
||||
taskManager = definition.taskManagers[i]
|
||||
taskManager.payload.uiObject.menu.internalClick('Stop All Tasks')
|
||||
}
|
||||
}
|
||||
@@ -124,8 +124,8 @@ function newStrategyPartConstructor () {
|
||||
currentStatus: true,
|
||||
label: undefined,
|
||||
visible: true,
|
||||
iconPathOn: 'menu-mobility-freeze',
|
||||
iconPathOff: 'menu-mobility-unfreeze',
|
||||
iconPathOn: 'menu-mobility-unfreeze',
|
||||
iconPathOff: 'menu-mobility-freeze',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
@@ -136,7 +136,7 @@ function newStrategyPartConstructor () {
|
||||
{
|
||||
action: 'Collapse / Uncollapse',
|
||||
actionFunction: floatingObject.collapseToggle,
|
||||
actionStatus: floatingObject.getCollapeseStatus,
|
||||
actionStatus: floatingObject.getCollapseStatus,
|
||||
currentStatus: false,
|
||||
label: undefined,
|
||||
visible: true,
|
||||
|
||||
+12
-3
@@ -257,10 +257,19 @@ function newProductStorage (pName) {
|
||||
return
|
||||
}
|
||||
}
|
||||
let event = {
|
||||
totalValue: pCaller.getExpectedFiles(),
|
||||
currentValue: pCaller.getFilesLoaded()
|
||||
let event
|
||||
if (pCaller !== undefined) {
|
||||
event = {
|
||||
totalValue: pCaller.getExpectedFiles(),
|
||||
currentValue: pCaller.getFilesLoaded()
|
||||
}
|
||||
} else { // When there are no data the reference to the caller wont arrive here.
|
||||
event = {
|
||||
totalValue: 1,
|
||||
currentValue: 1
|
||||
}
|
||||
}
|
||||
|
||||
thisObject.eventHandler.raiseEvent('File Sequence Loaded', event)
|
||||
|
||||
if (event.currentValue === event.totalValue) {
|
||||
|
||||
+4
-23
@@ -3,14 +3,11 @@ function newTopSpace () {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
endUser: undefined,
|
||||
currentEvent: undefined,
|
||||
login: undefined,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
var container = newContainer()
|
||||
let container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
@@ -20,19 +17,7 @@ function newTopSpace () {
|
||||
|
||||
return thisObject
|
||||
|
||||
async function initialize () {
|
||||
let sharedStatus = {
|
||||
currentDevTeamIndex: 0,
|
||||
currentEventIndex: 0,
|
||||
currentUserBotIndex: 0,
|
||||
currentProcessIndex: 0,
|
||||
currentBotType: '',
|
||||
eventHandler: newEventHandler()
|
||||
}
|
||||
|
||||
thisObject.login = newLogin()
|
||||
await thisObject.login.initialize(sharedStatus)
|
||||
|
||||
function initialize () {
|
||||
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
}
|
||||
|
||||
@@ -43,7 +28,7 @@ function newTopSpace () {
|
||||
container.frame.position.x = 0
|
||||
try {
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||
} catch(e) { }
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
@@ -66,10 +51,6 @@ function newTopSpace () {
|
||||
|
||||
drawBackground()
|
||||
return
|
||||
|
||||
thisObject.endUser.draw()
|
||||
thisObject.currentEvent.draw()
|
||||
thisObject.login.draw()
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
|
||||
@@ -116,6 +116,11 @@ function newAttachDetach () {
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Parameters': {
|
||||
node.payload.parentNode.parameters = undefined
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
case 'Strategy': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.strategies.length; i++) {
|
||||
|
||||
@@ -157,7 +157,19 @@ function newNodeDeleter () {
|
||||
deleteCloseExecution(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Event': {
|
||||
case 'Trigger On Event': {
|
||||
deleteEvent(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Trigger Off Event': {
|
||||
deleteEvent(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Take Position Event': {
|
||||
deleteEvent(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Next Phase Event': {
|
||||
deleteEvent(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
@@ -187,7 +199,7 @@ function newNodeDeleter () {
|
||||
}
|
||||
|
||||
default: {
|
||||
console.log('WARNING this node type is not listed at NodeDeleter: ' + node.type)
|
||||
console.log('WARNING this node type is not listed at NodeDeleter: ' + rootNode.type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ function newWorkspace () {
|
||||
let droppedNode = JSON.parse(nodeText)
|
||||
|
||||
if (droppedNode.type === 'Workspace') {
|
||||
stopAllRunningTasks()
|
||||
functionLibraryNodeDeleter.deleteWorkspace(workspaceNode, workspaceNode.rootNodes)
|
||||
workspaceNode = droppedNode
|
||||
functionLibraryPartsFromNodes.createPartFromNode(workspaceNode, undefined, undefined)
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
|
||||
function newLogin () {
|
||||
const MODULE_NAME = 'Login'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
let container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
thisObject.container.frame.width = 200
|
||||
thisObject.container.frame.height = COCKPIT_SPACE_HEIGHT
|
||||
|
||||
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 1
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y + BREAKPOINT_HEIGHT
|
||||
|
||||
container.isDraggeable = false
|
||||
container.isClickeable = true
|
||||
|
||||
return thisObject
|
||||
|
||||
async function initialize (sharedStatus) {
|
||||
try {
|
||||
if (window.canvasApp.executingAt === 'Local') { return }
|
||||
|
||||
const accessToken = window.localStorage.getItem('access_token')
|
||||
|
||||
if (accessToken) {
|
||||
await getEvents(accessToken, sharedStatus)
|
||||
// await getClones(accessToken)
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err.stack = ' + err.stack) }
|
||||
}
|
||||
}
|
||||
|
||||
async function getEvents (accessToken, sharedStatus) {
|
||||
var d = new Date()
|
||||
var nowSeconds = Math.round(d.getTime() / 1000)
|
||||
var twoWeeksAgoSeconds = nowSeconds - 1209600
|
||||
|
||||
let response = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`query events($maxStartDate: Int, $minEndDate: Int){
|
||||
events_Events(maxStartDate: $maxStartDate, minEndDate: $minEndDate){
|
||||
id
|
||||
title
|
||||
startDatetime
|
||||
endDatetime
|
||||
participants{
|
||||
clone{
|
||||
id
|
||||
team{
|
||||
slug
|
||||
}
|
||||
bot{
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
},
|
||||
variables: {
|
||||
variables: { maxStartDate: nowSeconds, minEndDate: twoWeeksAgoSeconds }
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (response.data.errors) {
|
||||
console.log('Error getting events: ' + JSON.stringify(response.data.errors))
|
||||
throw 'Error getting events: ' + JSON.stringify(response.data.errors)
|
||||
} else {
|
||||
window.localStorage.setItem('currentEvents', JSON.stringify(response.data.data.events_Events))
|
||||
currentEvent = window.localStorage.getItem('currentEventObject')
|
||||
if (currentEvent === null || currentEvent === '[]' || currentEvent === '') {
|
||||
sharedStatus.currentEventIndex = -1
|
||||
} else {
|
||||
currentEvent = JSON.parse(currentEvent)
|
||||
sharedStatus.currentEventIndex = response.data.data.events_Events.findIndex(function (element) {
|
||||
return element.id == currentEvent.id
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getClones (accessToken) {
|
||||
let response = await axios({
|
||||
url: window.canvasApp.graphQL.masterAppApiUrl,
|
||||
method: 'post',
|
||||
data: {
|
||||
query:
|
||||
`query Operations_Clones{
|
||||
operations_Clones {
|
||||
id
|
||||
authId
|
||||
teamId
|
||||
botId
|
||||
mode
|
||||
resumeExecution
|
||||
beginDatetime
|
||||
endDatetime
|
||||
waitTime
|
||||
state
|
||||
stateDatetime
|
||||
createDatetime
|
||||
lastLogs
|
||||
summaryDate
|
||||
buyAverage
|
||||
sellAverage
|
||||
marketRate
|
||||
combinedProfitsA
|
||||
combinedProfitsB
|
||||
assetA
|
||||
assetB
|
||||
botType
|
||||
teamName
|
||||
botName
|
||||
botAvatar
|
||||
teamAvatar
|
||||
processName
|
||||
keyId
|
||||
botSlug
|
||||
}
|
||||
}
|
||||
`
|
||||
},
|
||||
headers: {
|
||||
authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
|
||||
if (response.data.errors) {
|
||||
console.log('Error getting clones: ' + JSON.stringify(response.data.errors))
|
||||
throw 'Error getting clones: ' + JSON.stringify(response.data.errors)
|
||||
} else {
|
||||
window.localStorage.setItem('userClones', JSON.stringify(response.data.data.operations_Clones))
|
||||
let clones = response.data.data.operations_Clones
|
||||
for (let i = 0; i < clones.length; i++) {
|
||||
let clone = clones[i]
|
||||
if (clone.botType === 'Trading') {
|
||||
let teamSlug = clone.teamName.toLowerCase()
|
||||
teamSlug = teamSlug.replace(' ', '-')
|
||||
let devTeam = ecosystem.getTeam(teamSlug)
|
||||
let bot = ecosystem.getBot(devTeam, clone.botSlug)
|
||||
if (bot !== undefined) {
|
||||
bot.cloneId = clone.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onClick () {
|
||||
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
/* First we check if this point is inside this object UI. */
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return this.container
|
||||
} else {
|
||||
/* This point does not belong to this space. */
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
return // nothing to show.
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ function getSimulationParams () {
|
||||
let timePeriod = timePeriodArray[currentTimePeriod.timePeriodIndex][1]
|
||||
|
||||
let simulationParams = {
|
||||
beginDatetime: dateAtScreenCorner.valueOf(),
|
||||
beginDatetime: dateAtScreenCorner,
|
||||
timePeriod: timePeriod,
|
||||
timestamp: (new Date()).valueOf()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user