zoukankan      html  css  js  c++  java
  • 期货结算 期货算法公式

            #region 公式算法
            /// <summary>
            /// 可用资金公式 [权益-保证金]
            /// </summary>
            /// <param name="balance">权益</param>
            /// <param name="currmargin">保证金</param>
            /// <returns></returns>
            private decimal AvailableExpression(decimal balance, decimal currmargin) {
                return balance - currmargin;
            }
    
            /// <summary>
            /// 权益公式 [昨权益+入金-出金+平仓盈亏+持仓盈亏-手续费-交割手续费]
            /// </summary>
            /// <param name="prebalance">昨权益</param>
            /// <param name="deposit">入金</param>
            /// <param name="withdraw">出金</param>
            /// <param name="closeprofit">平仓盈亏</param>
            /// <param name="positionprofit">持仓盈亏</param>
            /// <param name="commission">手续费</param>
            /// <param name="deliverycommission">交割手续费</param>
            /// <returns></returns>
            private decimal BalanceExpression(decimal prebalance, decimal deposit, decimal withdraw, decimal closeprofit, decimal positionprofit, decimal commission, decimal deliverycommission) {
                return prebalance + deposit - withdraw + closeprofit + positionprofit - commission - deliverycommission;
            }
    
            /// <summary>
            /// 手续费公式 [(手数*按手数手续费率)+(手数*成交价*合约乘数*按金额手续费率)]
            /// </summary>
            /// <param name="volume">手数</param>
            /// <param name="tradeprice">成交价</param>
            /// <param name="volumemultiple">合约乘数</param>
            /// <param name="ratiobyvolume">按手数手续费率</param>
            /// <param name="ratiobymoney">按金额手续费率</param>
            /// <returns></returns>
            private decimal CommissionExpression(int volume, decimal tradeprice, int volumemultiple, decimal ratiobyvolume, decimal ratiobymoney) {
                return (volume * ratiobyvolume) + (volume * tradeprice * volumemultiple * ratiobymoney);
            }
    
            /// <summary>
            /// 平仓盈亏公式 [(成交价-开仓价或昨结算价)*手数*合约乘数]
            /// </summary>
            /// <param name="direction">买卖方向</param>
            /// <param name="tradeprice">成交价</param>
            /// <param name="tradeprice2">开仓价或昨结算价</param>
            /// <param name="volume">手数</param>
            /// <param name="volumemultiple">合约乘数</param>
            /// <returns></returns>
            private decimal CloseProfitExpresson(string direction, decimal tradeprice, decimal tradeprice2, int volume, int volumemultiple) {
                if (direction == dataManager.TradeConst.Direction.Sell) {
                    return (tradeprice - tradeprice2) * volume * volumemultiple;
                }
                else {
                    return (tradeprice2 - tradeprice) * volume * volumemultiple;
                }
            }
    
            /// <summary>
            /// 保证金公式 [(手数*按手数保证金率)+(手数*结算价*合约乘数*按金额保证金率)]
            /// </summary>
            /// <param name="volume">手数</param>
            /// <param name="settlementprice">结算价</param>
            /// <param name="volumemultiple">合约乘数</param>
            /// <param name="ratiobyvolume">按手数保证金率</param>
            /// <param name="ratiobymoney">按金额保证金率</param>
            /// <returns></returns>
            private decimal MarginExpresson(int volume, decimal settlementprice, int volumemultiple, decimal ratiobyvolume, decimal ratiobymoney) {
                return (volume * ratiobyvolume) + (volume * settlementprice * volumemultiple * ratiobymoney);
            }
    
            /// <summary>
            /// 交易所保证金公式 [(手数*结算价*合约乘数*按金额保证金率)]
            /// </summary>
            /// <param name="volume">手数</param>
            /// <param name="settlementprice">结算价</param>
            /// <param name="volumemultiple">合约乘数</param>
            /// <param name="ratiobymoney">按金额保证金率</param>
            /// <returns></returns>
            private decimal ExchangeMarginExpresson(int volume, decimal settlementprice, int volumemultiple, decimal ratiobymoney) {
                return (volume * settlementprice * volumemultiple * ratiobymoney);
            }
    
            /// <summary>
            /// 持仓盈亏公式 [((结算价-开仓价)或(开仓价-结算价))*手数*合约乘数]
            /// </summary>
            /// <param name="direction">方向</param>
            /// <param name="openpriceOrlastsettlementprice">开仓价或昨结算价</param>
            /// <param name="settlementprice">结算价</param>
            /// <param name="volume">手数</param>
            /// <param name="volumemultiple">合约乘数</param>
            /// <returns></returns>
            private decimal PositionProfitExpresson(string direction, decimal openpriceOrlastsettlementprice, decimal settlementprice, int volume, int volumemultiple) {
                if (direction == dataManager.TradeConst.Direction.Buy) {
                    return (settlementprice - openpriceOrlastsettlementprice) * volume * volumemultiple;
                }
                else {
                    return (openpriceOrlastsettlementprice - settlementprice) * volume * volumemultiple;
                }
            }
            #endregion
  • 相关阅读:
    Code first常用命令
    vue问题集锦
    net WebConfig读写
    CefSharp使用心得
    工作问题
    工作总结
    HttpContext.Current.Session为null
    Java基础00-接口组成更新31
    Java基础00-Lamda表达式30
    Java基础00-网络编程29
  • 原文地址:https://www.cnblogs.com/diose/p/7359758.html
Copyright © 2011-2022 走看看