using SqlSugar;
namespace AssetManager.Data;
///
/// 持仓明细表
///
[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 = "total_cost", ColumnDataType = "decimal(18,4)")]
public decimal TotalCost { 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; }
}