diff --git a/ChartsSpace/ChartUtilities.js b/ChartsSpace/ChartUtilities.js index e7d29bd8a..16f47e1d0 100644 --- a/ChartsSpace/ChartUtilities.js +++ b/ChartsSpace/ChartUtilities.js @@ -1,48 +1,48 @@ -function getSideDays (timePeriod) { +function getSideDays (timeFrame) { let daysOnSides - if (timePeriod < _1_HOUR_IN_MILISECONDS) { + if (timeFrame < _1_HOUR_IN_MILISECONDS) { daysOnSides = 1 } - if (timePeriod === _1_HOUR_IN_MILISECONDS) { + if (timeFrame === _1_HOUR_IN_MILISECONDS) { daysOnSides = 9 } - if (timePeriod === _2_HOURS_IN_MILISECONDS) { + if (timeFrame === _2_HOURS_IN_MILISECONDS) { daysOnSides = 10 } - if (timePeriod === _3_HOURS_IN_MILISECONDS) { + if (timeFrame === _3_HOURS_IN_MILISECONDS) { daysOnSides = 12 } - if (timePeriod === _4_HOURS_IN_MILISECONDS) { + if (timeFrame === _4_HOURS_IN_MILISECONDS) { daysOnSides = 20 } - if (timePeriod === _6_HOURS_IN_MILISECONDS) { + if (timeFrame === _6_HOURS_IN_MILISECONDS) { daysOnSides = 35 } - if (timePeriod === _8_HOURS_IN_MILISECONDS) { + if (timeFrame === _8_HOURS_IN_MILISECONDS) { daysOnSides = 44 } - if (timePeriod === _12_HOURS_IN_MILISECONDS) { + if (timeFrame === _12_HOURS_IN_MILISECONDS) { daysOnSides = 56 } - if (timePeriod === ONE_DAY_IN_MILISECONDS) { + if (timeFrame === ONE_DAY_IN_MILISECONDS) { daysOnSides = 154 } return daysOnSides } -function getCondenseFactor (timePeriod) { - switch (timePeriod) { +function getCondenseFactor (timeFrame) { + switch (timeFrame) { case _1_MINUTE_IN_MILISECONDS: return 1 case _5_MINUTES_IN_MILISECONDS: return 5 case _10_MINUTES_IN_MILISECONDS: return 10 @@ -51,8 +51,8 @@ function getCondenseFactor (timePeriod) { } } -function getTransparenceFactor (timePeriod) { - switch (timePeriod) { +function getTransparenceFactor (timeFrame) { + switch (timeFrame) { case _1_MINUTE_IN_MILISECONDS: return '0.12' case _5_MINUTES_IN_MILISECONDS: return '0.10' case _10_MINUTES_IN_MILISECONDS: return '0.08' diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 64f7a288a..75b6c2811 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -6,14 +6,14 @@ function newPlottersManager () { let productPlotters = [] - let timePeriod = INITIAL_TIME_PERIOD + let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE let thisObject = { fitFunction: undefined, container: undefined, setDatetime: setDatetime, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, positionAtDatetime: positionAtDatetime, draw: draw, getContainer: getContainer, @@ -158,7 +158,7 @@ function newPlottersManager () { } } - storage.initialize(pProductCard.dataMine, pProductCard.bot, pProductCard.session, pProductCard.product, exchange, market, datetime, timePeriod, onProductStorageInitialized) + storage.initialize(pProductCard.dataMine, pProductCard.bot, pProductCard.session, pProductCard.product, exchange, market, datetime, timeFrame, onProductStorageInitialized) function onProductStorageInitialized (err) { try { @@ -203,7 +203,7 @@ function newPlottersManager () { plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2 plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2 plotter.fitFunction = thisObject.fitFunction - plotter.initialize(storage, exchange, market, datetime, timePeriod, onPlotterInizialized, productDefinition) + plotter.initialize(storage, exchange, market, datetime, timeFrame, onPlotterInizialized, productDefinition) function onPlotterInizialized () { try { @@ -316,14 +316,14 @@ function newPlottersManager () { } } - function setTimePeriod (pTimePeriod) { - timePeriod = pTimePeriod + function setTimeFrame (pTimeFrame) { + timeFrame = pTimeFrame if (initializationReady === true) { for (let i = 0; i < productPlotters.length; i++) { let productPlotter = productPlotters[i] - productPlotter.productCard.setTimePeriod(timePeriod) - productPlotter.storage.setTimePeriod(timePeriod) - productPlotter.plotter.setTimePeriod(timePeriod) + productPlotter.productCard.setTimeFrame(timeFrame) + productPlotter.storage.setTimeFrame(timeFrame) + productPlotter.plotter.setTimeFrame(timeFrame) } } } diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 1ade95cc3..6736c475c 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -8,7 +8,7 @@ function newTimelineChart () { let timeLineCoordinateSystem - let timePeriod = INITIAL_TIME_PERIOD + let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE let thisObject = { @@ -44,7 +44,7 @@ function newTimelineChart () { let market let productsPanelHandle - let timePeriodScale + let timeFrameScale setupContainer() return thisObject @@ -58,8 +58,8 @@ function newTimelineChart () { function finalize () { plotterManager.finalize() plotterManager = undefined - timePeriodScale.finalize() - timePeriodScale = undefined + timeFrameScale.finalize() + timeFrameScale = undefined canvas.panelsSpace.destroyPanel(productsPanelHandle) thisObject.container.finalize() @@ -120,7 +120,7 @@ function newTimelineChart () { logoAA.src = window.canvasApp.urlPrefix + 'Images/sa-logo-background.png' // moveToUserPosition(thisObject.container, timeLineCoordinateSystem, undefined, undefined, undefined, true) - timePeriod = INITIAL_TIME_PERIOD + timeFrame = INITIAL_TIME_PERIOD datetime = NEW_SESSION_INITIAL_DATE /* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */ @@ -151,17 +151,17 @@ function newTimelineChart () { return } - timePeriodScale = newTimePeriodScale() - timePeriodScale.container.connectToParent(thisObject.container, false, false, false, true, true, true) - timePeriodScale.container.eventHandler.listenToEvent('Time Period Changed', function (event) { - let currentTimePeriod = timePeriod - timePeriod = event.timePeriod - if (timePeriod !== currentTimePeriod) { - plotterManager.setTimePeriod(timePeriod) + timeFrameScale = newTimeFrameScale() + timeFrameScale.container.connectToParent(thisObject.container, false, false, false, true, true, true) + timeFrameScale.container.eventHandler.listenToEvent('Time Frame Changed', function (event) { + let currentTimeFrame = timeFrame + timeFrame = event.timeFrame + if (timeFrame !== currentTimeFrame) { + plotterManager.setTimeFrame(timeFrame) } }) - timePeriodScale.initialize(timeLineCoordinateSystem) + timeFrameScale.initialize(timeLineCoordinateSystem) initializationReady = true callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) @@ -239,7 +239,7 @@ function newTimelineChart () { let container - container = timePeriodScale.getContainer(point) + container = timeFrameScale.getContainer(point) if (container !== undefined) { return container } @@ -289,7 +289,7 @@ function newTimelineChart () { if (thisObject.container.frame.isInViewPort()) { drawChartsBackground() plotterManager.draw() - timePeriodScale.draw() + timeFrameScale.draw() } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js index e28e08a7b..15f7c7d31 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignerSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -33,7 +33,7 @@ function newSessionFunctions () { let lightingPath = '->Definition->' + 'Trading System->' + 'Parameters->' + - 'Base Asset->Time Range->Time Period->Slippage->Fee Structure->Exchange Account Key->' + + 'Base Asset->Time Range->Time Frame->Slippage->Fee Structure->Exchange Account Key->' + 'Strategy->' + 'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' + 'Announcement->Telegram Bot->' + @@ -58,15 +58,15 @@ function newSessionFunctions () { function getUICurrentValues () { let dateAtScreenCorner = new Date(window.localStorage.getItem('Date @ Screen Corner')) - let currentTimePeriod = JSON.parse(window.localStorage.getItem('Current Time Period')) + let currentTimeFrame = JSON.parse(window.localStorage.getItem('Current Time Frame')) - let timePeriodsMasterArray = [marketFilesPeriods, dailyFilePeriods] - let timePeriodArray = timePeriodsMasterArray[currentTimePeriod.filePeriodIndex] - let timePeriod = timePeriodArray[currentTimePeriod.timePeriodIndex][1] + let timeFramesMasterArray = [marketFilesPeriods, dailyFilePeriods] + let timeFrameArray = timeFramesMasterArray[currentTimeFrame.filePeriodIndex] + let timeFrame = timeFrameArray[currentTimeFrame.timeFrameIndex][1] let uiCurrentValues = { initialDatetime: dateAtScreenCorner, - timePeriod: timePeriod, + timeFrame: timeFrame, timestamp: (new Date()).valueOf() } diff --git a/Globals.js b/Globals.js index 4e09972ee..0c9c7149c 100644 --- a/Globals.js +++ b/Globals.js @@ -97,13 +97,13 @@ let dailyFilePeriods = dailyFilePeriods = JSON.parse(dailyFilePeriods); -function convertTimePeriodToName(pTimePeriod) { +function convertTimeFrameToName(pTimeFrame) { for (let i = 0; i < dailyFilePeriods.length; i++) { let period = dailyFilePeriods[i]; - if (period[0] === pTimePeriod) { + if (period[0] === pTimeFrame) { return period[1]; @@ -114,7 +114,7 @@ function convertTimePeriodToName(pTimePeriod) { let period = marketFilesPeriods[i]; - if (period[0] === pTimePeriod) { + if (period[0] === pTimeFrame) { return period[1]; diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index c4777ed5b..539aab0bd 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -16,7 +16,7 @@ function newProductCard () { turnOff: turnOff, turnOn: turnOn, setDatetime: setDatetime, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, onMarketFileLoaded: onMarketFileLoaded, onDailyFileLoaded: onDailyFileLoaded, onSingleFileLoaded: onSingleFileLoaded, @@ -66,7 +66,7 @@ function newProductCard () { opacity: 0.00 } - let timePeriod = INITIAL_TIME_PERIOD + let timeFrame = INITIAL_TIME_PERIOD let datetime = NEW_SESSION_INITIAL_DATE /* TODO We are in a transition period in which bots and dataMines images might be located at different places. @@ -122,7 +122,7 @@ function newProductCard () { legacyBotAvatar = undefined legacyBotAvatarLoaded = undefined legacyPlotterBanner = undefined - timePeriod = undefined + timeFrame = undefined datetime = undefined LOADING_FILL_STYLE = undefined @@ -328,13 +328,13 @@ function newProductCard () { datetime = pDatetime if (currentDate !== newDate) { - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { dailyFileProgressBar.animatedValue = 0 } } } - function setTimePeriod (pTimePeriod) { + function setTimeFrame (pTimeFrame) { /* When the time period below or equal to 1 hour changes, this forces cursors to potentially load more files, thus we reset this counter and @@ -342,10 +342,10 @@ function newProductCard () { */ - if (timePeriod !== pTimePeriod) { - timePeriod = pTimePeriod + if (timeFrame !== pTimeFrame) { + timeFrame = pTimeFrame - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { dailyFileProgressBar.animatedValue = 0 } } diff --git a/Panels/TimeControlPanel.js b/Panels/TimeControlPanel.js index 55d1baa11..7eba4062a 100644 --- a/Panels/TimeControlPanel.js +++ b/Panels/TimeControlPanel.js @@ -16,7 +16,7 @@ function newTimeControlPanel () { thisObject.container = container thisObject.container.frame.containerName = 'Current Datetime' - let timePeriod + let timeFrame let panelTabButton return thisObject @@ -48,7 +48,7 @@ function newTimeControlPanel () { thisObject.datetimeDisplay = datetimeDisplay viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) - timePeriod = INITIAL_TIME_PERIOD + timeFrame = INITIAL_TIME_PERIOD } function onBotChangedTime (pNewDatetime) { @@ -59,7 +59,7 @@ function newTimeControlPanel () { function onZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. - timePeriod = recalculatePeriod(event.newLevel) + timeFrame = recalculatePeriod(event.newLevel) } } @@ -138,10 +138,10 @@ function newTimeControlPanel () { browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - if (timePeriod > _45_MINUTES_IN_MILISECONDS) { - label = timePeriod / _1_HOUR_IN_MILISECONDS + ' hs' + if (timeFrame > _45_MINUTES_IN_MILISECONDS) { + label = timeFrame / _1_HOUR_IN_MILISECONDS + ' hs' } else { - label = timePeriod / _1_MINUTE_IN_MILISECONDS + ' min' + label = timeFrame / _1_MINUTE_IN_MILISECONDS + ' min' } /* Now we transform x on the actual coordinate on the canvas. */ diff --git a/Plotter.js b/Plotter.js index d0f3df203..00fa2a607 100644 --- a/Plotter.js +++ b/Plotter.js @@ -17,7 +17,7 @@ function newPlotter () { finalize: finalize, container: undefined, getContainer: getContainer, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, setDatetime: setDatetime, recalculateScale: recalculateScale, draw: draw, @@ -39,7 +39,7 @@ function newPlotter () { let atMousePositionFillStyles = new Map() let atMousePositionStrokeStyles = new Map() - let timePeriod // This will hold the current Time Period the user is at. + let timeFrame // This will hold the current Time Frame the user is at. let datetime // This will hold the current Datetime the user is at. let marketFile // This is the current Market File being plotted. @@ -77,7 +77,7 @@ function newPlotter () { dailyFiles = undefined datetime = undefined - timePeriod = undefined + timeFrame = undefined marketFile = undefined fileCursor = undefined @@ -94,14 +94,14 @@ function newPlotter () { } } - function initialize (pStorage, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction, pProductDefinition) { + function initialize (pStorage, pExchange, pMarket, pDatetime, pTimeFrame, callBackFunction, pProductDefinition) { try { /* Store the information received. */ marketFiles = pStorage.marketFiles[0] dailyFiles = pStorage.dailyFiles[0] datetime = pDatetime - timePeriod = pTimePeriod + timeFrame = pTimeFrame productDefinition = pProductDefinition @@ -111,8 +111,8 @@ function newPlotter () { recalculateScale() /* Now we set the right files according to current Period. */ - marketFile = marketFiles.getFile(pTimePeriod) - fileCursor = dailyFiles.getFileCursor(pTimePeriod) + marketFile = marketFiles.getFile(pTimeFrame) + fileCursor = dailyFiles.getFileCursor(pTimeFrame) /* Listen to the necesary events. */ zoomChangedEventSubscriptionId = viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged) @@ -137,7 +137,7 @@ function newPlotter () { function onMarketFilesUpdated () { try { - let newMarketFile = marketFiles.getFile(timePeriod) + let newMarketFile = marketFiles.getFile(timeFrame) if (newMarketFile !== undefined) { marketFile = newMarketFile mustRecalculateDataPoints = true @@ -150,7 +150,7 @@ function newPlotter () { function onDailyFilesUpdated () { try { - let newFileCursor = dailyFiles.getFileCursor(timePeriod) + let newFileCursor = dailyFiles.getFileCursor(timeFrame) if (newFileCursor !== undefined) { fileCursor = newFileCursor mustRecalculateDataPoints = true @@ -176,20 +176,20 @@ function newPlotter () { } } - function setTimePeriod (pTimePeriod) { + function setTimeFrame (pTimeFrame) { try { - if (timePeriod !== pTimePeriod) { - timePeriod = pTimePeriod + if (timeFrame !== pTimeFrame) { + timeFrame = pTimeFrame mustRecalculateDataPoints = true - if (timePeriod >= _1_HOUR_IN_MILISECONDS) { - let newMarketFile = marketFiles.getFile(pTimePeriod) + if (timeFrame >= _1_HOUR_IN_MILISECONDS) { + let newMarketFile = marketFiles.getFile(pTimeFrame) if (newMarketFile !== undefined) { marketFile = newMarketFile recalculate() } } else { - let newFileCursor = dailyFiles.getFileCursor(pTimePeriod) + let newFileCursor = dailyFiles.getFileCursor(pTimeFrame) if (newFileCursor !== undefined) { fileCursor = newFileCursor @@ -198,7 +198,7 @@ function newPlotter () { } } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] setTimePeriod -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] setTimeFrame -> err = ' + err.stack) } } } @@ -228,7 +228,7 @@ function newPlotter () { function recalculate () { try { - if (timePeriod >= _1_HOUR_IN_MILISECONDS) { + if (timeFrame >= _1_HOUR_IN_MILISECONDS) { recalculateUsingMarketFiles() } else { recalculateUsingDailyFiles() @@ -272,14 +272,14 @@ function newPlotter () { return jsonifiedArray } - function calculationsProcedure (jsonArray, recordDefinition, calculationsProcedure, timePeriod) { + function calculationsProcedure (jsonArray, recordDefinition, calculationsProcedure, timeFrame) { /* This function has as an input an array of JSON objects, and it adds calculated properties to complete the set of properties that will be available. */ let system = { // These are the available system variables to be used in User Code and Formulas - timePeriod: timePeriod, + timeFrame: timeFrame, ONE_DAY_IN_MILISECONDS: ONE_DAY_IN_MILISECONDS } let variable = {} // This is the structure where the user will define its own variables that will be shared across different code blocks and formulas. @@ -348,7 +348,7 @@ function newPlotter () { if (fileCursor === undefined) { return } // We need to wait until there is a fileCursor if (fileCursor.files.size === 0) { return } // We need to wait until there are files in the cursor - let daysOnSides = getSideDays(timePeriod) + let daysOnSides = getSideDays(timeFrame) let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem) let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem) @@ -373,7 +373,7 @@ function newPlotter () { /* Add the calculated properties */ if (productDefinition.calculations !== undefined) { - let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timePeriod) + let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timeFrame) records.push(...calculationsResult) // This adds records to the current array. } else { records.push(...jsonData)// This adds records to the current array. @@ -401,7 +401,7 @@ function newPlotter () { try { if (marketFile === undefined) { return } // Initialization not complete yet. - let daysOnSides = getSideDays(timePeriod) + let daysOnSides = getSideDays(timeFrame) let leftDate = getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem) let rightDate = getDateFromPoint(viewPort.visibleArea.topRight, thisObject.container, timeLineCoordinateSystem) @@ -426,7 +426,7 @@ function newPlotter () { /* Add the calculated properties */ if (productDefinition.calculations !== undefined) { - let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timePeriod) + let calculationsResult = calculationsProcedure(jsonData, productDefinition.record, productDefinition.calculations, timeFrame) records.push(...calculationsResult) // This adds records to the current array. } else { records.push(...jsonData)// This adds records to the current array. diff --git a/ProductStorage.js b/ProductStorage.js index 3ad5d77f6..1b3323738 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -31,7 +31,7 @@ function newProductStorage (pName) { singleFile: [], fileSequences: [], setDatetime: setDatetime, - setTimePeriod: setTimePeriod, + setTimeFrame: setTimeFrame, initialize: initialize, finalize: finalize } @@ -43,7 +43,7 @@ function newProductStorage (pName) { thisObject.eventHandler.name = 'Storage-' + pName let datetime - let timePeriod + let timeFrame return thisObject @@ -74,10 +74,10 @@ function newProductStorage (pName) { } } - function initialize (pdataMine, pBot, pSession, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { + function initialize (pdataMine, pBot, pSession, pProduct, pExchange, pMarket, pDatetime, pTimeFrame, callBackFunction) { try { datetime = pDatetime - timePeriod = pTimePeriod + timeFrame = pTimeFrame let dataSetsToLoad = 0 let dataSetsLoaded = 0 @@ -99,7 +99,7 @@ function newProductStorage (pName) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onDailyFileReady) + dailyFiles.initialize(pdataMine, pBot, pSession, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimeFrame, onDailyFileReady) thisObject.dailyFiles.push(dailyFiles) } break @@ -309,7 +309,7 @@ function newProductStorage (pName) { datetime = new Date(pDatetime) if (currentDate !== newDate) { - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { for (let i = 0; i < thisObject.dailyFiles.length; i++) { thisObject.dailyFiles[i].setDatetime(pDatetime) } @@ -317,15 +317,15 @@ function newProductStorage (pName) { } } - function setTimePeriod (pTimePeriod) { - /* We are going to filter out the cases in which the timePeriod received is the same that the one we already know. */ + function setTimeFrame (pTimeFrame) { + /* We are going to filter out the cases in which the timeFrame received is the same that the one we already know. */ - if (timePeriod !== pTimePeriod) { - timePeriod = pTimePeriod + if (timeFrame !== pTimeFrame) { + timeFrame = pTimeFrame - if (timePeriod <= _1_HOUR_IN_MILISECONDS) { + if (timeFrame <= _1_HOUR_IN_MILISECONDS) { for (let i = 0; i < thisObject.dailyFiles.length; i++) { - thisObject.dailyFiles[i].setTimePeriod(pTimePeriod, datetime) + thisObject.dailyFiles[i].setTimeFrame(pTimeFrame, datetime) } } } diff --git a/Scales/TimePeriodScale.js b/Scales/TimeFrameScale.js similarity index 80% rename from Scales/TimePeriodScale.js rename to Scales/TimeFrameScale.js index a93330788..df39d022d 100644 --- a/Scales/TimePeriodScale.js +++ b/Scales/TimeFrameScale.js @@ -1,8 +1,8 @@ -function newTimePeriodScale () { - const MODULE_NAME = 'Time Period Scale' +function newTimeFrameScale () { + const MODULE_NAME = 'Time Frame Scale' let thisObject = { - timePeriod: undefined, + timeFrame: undefined, container: undefined, draw: draw, getContainer: getContainer, @@ -25,9 +25,9 @@ function newTimePeriodScale () { let timeLineCoordinateSystem let objectStorage = {} let filePeriodIndex = FILES_PERIOD_DEFAULT_VALUE - let timePeriodIndex = TIME_PERIOD_DEFAULT_VALUE - let timePeriodsMasterArray = [marketFilesPeriods, dailyFilePeriods] - let timePeriodLabel = '' + let timeFrameIndex = TIME_PERIOD_DEFAULT_VALUE + let timeFramesMasterArray = [marketFilesPeriods, dailyFilePeriods] + let timeFrameLabel = '' let onMouseWheelEventSubscriptionId let onMouseOverEventSubscriptionId @@ -66,7 +66,7 @@ function newTimePeriodScale () { onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) readObjectState() - newTimePeriod() + newTimeFrame() onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', function (event) { mouse.position.x = event.x @@ -84,21 +84,21 @@ function newTimePeriodScale () { function onZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. - let currentTimePeriod = thisObject.timePeriod - let timePeriod = recalculatePeriod(event.newLevel) - if (timePeriod !== currentTimePeriod) { - for (let i = 0; i < timePeriodsMasterArray.length; i++) { - let timePeriodArray = timePeriodsMasterArray[i] - for (let j = 0; j < timePeriodArray.length; j++) { - let record = timePeriodArray[j] - if (timePeriod === record[0]) { + let currentTimeFrame = thisObject.timeFrame + let timeFrame = recalculatePeriod(event.newLevel) + if (timeFrame !== currentTimeFrame) { + for (let i = 0; i < timeFramesMasterArray.length; i++) { + let timeFrameArray = timeFramesMasterArray[i] + for (let j = 0; j < timeFrameArray.length; j++) { + let record = timeFrameArray[j] + if (timeFrame === record[0]) { filePeriodIndex = i - timePeriodIndex = j + timeFrameIndex = j } } } saveObjectState() - newTimePeriod() + newTimeFrame() } } } @@ -106,31 +106,31 @@ function newTimePeriodScale () { function onMouseWheel (event) { delta = event.wheelDelta if (delta < 0) { - timePeriodIndex-- - if (timePeriodIndex < 0) { + timeFrameIndex-- + if (timeFrameIndex < 0) { filePeriodIndex-- if (filePeriodIndex < 0) { filePeriodIndex = 0 - timePeriodIndex = 0 + timeFrameIndex = 0 } else { - timePeriodIndex = timePeriodsMasterArray[filePeriodIndex].length - 1 + timeFrameIndex = timeFramesMasterArray[filePeriodIndex].length - 1 } } } else { - timePeriodIndex++ - if (timePeriodIndex > timePeriodsMasterArray[filePeriodIndex].length - 1) { + timeFrameIndex++ + if (timeFrameIndex > timeFramesMasterArray[filePeriodIndex].length - 1) { filePeriodIndex++ - if (filePeriodIndex > timePeriodsMasterArray.length - 1) { - filePeriodIndex = timePeriodsMasterArray.length - 1 - timePeriodIndex = timePeriodsMasterArray[filePeriodIndex].length - 1 + if (filePeriodIndex > timeFramesMasterArray.length - 1) { + filePeriodIndex = timeFramesMasterArray.length - 1 + timeFrameIndex = timeFramesMasterArray[filePeriodIndex].length - 1 } else { - timePeriodIndex = 0 + timeFrameIndex = 0 } } } saveObjectState() - newTimePeriod() + newTimeFrame() } function getContainer (pPoint) { @@ -156,7 +156,7 @@ function newTimePeriodScale () { function saveObjectState () { objectStorage.filePeriodIndex = filePeriodIndex - objectStorage.timePeriodIndex = timePeriodIndex + objectStorage.timeFrameIndex = timeFrameIndex window.localStorage.setItem(MODULE_NAME, JSON.stringify(objectStorage)) } @@ -165,19 +165,19 @@ function newTimePeriodScale () { if (objectStorageString !== null && objectStorageString !== '') { objectStorage = JSON.parse(objectStorageString) filePeriodIndex = objectStorage.filePeriodIndex - timePeriodIndex = objectStorage.timePeriodIndex + timeFrameIndex = objectStorage.timeFrameIndex } } - function newTimePeriod () { - let timePeriodArray = timePeriodsMasterArray[filePeriodIndex] - thisObject.timePeriod = timePeriodArray[timePeriodIndex][0] - timePeriodLabel = timePeriodArray[timePeriodIndex][1] + function newTimeFrame () { + let timeFrameArray = timeFramesMasterArray[filePeriodIndex] + thisObject.timeFrame = timeFrameArray[timeFrameIndex][0] + timeFrameLabel = timeFrameArray[timeFrameIndex][1] let event = {} - event.timePeriod = thisObject.timePeriod - thisObject.container.eventHandler.raiseEvent('Time Period Changed', event) - window.localStorage.setItem('Current Time Period', JSON.stringify({filePeriodIndex: filePeriodIndex, timePeriodIndex: timePeriodIndex})) + event.timeFrame = thisObject.timeFrame + thisObject.container.eventHandler.raiseEvent('Time Frame Changed', event) + window.localStorage.setItem('Current Time Frame', JSON.stringify({filePeriodIndex: filePeriodIndex, timeFrameIndex: timeFrameIndex})) } function draw () { @@ -262,7 +262,7 @@ to be visible at the top of the viewPort. */ /* Common Variables */ - let label = timePeriodLabel.split('-') + let label = timeFrameLabel.split('-') let label1 = label[0] let label2 = label[1].toUpperCase() let fontSize1 = 20