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