diff --git a/src/models/event.js b/src/models/event.js deleted file mode 100644 index b0337b374..000000000 --- a/src/models/event.js +++ /dev/null @@ -1,60 +0,0 @@ -import mongoose, { Schema } from 'mongoose'; -import Plotter from './plotter'; -import Formula from './formula'; -import { - UNPUBLISHED, - EventStateEnum, -} from '../enums/EventState'; - -const { ObjectId } = Schema.Types; - -const eventSchema = new Schema({ - state: { - type: String, - enum: EventStateEnum, - default: UNPUBLISHED, - }, - name: { - type: String, - required: true, - }, - hostId: { - type: String, - required: true, - }, - formulaId: { - type: ObjectId, - ref: Formula.modelName, - }, - plotterId: { - type: ObjectId, - ref: Plotter.modelName, - }, - prizes: [{ - rank: { - type: String, - required: true, - }, - subPrize: [{ - condition: String, - }], - }], -}); - -eventSchema.pre('find', function populate() { - this.populate('formulaId').populate('plotterId'); -}); -eventSchema.post('save', (doc, next) => { - doc.populate('formulaId').populate('plotterId').execPopulate().then(() => { - next(); - }); -}); -eventSchema.post('findOneAndUpdate', (doc, next) => { - doc.populate('formulaId').populate('plotterId').execPopulate().then(() => { - next(); - }); -}); - -const Event = mongoose.model('Event', eventSchema); - -export default Event; diff --git a/src/models/formula.js b/src/models/formula.js deleted file mode 100644 index f65d67926..000000000 --- a/src/models/formula.js +++ /dev/null @@ -1,12 +0,0 @@ -import mongoose, { Schema } from 'mongoose'; - -const formulaSchema = new Schema({ - name: { - type: String, - required: true, - }, -}); - -const Formula = mongoose.model('Formula', formulaSchema); - -export default Formula; diff --git a/src/models/index.js b/src/models/index.js index 251eda8ea..4c02fc165 100644 --- a/src/models/index.js +++ b/src/models/index.js @@ -1,9 +1,6 @@ -import Plotter from './plotter'; -import Event from './event'; -import Formula from './formula'; +/* eslint-disable import/prefer-default-export */ +import Strategy from './strategy'; export { - Event, - Plotter, - Formula, + Strategy, }; diff --git a/src/models/plotter.js b/src/models/plotter.js deleted file mode 100644 index 9f89e9a70..000000000 --- a/src/models/plotter.js +++ /dev/null @@ -1,12 +0,0 @@ -import mongoose, { Schema } from 'mongoose'; - -const plotterSchema = new Schema({ - name: { - type: String, - required: true, - }, -}); - -const Plotter = mongoose.model('Plotter', plotterSchema); - -export default Plotter; diff --git a/src/models/strategy.js b/src/models/strategy.js new file mode 100644 index 000000000..fa09a6916 --- /dev/null +++ b/src/models/strategy.js @@ -0,0 +1,174 @@ +import mongoose, { Schema } from 'mongoose'; + +const strategySchema = new Schema({ + fbId: { + type: String, + required: true, + }, + strategies: [{ + 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', + }, + }], + }], + }], + }, + }], +}); + +const Strategy = mongoose.model('Strategy', strategySchema); + +export default Strategy;