18 lines
577 B
C#
18 lines
577 B
C#
namespace KLHZ.Trader.Core.Exchange.Utils
|
|
{
|
|
internal static class TradingCalculator
|
|
{
|
|
public static decimal CaclProfit(decimal openPrice, decimal closePrice, decimal comission, decimal leverage, bool isShort)
|
|
{
|
|
var summComission = closePrice * comission + openPrice * comission;
|
|
var priceDiff = closePrice - openPrice;
|
|
if (isShort)
|
|
{
|
|
priceDiff *= -1;
|
|
}
|
|
var diff = priceDiff * leverage - summComission;
|
|
return diff;
|
|
}
|
|
}
|
|
}
|