- 修改ApiResponse、RiskParityConfig等DTO类的属性为可空类型 - 在策略计算器中添加空值检查逻辑 - 更新服务层代码处理可能的空值情况 - 添加发布配置文件FolderProfile.pubxml
229 lines
6.1 KiB
C#
229 lines
6.1 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", IndexGroupNameList = new string[] { "idx_user_id" })]
|
|
public string? UserId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 所用策略ID
|
|
/// </summary>
|
|
[SugarColumn(ColumnName = "strategy_id", IndexGroupNameList = new string[] { "idx_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", IndexGroupNameList = new string[] { "idx_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>
|
|
/// 资产类型 (Stock/Crypto)
|
|
/// </summary>
|
|
[SugarColumn(ColumnName = "asset_type", Length = 20)]
|
|
public string? AssetType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 持有数量
|
|
/// </summary>
|
|
[SugarColumn(ColumnName = "shares", ColumnDataType = "decimal(18,8)")]
|
|
public decimal 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", IndexGroupNameList = new string[] { "idx_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>
|
|
/// 资产类型 (Stock/Crypto)
|
|
/// </summary>
|
|
[SugarColumn(ColumnName = "asset_type", Length = 20)]
|
|
public string? AssetType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 交易标题 (如: 定期定投)
|
|
/// </summary>
|
|
[SugarColumn(ColumnName = "title", Length = 200)]
|
|
public string? Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// 交易数量
|
|
/// </summary>
|
|
[SugarColumn(ColumnName = "amount", ColumnDataType = "decimal(18,8)")]
|
|
public decimal 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; }
|
|
}
|