Superalgos node v1

This commit is contained in:
Matias committed 2019-06-22 19:23:46 -03:00
1 parent 8cbe7631ce
commit 5193cf891b
7 files changed
+56 -51

No files matched your search

+4
View File
@@ -5,9 +5,13 @@ import schema from './schema';
import wrongPreshared from './errors/notAllowed.json';
import db from './db';
import logger from './utils/logger'
import bodyParser from 'body-parser'
const app = express();
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
app.post('/graphql', (req, res, next) => {
if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) {
next();
+12 -12
View File
@@ -5,10 +5,10 @@
"codeName": "AAMasters",
"displayName": "Masters",
"host": {
"url": "https://platform-api-dev.superalgos.org/",
"storage": "https://aadevelop.blob.core.windows.net",
"url": "https://demo-api-dev.superalgos.org/",
"storage": "localStorage",
"container": "aamasters",
"accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D"
"accessKey": ""
},
"bots": [
{
@@ -725,10 +725,10 @@
"codeName": "AAVikings",
"displayName": "Vikings",
"host": {
"url": "https://platform-api-dev.superalgos.org/",
"url": "https://demo-api-dev.superalgos.org/",
"container": "aavikings",
"storage": "https://aadevelop.blob.core.windows.net",
"accessKey": "?st=2019-05-20T12%3A00%3A00Z&se=2020-05-21T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=hJuV9aEP4KVZo5z54FEF1BQtkbksfwkTJFv1FYkHFRg%3D"
"storage": "localStorage",
"accessKey": ""
},
"bots": [
{
@@ -832,10 +832,10 @@
"codeName": "AAMasters",
"displayName": "AA Arena",
"host": {
"url": "https://platform-api-dev.superalgos.org/",
"storage": "https://aadevelop.blob.core.windows.net",
"url": "https://demo-api-dev.superalgos.org/",
"storage": "localStorage",
"container": "aaplatform",
"accessKey": "?sv=2018-03-28&ss=b&srt=co&sp=rw&se=2020-01-04T00:00:00Z&st=2019-01-08T11:25:04Z&spr=https&sig=xZU1PO%2BdtVilqlZp%2BVRWW55LYl8oGZU7x4JnP%2BhMc%2FY%3D"
"accessKey": ""
},
"competitions": [
{
@@ -849,10 +849,10 @@
"devTeam": "AAMasters",
"codeName": "PlottersROI",
"host": {
"url": "https://platform-api-dev.superalgos.org/",
"storage": "https://aadevelop.blob.core.windows.net",
"url": "https://demo-api-dev.superalgos.org/",
"storage": "localStorage",
"container": "aamasters",
"accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D"
"accessKey": ""
},
"moduleName": "CombinedProfits",
"repo": "Plotters-ROI"
+22 -15
View File
@@ -1,6 +1,8 @@
import logger from '../../utils/logger'
import { FileInputType } from '../types/input'
import { GraphQLString } from 'graphql'
import { getFileContent } from '../../storage/providers/MinioStorage'
import { getFileContentRemote } from '../../storage/providers/AzureStorage'
export const args = { file: { type: FileInputType } }
@@ -9,28 +11,33 @@ const resolve = async (parent, { file }, context) => {
try {
// TODO Temporary fix for plotter and plotter pannels
if (file.storage === '' && file.accessKey === '') {
let defaultEcosystem = require('../../config/ecosystem.json')
for (let index = 0; index < defaultEcosystem.devTeams.length; index++) {
const devTeam = defaultEcosystem.devTeams[index];
if (devTeam.codeName.toLowerCase() === file.container) {
file.storage = devTeam.host.storage
file.accessKey = devTeam.host.accessKey
let fileContent
if (file.storage === '' || file.storage === undefined) {
//TODO Add permissions
fileContent = await getFileContent(file.container, file.filePath)
} else {
// TODO Temporary fix for plotter and plotter pannels
if (file.storage === '' && file.accessKey === '') {
let defaultEcosystem = require('../../config/ecosystem.json')
for (let index = 0; index < defaultEcosystem.devTeams.length; index++) {
const devTeam = defaultEcosystem.devTeams[index];
if (devTeam.codeName.toLowerCase() === file.container) {
file.storage = devTeam.host.storage
file.accessKey = devTeam.host.accessKey
}
}
}
if (file.storage === '' || file.accessKey === '') {
throw "Wrong parameters."
}
fileContent = await getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey)
}
if (file.storage === '' || file.accessKey === '') {
throw "Wrong parameters."
}
let storage = require('../../storage/providers/AzureStorage')
let fileContent = await storage.getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey)
return fileContent
} catch (err) {
logger.error('getPlotterCode -> Error: %s', err.stack)
logger.error('getPlotterCode -> Error: %s', err)
logger.error('getPlotterCode -> Stack: %s', err.stack)
throw err
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ const Type = new GraphQLInputObjectType({
container: { type: new GraphQLNonNull(GraphQLString) },
filePath: { type: new GraphQLNonNull(GraphQLString) },
storage: { type: new GraphQLNonNull(GraphQLString) },
accessKey: { type: new GraphQLNonNull(GraphQLString) },
accessKey: { type: GraphQLString },
fileContent: { type: GraphQLString }
}),
});
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -19,9 +19,6 @@
let utilities = UTILITIES.newCloudUtilities(bot, logger);
const FILE_STORAGE = require('./Integrations/FileStorage.js');
let botStorage = FILE_STORAGE.newFileStorage();
let dataDependencies;
return thisObject;
@@ -113,7 +110,7 @@
function writeFiles(pTradingSystem) {
tradingSystem = pTradingSystem
writeRecordsFile()
writeRecordsFile()
}
function writeRecordsFile() {
@@ -168,7 +165,7 @@
record.maximunBalanceA + "," +
record.initialBalanceB + "," +
record.minimunBalanceB + "," +
record.maximunBalanceB + "]";
record.maximunBalanceB + "]";
if (separator === "") { separator = ","; }
@@ -185,7 +182,7 @@
let filePath = filePathRoot + "/Output/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -273,7 +270,7 @@
let filePath = filePathRoot + "/Output/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -350,7 +347,7 @@
let filePath = filePathRoot + "/Output/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -430,7 +427,7 @@
let filePath = filePathRoot + "/Output/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -17,9 +17,6 @@
start: start
};
const FILE_STORAGE = require('./Integrations/FileStorage.js');
let botStorage = FILE_STORAGE.newFileStorage();
let dataDependencies;
return thisObject;
@@ -164,8 +161,8 @@
record.maximunBalanceA + "," +
record.initialBalanceB + "," +
record.minimunBalanceB + "," +
record.maximunBalanceB + "]";
record.maximunBalanceB + "]";
if (separator === "") { separator = ","; }
fileRecordCounter++;
@@ -180,7 +177,7 @@
let filePath = filePathRoot + "/Output/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -258,7 +255,7 @@
let filePath = filePathRoot + "/Output/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -328,7 +325,7 @@
let filePath = filePathRoot + "/Output/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -401,7 +398,7 @@
let filePath = filePathRoot + "/Output/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel;
filePath += '/' + fileName
botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -232,10 +232,10 @@
"devTeam": "AAMasters",
"bot": "AABruce",
"host": {
"url": "http://localhost:4100/",
"storage": "https://aadevelop.blob.core.windows.net",
"url": "https://demo-dev.superalgos.org/",
"storage": "localStorage",
"container": "aamasters",
"accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D"
"accessKey": ""
},
"botVersion": {
"major": 1,