diff --git a/src/models/Strategy.js b/src/models/Strategy.js index 504f94431..e0932ec67 100644 --- a/src/models/Strategy.js +++ b/src/models/Strategy.js @@ -9,6 +9,11 @@ const strategySchema = new Schema( dropDups: true, }, subStrategies: [{ + actif: { + type: Boolean, + required: true, + default: true, + }, name: { type: String, default: '', diff --git a/src/schema/types/Strategy.js b/src/schema/types/Strategy.js index 4a5be341d..8c9633146 100644 --- a/src/schema/types/Strategy.js +++ b/src/schema/types/Strategy.js @@ -2,6 +2,7 @@ import { GraphQLObjectType, GraphQLString, GraphQLList, + GraphQLBoolean, GraphQLID, } from 'graphql'; import { @@ -15,8 +16,12 @@ const Type = new GraphQLObjectType({ id: { type: GraphQLID }, fbSlug: { type: GraphQLString }, subStrategies: { + args: { actifOnly: { type: GraphQLBoolean } }, type: new GraphQLList(SubStrategyType), - resolve(parent) { + resolve(parent, { actifOnly }) { + if (actifOnly) { + return parent.subStrategies.filter(subStrategy => subStrategy.actif); + } return parent.subStrategies; }, }, diff --git a/src/schema/types/SubStrategy.js b/src/schema/types/SubStrategy.js index 4d6fe80d7..69b7ff20c 100644 --- a/src/schema/types/SubStrategy.js +++ b/src/schema/types/SubStrategy.js @@ -1,6 +1,7 @@ import { GraphQLObjectType, GraphQLString, + GraphQLBoolean, } from 'graphql'; import { EntryPointType, @@ -16,6 +17,7 @@ const Type = new GraphQLObjectType({ name: 'SubStrategy', description: 'SubStrategy composing a strategy', fields: () => ({ + actif: { type: GraphQLBoolean }, name: { type: GraphQLString }, entryPoint: { type: EntryPointType, diff --git a/src/schema/types/input/SubStrategy.js b/src/schema/types/input/SubStrategy.js index d55203ea8..737aa532b 100644 --- a/src/schema/types/input/SubStrategy.js +++ b/src/schema/types/input/SubStrategy.js @@ -1,5 +1,6 @@ import { GraphQLString, + GraphQLBoolean, GraphQLInputObjectType, } from 'graphql'; import { @@ -16,6 +17,7 @@ const Type = new GraphQLInputObjectType({ name: 'SubStrategyInput', description: 'Payload for subStrategy input', fields: () => ({ + actif: { type: GraphQLBoolean }, name: { type: GraphQLString }, entryPoint: { type: EntryPointInputType }, exitPoint: { type: ExitPointInputType }, diff --git a/src/templates/strategyTemplate.js b/src/templates/strategyTemplate.js index cbdf50876..7af2abcde 100644 --- a/src/templates/strategyTemplate.js +++ b/src/templates/strategyTemplate.js @@ -2,6 +2,7 @@ const strategy = { subStrategies: [ { + actif: true, name: 'Trend Following', entryPoint: { situations: [ @@ -180,6 +181,7 @@ const strategy = { }, }, { + actif: true, name: 'Range Trading', entryPoint: { situations: [ @@ -253,6 +255,7 @@ const strategy = { }, }, { + actif: true, name: 'LRC Strategy', entryPoint: { situations: [