diff --git a/AABrowserAPI/CopySimulator.js b/AABrowserAPI/CopySimulator.js index 29097c067..6479cf136 100644 --- a/AABrowserAPI/CopySimulator.js +++ b/AABrowserAPI/CopySimulator.js @@ -1,13 +1,4 @@ - -// let financialBeingsCopy = newFinancialBeingClone() - -// const simulatorTemplatePath = "aaplatform/AATemplate/bots/AAJason-Indicator-Bot1"; -// const blobName = "this.bot.config.json"; - -// financialBeingsCopy.copySimulator("team-a", "team a", "matias", "bot-a", "bot a") -// async function copySimulator(pTeamCodeName, pTeamDisplayName, pUserName, pBotCodeName, pBotDisplayName, pUserId) { - -const { +const { Aborter, BlobURL, BlockBlobURL, @@ -66,31 +57,36 @@ exports.newCopySimulator = function newCopySimulator() { let codeMarket = await getFileContent(templatePath + "/Multi-Period-Market", "User.Bot.js") // Change config to adapt the new indicator + let botCodeName = "simulator-" + pBotCodeName let parsedConfig = JSON.parse(config) - parsedConfig.displayName = "Simulator " + pBotDisplayName; - parsedConfig.codeName = "simulator-" + pBotCodeName; - parsedConfig.devTeam = pTeamCodeName; - parsedConfig.profilePicture = pBotCodeName + ".png"; + parsedConfig.displayName = "Simulator " + pBotDisplayName + parsedConfig.codeName = botCodeName + parsedConfig.devTeam = pTeamCodeName + parsedConfig.profilePicture = pBotCodeName + ".png" - for (let i = 0; i < parsedConfig.processes[0].statusDependencies.length; i++) { - - if (parsedConfig.processes[0].statusDependencies[i].devTeam === "AAMasters" && - parsedConfig.processes[0].statusDependencies[i].bot === "AAJason") { - - parsedConfig.processes[0].statusDependencies[i].devTeam = parsedConfig.devTeam; - parsedConfig.processes[0].statusDependencies[i].bot = parsedConfig.codeName; - } + let statusDependencyMarket = { + devTeam: pTeamCodeName, + bot: botCodeName, + botVersion: { + "major": 1, + "minor": 0 + }, + process: "Multi-Period-Market", + dataSetVersion: "dataSet.V1" } + parsedConfig.processes[0].statusDependencies.push(statusDependencyMarket) - for (let i = 0; i < parsedConfig.processes[1].statusDependencies.length; i++) { - - if (parsedConfig.processes[1].statusDependencies[i].devTeam === "AAMasters" && - parsedConfig.processes[1].statusDependencies[i].bot === "AAJason") { - - parsedConfig.processes[1].statusDependencies[i].devTeam = parsedConfig.devTeam; - parsedConfig.processes[1].statusDependencies[i].bot = parsedConfig.codeName; - } + let statusDependencyDaily = { + devTeam: pTeamCodeName, + bot: botCodeName, + botVersion: { + "major": 1, + "minor": 0 + }, + process: "Multi-Period-Daily", + dataSetVersion: "dataSet.V1" } + parsedConfig.processes[1].statusDependencies.push(statusDependencyDaily) //Changing Indicator Output parsedConfig.products[0].storageAccount = pTeamCodeName @@ -104,8 +100,8 @@ exports.newCopySimulator = function newCopySimulator() { parsedConfig.products[1].dataSets[1].dataRange.filePath = pTeamCodeName + "/" + parsedConfig.codeName + ".1.0/AACloud.1.1/@Exchange/dataSet.V1/Output/Simulation-Conditions/Multi-Period-Daily" // Write the new files - let newSimulatorName = "simulator-"+ pBotCodeName + "-Indicator-Bot" - let newSimulatorPath = "aaplatform/"+ pTeamCodeName + "/bots/" + newSimulatorName + let newSimulatorName = "simulator-" + pBotCodeName + "-Indicator-Bot" + let newSimulatorPath = "aaplatform/" + pTeamCodeName + "/bots/" + newSimulatorName await writeFileContent(newSimulatorPath, "Commons.js", commons) await writeFileContent(newSimulatorPath, "this.bot.config.json", beautify(parsedConfig, null, 2, 80)) await writeFileContent(newSimulatorPath + "/Multi-Period-Daily", "User.Bot.js", codeDaily) @@ -125,7 +121,7 @@ exports.newCopySimulator = function newCopySimulator() { // Delete simulator code let newSimulatorName = "simulator-" + pBotCodeName + "-Indicator-Bot" - let newSimulatorPath = "aaplatform/"+ pTeamCodeName + "/bots/" + newSimulatorName + let newSimulatorPath = "aaplatform/" + pTeamCodeName + "/bots/" + newSimulatorName await deleteBlob(newSimulatorPath, "Commons.js") await deleteBlob(newSimulatorPath, "this.bot.config.json") await deleteBlob(newSimulatorPath + "/Multi-Period-Daily", "User.Bot.js") @@ -158,7 +154,7 @@ exports.newCopySimulator = function newCopySimulator() { } async function deleteBlob(containerName, blobName) { - try{ + try { const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName) const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName) await blockBlobURL.delete(Aborter.none) @@ -167,11 +163,6 @@ exports.newCopySimulator = function newCopySimulator() { } } - async function deleteContainer(containerName) { - const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName) - let containerRemoveResponse = await containerURL.delete(Aborter.none) - } - // A helper method used to read a Node.js readable stream into string async function streamToString(readableStream) { return new Promise((resolve, reject) => { diff --git a/AABrowserAPI/TeamSetup.js b/AABrowserAPI/TeamSetup.js index c13b035b3..5fcd5485b 100644 --- a/AABrowserAPI/TeamSetup.js +++ b/AABrowserAPI/TeamSetup.js @@ -204,26 +204,62 @@ botConfig.processes[0].statusDependencies[i].devTeam = pTeamCodeName; botConfig.processes[0].statusDependencies[i].bot = pBotCodeName; } - - // Add a copy of the simulator indicator in the configuration - if ( botConfig.processes[0].statusDependencies[i].devTeam === "AAMasters" && - botConfig.processes[0].statusDependencies[i].bot === "AAJason" ) { - - botConfig.processes[0].statusDependencies[i].devTeam = pTeamCodeName; - botConfig.processes[0].statusDependencies[i].bot = "simulator-" + pBotCodeName; - } } - for (let i = 0; i < botConfig.processes[0].dataDependencies.length; i++) { + // Add simulator dependency + let simulatorBotCodeName = "simulator-" + pBotCodeName - // Add a copy of the simulator indicator in the configuration - if ( botConfig.processes[0].dataDependencies[i].devTeam === "AAMasters" && - botConfig.processes[0].dataDependencies[i].bot === "AAJason" ) { - - botConfig.processes[0].dataDependencies[i].devTeam = pTeamCodeName; - botConfig.processes[0].dataDependencies[i].bot = "simulator-" + pBotCodeName; - } + let statusDependencyMarket = { + devTeam: pTeamCodeName, + bot: simulatorBotCodeName, + botVersion: { + "major": 1, + "minor": 0 + }, + process: "Multi-Period-Market", + dataSetVersion: "dataSet.V1", + type: "Indicator" } + botConfig.processes[0].statusDependencies.push(statusDependencyMarket) + + let statusDependencyDaily = { + devTeam: pTeamCodeName, + bot: simulatorBotCodeName, + botVersion: { + "major": 1, + "minor": 0 + }, + process: "Multi-Period-Daily", + dataSetVersion: "dataSet.V1", + type: "Indicator" + } + botConfig.processes[0].statusDependencies.push(statusDependencyDaily) + + let dataDependencyMarket = { + devTeam: pTeamCodeName, + bot: simulatorBotCodeName, + botVersion: { + "major": 1, + "minor": 0 + }, + product: "Trading-Simulation", + dataSetVersion: "dataSet.V1", + dataSet: "Multi-Period-Market" + } + botConfig.processes[0].dataDependencies.push(dataDependencyMarket) + + let dataDependencyDaily = { + devTeam: pTeamCodeName, + bot: simulatorBotCodeName, + botVersion: { + "major": 1, + "minor": 0 + }, + product: "Trading-Simulation", + dataSetVersion: "dataSet.V1", + dataSet: "Multi-Period-Daily" + } + botConfig.processes[0].dataDependencies.push(dataDependencyDaily) botConfig.displayName = pBotDisplayName; botConfig.codeName = pBotCodeName;