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 technical_indicators = sequelize.define(
    'technical_indicators',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

calculated_at: {
        type: DataTypes.DATE,
      
      

      },

indicator_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"rsi",


"macd",


"bollinger_bands",


"sma",


"ema",


"volume"

        ],

      },

timeframe: {
        type: DataTypes.ENUM,
      
      

        values: [

"1min",


"5min",


"15min",


"30min",


"60min",


"daily",


"weekly",


"monthly"

        ],

      },

period: {
        type: DataTypes.INTEGER,
      
      

      },

value: {
        type: DataTypes.DECIMAL,
      
      

      },

signal: {
        type: DataTypes.DECIMAL,
      
      

      },

histogram: {
        type: DataTypes.DECIMAL,
      
      

      },

upper_band: {
        type: DataTypes.DECIMAL,
      
      

      },

middle_band: {
        type: DataTypes.DECIMAL,
      
      

      },

lower_band: {
        type: DataTypes.DECIMAL,
      
      

      },

source: {
        type: DataTypes.TEXT,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  technical_indicators.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity





































//end loop



    db.technical_indicators.belongsTo(db.market_symbols, {
      as: 'market_symbol',
      foreignKey: {
        name: 'market_symbolId',
      },
      constraints: false,
    });




    db.technical_indicators.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.technical_indicators.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return technical_indicators;
};


