コード例 #1
0
ファイル: Position.cs プロジェクト: YourTradingSystems/4XGain
 public static Position operator -(Position p1, Position p2)
 {
     Position res = new Position();
     if (p1.symbol.Length != 0 && p2.symbol.Length != 0 && !p1.symbol.Equals(p2.symbol))
         throw new Exception("Position symbols not the same");
     res.symbol = p1.symbol.Length==0 ? p2.symbol : p1.symbol;
     double pd1 = p1.qty * (p1.direction == 0 ? 1.0 : -1.0);
     double pd2 = p2.qty * (p2.direction == 0 ? 1.0 : -1.0);
     res.qty = pd1 - pd2;
     res.direction = (res.qty < 0.0 ? 1 : 0);
     res.qty = Math.Abs(res.qty);
     return res;
 }
コード例 #2
0
ファイル: Position.cs プロジェクト: YourTradingSystems/4XGain
 ///<summary>
 ///Compares two Position objects. 
 ///</summary>
 ///<param name="otherPosition"> an other position to compare</param>
 ///<returns> true if this Positions is equal
 ///otherwise false</returns>
 public bool compare(Position otherPosition)
 {
     return (otherPosition.symbol.Equals(this.symbol) &&
             otherPosition.qty == this.qty &&
             otherPosition.direction == this.direction);
 }