Adding toggleable strategy state

This commit is contained in:
Unknown committed 2019-03-25 09:55:51 +01:00
1 parent 2ceca44635
commit 5f66847dba
5 files changed
+18 -1

No files matched your search

+5
View File
@@ -9,6 +9,11 @@ const strategySchema = new Schema(
dropDups: true,
},
subStrategies: [{
actif: {
type: Boolean,
required: true,
default: true,
},
name: {
type: String,
default: '',
+6 -1
View File
@@ -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;
},
},
+2
View File
@@ -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,
+2
View File
@@ -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 },
+3
View File
@@ -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: [