const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Symbol = sequelize.define('Symbol', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  symbol: {
    type: DataTypes.STRING(50),
    allowNull: false,
    unique: true
  },
  baseAsset: {
    type: DataTypes.STRING(50),
    field: 'base_asset'
  },
  quoteAsset: {
    type: DataTypes.STRING(50),
    field: 'quote_asset'
  },
  exchange: {
    type: DataTypes.STRING(50)
  },
  instrumentType: {
    type: DataTypes.ENUM('crypto', 'stock', 'forex', 'commodity'),
    field: 'instrument_type',
    allowNull: false
  },
  isActive: {
    type: DataTypes.BOOLEAN,
    field: 'is_active',
    defaultValue: true
  },
  createdAt: {
    type: DataTypes.DATE,
    field: 'created_at'
  },
  updatedAt: {
    type: DataTypes.DATE,
    field: 'updated_at'
  }
}, {
  tableName: 'symbols',
  indexes: [
    { fields: ['exchange'] },
    { fields: ['instrument_type'] }
  ]
});

module.exports = Symbol;
