Adding history to strategies, not showing them up yet though
This commit is contained in:
1 parent
e36afab3a6
commit
4f1802e4ee
2 files changed
+293
-119
No files matched your search
+289
-119
@@ -1,99 +1,19 @@
|
||||
import mongoose, { Schema } from 'mongoose';
|
||||
|
||||
const strategySchema = new Schema({
|
||||
fbId: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
dropDups: true,
|
||||
},
|
||||
subStrategies: [{
|
||||
name: {
|
||||
const strategySchema = new Schema(
|
||||
{
|
||||
fbId: {
|
||||
type: String,
|
||||
default: '',
|
||||
required: true,
|
||||
unique: true,
|
||||
dropDups: true,
|
||||
},
|
||||
entryPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
exitPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
sellPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
stopLoss: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
subStrategies: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
entryPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
@@ -110,18 +30,8 @@ const strategySchema = new Schema({
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
},
|
||||
exitPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
@@ -138,18 +48,8 @@ const strategySchema = new Schema({
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
sellOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
},
|
||||
sellPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
@@ -166,10 +66,280 @@ const strategySchema = new Schema({
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
stopLoss: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
sellOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
}],
|
||||
history: [{
|
||||
updatedAt: Date,
|
||||
subStrategies: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
entryPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
exitPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
sellPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
stopLoss: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
sellOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
}],
|
||||
},
|
||||
}],
|
||||
});
|
||||
}],
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
},
|
||||
);
|
||||
|
||||
const Strategy = mongoose.model('Strategy', strategySchema);
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ const resolve = (parent, { id: _id, strategy: editedStrategy }) => new Promise((
|
||||
rej(err);
|
||||
return;
|
||||
}
|
||||
strategy.history.push({
|
||||
updatedAt: strategy.updatedAt,
|
||||
subStrategies: strategy.subStrategies,
|
||||
});
|
||||
strategy.subStrategies = editedStrategy.subStrategies;
|
||||
strategy.save((error) => {
|
||||
if (error) {
|
||||
|
||||
Reference in new issue
Block a user