import { Schema, model } from 'mongoose';

const tradeSchema = new Schema({
  userId: {
    type: Schema.Types.ObjectId,
    required: true,
    ref: 'User',
  },
  asset: {
    type: String,
    required: true,
  },
  tradeType: {
    type: String,
    enum: ['buy', 'sell'],
    required: true,
  },
  quantity: {
    type: Number,
    required: true,
  },
  price: {
    type: Number,
    required: true,
  },
  entryPoint: {
    type: Number,
  },
  exitPoint: {
    type: Number,
  },
  stopLoss: {
    type: Number,
  },
  takeProfit: {
    type: Number,
  },
  broker: {
    type: String,
  },
  accountType: {
    type: String,
  },
  strategyTags: [{
    type: String,
  }],
  notes: {
    type: String,
  },
  screenshots: [{
    type: String, // URLs to images
  }],
  tradeDate: {
    type: Date,
    default: Date.now,
  },
  status: {
    type: String,
    enum: ['completed', 'pending', 'canceled'],
    default: 'completed',
  },
});

export const Trade = model('Trade', tradeSchema);