diff --git a/client/package.json b/client/package.json index a6356f216..a79bd9079 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@superalgos/operations-client", - "version": "0.0.30", + "version": "0.0.31", "description": "Superalgos Operations client-side web app", "main": "src/index.js", "dependencies": { diff --git a/client/src/GraphQL/models.js b/client/src/GraphQL/models.js index 022fb3ada..997c57bc1 100644 --- a/client/src/GraphQL/models.js +++ b/client/src/GraphQL/models.js @@ -38,7 +38,6 @@ const sensorProcessNames = { } const indicatorProcessNames = { - Single: 'Single-Period-Daily', Daily: 'Multi-Period-Daily', Market: 'Multi-Period-Market' } diff --git a/client/src/views/Clone/Add/index.js b/client/src/views/Clone/Add/index.js index c8448728a..013b752f9 100644 --- a/client/src/views/Clone/Add/index.js +++ b/client/src/views/Clone/Add/index.js @@ -28,8 +28,8 @@ class AddClone extends Component { this.state = { user: JSON.parse(user), selectedBot: { 'id': '' }, - mode: '', - resumeExecution: true, + mode: "noTime", + resumeExecution: false, beginDatetime: DateTime.local().minus({ days: 8 }).startOf('day'), endDatetime: DateTime.local(), waitTime: 1, @@ -41,7 +41,7 @@ class AddClone extends Component { teamId: '', keyId: '', exchangeName: exchanges.Coss, - processName: '', + processName: indicatorProcessNames.Daily, // Indicator Bot startYear: 2019, @@ -267,9 +267,9 @@ class AddClone extends Component { ); if (error) return `Error! ${error.message}`; const list = data.keyVault_AvailableKeys.map((key) => ( - - {key.key.substr(0, 32) + "..." + " - " + key.exchange} - + + {key.key.substr(0, 32) + "..." + " - " + key.exchange} + )); return ( } - {(this.state.selectedBot.kind === botTypes.Indicator - || this.state.selectedBot.kind === botTypes.Sensor) && - - this.setState({ mode: e.target.value })} - onBlur={(e) => this.setState({ modeError: false })} - error={this.state.modeError} - fullWidth - > - {Object.keys(indicatorStartModes).map(option => ( - - {indicatorStartModes[option]} - - ))} - - - {this.state.mode === "allMonths" && - - this.setState({ startYear: e.target.value })} - fullWidth - > - {getIndicatorYears().map(option => ( - - {option} - - ))} - - - this.setState({ endYear: e.target.value })} - fullWidth - > - {getIndicatorYears().map(option => ( - - {option} - - ))} - - - } - - {this.state.mode === "oneMonth" && - - this.setState({ startYear: e.target.value })} - fullWidth - > - {getIndicatorYears().map(option => ( - - {option} - - ))} - - - this.setState({ month: e.target.value })} - fullWidth - > - {availableMonths.map((option, index) => ( - - {option} - - ))} - - - } - - } - - - {(this.state.mode === "noTime" && this.state.selectedBot.kind !== botTypes.Sensor ) && + {(this.state.mode === "noTime" && this.state.selectedBot.kind !== botTypes.Sensor) && The Resume Execution option let's you pick up the context of @@ -612,8 +518,8 @@ class AddClone extends Component { if (!this.state.serverError) this.setState({ selectedBot: { 'id': '' }, - mode: '', - resumeExecution: true, + mode: 'noTime', + resumeExecution: false, beginDatetime: DateTime.local().minus({ days: 8 }).startOf('day'), endDatetime: DateTime.local(), waitTime: 1, @@ -621,11 +527,20 @@ class AddClone extends Component { stateDatetime: 0, createDatetime: 0, runAsTeam: false, - processName: '', + exchangeName: exchanges.Coss, + processName: indicatorProcessNames.Daily, teams: [], teamId: '', keyId: '', + // Indicator Bot + startYear: 2019, + endYear: 2019, + month: 1, + + //TradingBot + timePeriod: '01-hs', + //Error handlers nameError: false, teamError: false, diff --git a/server/src/schema/mutations/AddCloneMutation.js b/server/src/schema/mutations/AddCloneMutation.js index 549f9651f..5f72a3739 100644 --- a/server/src/schema/mutations/AddCloneMutation.js +++ b/server/src/schema/mutations/AddCloneMutation.js @@ -40,13 +40,25 @@ const resolve = async (parent, { clone }, context) => { throw new WrongArgumentsError('The key was not provided to run the clone.') } - try { - let allUserBotsResponse = await teamQuery(context.authorization, clone.botId) - let bot = allUserBotsResponse.data.data.teams_FbByOwner.edges[0].node - clone = cloneDetails(bot, clone) - clone.createDatetime = new Date().valueOf() / 1000 | 0 - clone.active = true + let allUserBotsResponse = await teamQuery(context.authorization, clone.botId) + let bot = allUserBotsResponse.data.data.teams_FbByOwner.edges[0].node + clone = cloneDetails(bot, clone) + clone.createDatetime = new Date().valueOf() / 1000 | 0 + clone.active = true + // TODO Temporary Limitation on bot creation + if (!(clone.teamSlug === "AAMasters" || clone.teamSlug === "AAVikings")) { + let clones = await Clone.find({ + authId: context.userId, + active: true + }) + + if (clones !== undefined && clones.length >= 5) { + throw new Error('Currently maximum number of clones per user is 5. You can delete an existing clone and try again.') + } + } + + try { let newClone = new Clone(clone) newClone.authId = context.userId clone.id = newClone._id