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
  • 相关阅读:
    pidgin的未认证解决办法
    题解【洛谷P1074】[NOIP2009]靶形数独
    题解【洛谷P1315】[NOIP2011]观光公交
    题解【BZOJ4145】「AMPPZ2014」The Prices
    题解【洛谷P4588】[TJOI2018]数学计算
    题解【洛谷P3884】[JLOI2009]二叉树问题
    题解【SP8002】HORRIBLE
    树链剖分学习笔记
    题解【洛谷P1807】最长路_NOI导刊2010提高(07)
    题解【洛谷P1995】口袋的天空
  • 原文地址:https://www.cnblogs.com/diose/p/7359758.html
Copyright © 2011-2022 走看看