期貨結算 期貨算法公式
阿新 • • 發佈:2017-08-14
multiple urn == 成交 ssi open posit ava mis
#region 公式算法 /// <summary> /// 可用資金公式 [權益-保證金] /// </summary> /// <param name="balance">權益</param> /// <param name="currmargin">保證金</param> /// <returns></returns> private decimal AvailableExpression(decimalbalance, 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
期貨結算 期貨算法公式