236 lines
3.2 KiB
JavaScript
236 lines
3.2 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const model_configurations = sequelize.define(
|
|
'model_configurations',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
name: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
regime_method: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"digitized_returns"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
garch_omega: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
garch_alpha: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
garch_beta: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
simulation_steps: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
n_paths: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
base_lambda_jump: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
vol_sensitivity: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
jump_sensitivity: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
use_volume_factor: {
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"active",
|
|
|
|
|
|
"inactive"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
notes: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
model_configurations.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.model_configurations.hasMany(db.risk_runs, {
|
|
as: 'risk_runs_model_configuration',
|
|
foreignKey: {
|
|
name: 'model_configurationId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
db.model_configurations.hasMany(db.scenario_analyses, {
|
|
as: 'scenario_analyses_model_configuration',
|
|
foreignKey: {
|
|
name: 'model_configurationId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
db.model_configurations.hasMany(db.backtest_jobs, {
|
|
as: 'backtest_jobs_model_configuration',
|
|
foreignKey: {
|
|
name: 'model_configurationId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.model_configurations.belongsTo(db.assets, {
|
|
as: 'asset',
|
|
foreignKey: {
|
|
name: 'assetId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.model_configurations.belongsTo(db.sentiment_models, {
|
|
as: 'sentiment_model',
|
|
foreignKey: {
|
|
name: 'sentiment_modelId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.model_configurations.belongsTo(db.organizations, {
|
|
as: 'organizations',
|
|
foreignKey: {
|
|
name: 'organizationsId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.model_configurations.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.model_configurations.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return model_configurations;
|
|
};
|
|
|
|
|