const {DataTypes} = require("sequelize")
module.exports = (sequelize) => {
  return sequelize.define(
    "MarketTicker",
    {
      market_id: { type: DataTypes.BIGINT.UNSIGNED, primaryKey: true },

      last_price: { type: DataTypes.DECIMAL(30, 12), allowNull: false, defaultValue: 0 },

      bid: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      ask: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      spread: { type: DataTypes.DECIMAL(30, 12), allowNull: true },

      high_24h: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      low_24h: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      volume_24h: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      change_24h: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      change_pct_24h: { type: DataTypes.DECIMAL(18, 8), allowNull: true },

      mark_price: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      index_price: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
      open_interest: { type: DataTypes.DECIMAL(30, 12), allowNull: true },
    },
    {
      tableName: "market_tickers",
      underscored: true,
      timestamps: true,
    }
  );
};