using SqlSugar;
namespace AssetManager.Data;
///
/// 投资组合表
///
[SugarTable("portfolios")]
public class Portfolio
{
///
/// 主键
///
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
public string? Id { get; set; }
///
/// 所属用户ID
///
[SugarColumn(ColumnName = "user_id", IndexGroupNameList = new string[] { "idx_user_id" })]
public string? UserId { get; set; }
///
/// 所用策略ID
///
[SugarColumn(ColumnName = "strategy_id", IndexGroupNameList = new string[] { "idx_strategy_id" })]
public string? StrategyId { get; set; }
///
/// 组合名称
///
[SugarColumn(ColumnName = "name", Length = 200)]
public string? Name { get; set; }
///
/// 组合币种 (USD/CNY等)
///
[SugarColumn(ColumnName = "currency", Length = 10)]
public string? Currency { get; set; }
///
/// 当前总市值 (可冗余或实时计算)
///
[SugarColumn(ColumnName = "total_value", ColumnDataType = "decimal(18,4)")]
public decimal TotalValue { get; set; }
///
/// 累计收益率
///
[SugarColumn(ColumnName = "return_rate", ColumnDataType = "decimal(18,4)")]
public decimal ReturnRate { get; set; }
///
/// 运行状态 (运行中/监控中)
///
[SugarColumn(ColumnName = "status", Length = 50)]
public string? Status { get; set; }
///
/// 创建时间
///
[SugarColumn(ColumnName = "created_at")]
public DateTime CreatedAt { get; set; }
///
/// 更新时间
///
[SugarColumn(ColumnName = "updated_at")]
public DateTime UpdatedAt { get; set; }
}
///
/// 持仓明细表
///
[SugarTable("positions")]
public class Position
{
///
/// 主键
///
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
public string? Id { get; set; }
///
/// 所属组合ID
///
[SugarColumn(ColumnName = "portfolio_id", IndexGroupNameList = new string[] { "idx_portfolio_id" })]
public string? PortfolioId { get; set; }
///
/// 标的代码 (如: UPRO.US)
///
[SugarColumn(ColumnName = "stock_code", Length = 50)]
public string? StockCode { get; set; }
///
/// 标的名称
///
[SugarColumn(ColumnName = "stock_name", Length = 200)]
public string? StockName { get; set; }
///
/// 资产类型 (Stock/Crypto)
///
[SugarColumn(ColumnName = "asset_type", Length = 20)]
public string? AssetType { get; set; }
///
/// 持有数量
///
[SugarColumn(ColumnName = "shares", ColumnDataType = "decimal(18,8)")]
public decimal Shares { get; set; }
///
/// 持仓均价
///
[SugarColumn(ColumnName = "avg_price", ColumnDataType = "decimal(18,4)")]
public decimal AvgPrice { get; set; }
///
/// 标的币种
///
[SugarColumn(ColumnName = "currency", Length = 10)]
public string? Currency { get; set; }
///
/// 建仓时间
///
[SugarColumn(ColumnName = "created_at")]
public DateTime CreatedAt { get; set; }
///
/// 最后更新时间
///
[SugarColumn(ColumnName = "updated_at")]
public DateTime UpdatedAt { get; set; }
}
///
/// 交易流水表
///
[SugarTable("transactions")]
public class Transaction
{
///
/// 主键
///
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
public string? Id { get; set; }
///
/// 所属组合ID
///
[SugarColumn(ColumnName = "portfolio_id", IndexGroupNameList = new string[] { "idx_portfolio_id" })]
public string? PortfolioId { get; set; }
///
/// 交易类型 (buy/sell)
///
[SugarColumn(ColumnName = "type", Length = 20)]
public string? Type { get; set; }
///
/// 标的代码
///
[SugarColumn(ColumnName = "stock_code", Length = 50)]
public string? StockCode { get; set; }
///
/// 资产类型 (Stock/Crypto)
///
[SugarColumn(ColumnName = "asset_type", Length = 20)]
public string? AssetType { get; set; }
///
/// 交易标题 (如: 定期定投)
///
[SugarColumn(ColumnName = "title", Length = 200)]
public string? Title { get; set; }
///
/// 交易数量
///
[SugarColumn(ColumnName = "amount", ColumnDataType = "decimal(18,8)")]
public decimal Amount { get; set; }
///
/// 成交价格
///
[SugarColumn(ColumnName = "price", ColumnDataType = "decimal(18,4)")]
public decimal Price { get; set; }
///
/// 交易总金额
///
[SugarColumn(ColumnName = "total_amount", ColumnDataType = "decimal(18,4)")]
public decimal TotalAmount { get; set; }
///
/// 交易币种
///
[SugarColumn(ColumnName = "currency", Length = 10)]
public string? Currency { get; set; }
///
/// 交易状态 (processing/completed)
///
[SugarColumn(ColumnName = "status", Length = 50)]
public string? Status { get; set; }
///
/// 交易备注
///
[SugarColumn(ColumnName = "remark", Length = 500, IsNullable = true)]
public string? Remark { get; set; }
///
/// 交易发生时间
///
[SugarColumn(ColumnName = "transaction_time")]
public DateTime TransactionTime { get; set; }
///
/// 记录创建时间
///
[SugarColumn(ColumnName = "created_at")]
public DateTime CreatedAt { get; set; }
}