码迷,mamicode.com
首页 > 编程语言 > 详细

期货结算 期货算法公式

时间:2017-08-14 20:00:39      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:reg   ssi   mon   pre   pen   summary   ==   return   ice   

        #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

 

期货结算 期货算法公式

标签:reg   ssi   mon   pre   pen   summary   ==   return   ice   

原文地址:http://www.cnblogs.com/diose/p/7359758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!