币安量化交易
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.9 KiB

3 years ago
using Binance.TradeRobot.Model.Base;
namespace Binance.TradeRobot.Model.Dto
3 years ago
{
public class UserResponse : Db.User
3 years ago
{
/// <summary>
/// 总资产(本金+收益)
/// </summary>
public decimal TotalAssets { get { return CostAmount + Profit; } }
/// <summary>
/// 本金比例
/// </summary>
public decimal CostRatio { get; set; }
/// <summary>
/// 分红比例
/// </summary>
public decimal DividendRatio { get; set; }
3 years ago
/// <summary>
/// 用户资金改变算法
/// </summary>
/// <param name="capitalChangeType"></param>
/// <param name="changeAmount"></param>
/// <param name="priorityAddCost">true:优先增加本金 false:优先增加利润</param>
public void ChangeAmount(Enums.CapitalChangeType capitalChangeType, decimal changeAmount, bool priorityAddCost)
{
if (capitalChangeType == Enums.CapitalChangeType.Add)
{
if (priorityAddCost)
CostAmount += changeAmount;
else
Profit += changeAmount;
}
else if (capitalChangeType == Enums.CapitalChangeType.Reduce)
{
if (Profit > 0)
{
if (Profit >= changeAmount)
Profit -= changeAmount; //收益足够提现,只扣收益
else
{
var lessChangeAmount = changeAmount; //收益不足提现,先扣收益,不足部分再扣本金
lessChangeAmount -= Profit;
Profit = 0;
CostAmount -= lessChangeAmount;
}
}
else
{
CostAmount -= changeAmount;
}
}
}
3 years ago
}
}