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.
|
|
|
using Binance.TradeRobot.Model.Base;
|
|
|
|
|
|
|
|
namespace Binance.TradeRobot.Model.Dto
|
|
|
|
{
|
|
|
|
public class UserResponse : Db.User
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// 累计盈亏
|
|
|
|
/// </summary>
|
|
|
|
public decimal CumulativeProfitAndLoss { get { return TotalAssets - CostAmount; } }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 本金比例
|
|
|
|
/// </summary>
|
|
|
|
public decimal CostRatio { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 分红比例
|
|
|
|
/// </summary>
|
|
|
|
public decimal DividendRatio { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 用户资金改变算法
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="capitalChangeType"></param>
|
|
|
|
/// <param name="changeAmount"></param>
|
|
|
|
/// <param name="isManualOperation">是否手动操作</param>
|
|
|
|
public void ChangeAmount(Enums.CapitalChangeType capitalChangeType, decimal changeAmount, bool isManualOperation)
|
|
|
|
{
|
|
|
|
if (capitalChangeType == Enums.CapitalChangeType.Add)
|
|
|
|
{
|
|
|
|
TotalAssets += changeAmount;
|
|
|
|
if (isManualOperation)
|
|
|
|
CostAmount += changeAmount;
|
|
|
|
}
|
|
|
|
else if (capitalChangeType == Enums.CapitalChangeType.Reduce)
|
|
|
|
{
|
|
|
|
var cumulativeProfitAndLoss = CumulativeProfitAndLoss;
|
|
|
|
TotalAssets -= changeAmount;
|
|
|
|
|
|
|
|
if (isManualOperation)
|
|
|
|
{
|
|
|
|
if (cumulativeProfitAndLoss < changeAmount)
|
|
|
|
CostAmount -= cumulativeProfitAndLoss > 0 ? changeAmount - cumulativeProfitAndLoss : changeAmount;
|
|
|
|
WithdrawAmount += changeAmount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|