internal double ProfitInPosition(TransactionPairBinary binary, double price)
 {
     if (binary.Completed)
     {
         price = binary.ExitPrice;
     }
     return(profitLossCalculation.CalculateProfit(binary.Direction, binary.EntryPrice, price));
 }
Beispiel #2
0
 internal double ProfitInPosition(TransactionPairBinary binary, double price)
 {
     if (!binary.Completed)
     {
         binary.ExitPrice = price;
     }
     return(CalcProfitLoss(binary));
 }
Beispiel #3
0
 public IEnumerator GetEnumerator()
 {
     for (int i = 0; i < transactionPairs.Count; i++)
     {
         TransactionPairBinary binary = transactionPairs[i];
         yield return(binary);
     }
 }
Beispiel #4
0
        public double ProfitInPosition(int index, double price)
        {
            TransactionPairBinary binary = transactionPairs[index];

            if (trace)
            {
                log.Trace("direction = " + binary.Direction + ", currentPosition = " + binary.CurrentPosition + ", volume = " + binary.Volume + ", closed points = " + binary.ClosedPoints);
            }
            binary.ExitPrice = price;
            return(CalcProfitLoss(binary));
        }
Beispiel #5
0
 public TransactionPairsBinary GetCompletedList(TimeStamp time, double price, int bar)
 {
     if (count > 0)
     {
         TransactionPairBinary pair = this[count - 1];
         if (!pair.Completed)
         {
             pair.Update(price, time, bar);
             this[count - 1] = pair;
         }
     }
     return(this);
 }
        public double ProfitInPosition(int index, double price)
        {
            TransactionPairBinary binary = transactionPairs[index];

            if (trace)
            {
                log.Trace("direction = " + binary.Direction + ", currentPosition = " + binary.CurrentPosition + ", volume = " + binary.Volume);
            }
            if (binary.Direction == 0)
            {
                throw new ApplicationException("Direction not set for profit loss calculation.");
            }
            return(profitLossCalculation.CalculateProfit(binary.Direction, binary.EntryPrice, price));
        }
        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(TransactionPairBinary))
            {
                return(false);
            }
            TransactionPairBinary trade = (TransactionPairBinary)obj;
            var entryPriceMatch         = this.currentPosition == trade.currentPosition ? this.averageEntryPrice == trade.averageEntryPrice : true;

            return(this.longVolume == trade.longVolume &&
                   this.shortVolume == trade.shortVolume &&
                   entryPriceMatch &&
                   this.EntryTime == trade.EntryTime &&
                   this.exitPrice == trade.exitPrice &&
                   this.ExitTime == trade.ExitTime);
        }
Beispiel #8
0
        unsafe public void Add(TransactionPairBinary trade)
        {
            if (count >= capacity)
            {
                throw new ApplicationException("Only " + capacity + " items allows per transaction page.");
            }

            fixed(byte *bptr = buffer)
            {
                TransactionPairBinary *tptr = (TransactionPairBinary *)bptr;

                *(tptr + count) = trade;
            }

            count++;
        }
Beispiel #9
0
        private double CalcProfitLoss(TransactionPairBinary binary)
        {
            double result;

            if (profitLoss2Calculation == null)
            {
                result = profitLossCalculation.CalculateProfit(binary.Direction, binary.EntryPrice, binary.ExitPrice);
            }
            else
            {
                double profitLoss;
                double costs;
                profitLoss2Calculation.CalculateProfit(binary, out profitLoss, out costs);
                result = profitLoss - costs;
            }
            return(result.Round());
        }
//		public void SetProperties(string parameters)
//		{
//			string[] strings = parameters.Split(new char[] {','});
//			currentPosition = Convert.ToInt32(strings[0]);
//			entryPrice = Convert.ToDouble(strings[1]);
//			averageEntryPrice = Convert.ToDouble(strings[2]);
//			entryTime = new TimeStamp(strings[3]).Internal;
//			exitPrice = Convert.ToDouble(strings[4]);
//			exitTime = new TimeStamp(strings[5]).Internal;
//		}

        public TransactionPairBinary(TransactionPairBinary other)
        {
            entryTime         = other.entryTime;
            postedEntryTime   = other.postedEntryTime;
            exitTime          = other.exitTime;
            postedExitTime    = other.postedExitTime;
            currentPosition   = other.currentPosition;
            entryPrice        = other.entryPrice;
            averageEntryPrice = other.averageEntryPrice;
            exitPrice         = other.exitPrice;
            minPrice          = other.minPrice;
            maxPrice          = other.maxPrice;
            exitBar           = other.exitBar;
            entryBar          = other.entryBar;
            completed         = other.completed;
            longVolume        = other.longVolume;
            shortVolume       = other.shortVolume;
            entryOrderId      = other.entryOrderId;
            entrySerialNumber = other.entrySerialNumber;
            exitOrderId       = other.exitOrderId;
            exitSerialNumber  = other.entrySerialNumber;
        }
Beispiel #11
0
 public void Add(TransactionPairBinary trade)
 {
     count++;
     AssureTail();
     tail.Add(trade);
 }
 public void init(TransactionPairBinary binary)
 {
     this.binary = binary;
 }
 public TransactionPairImpl(TransactionPairBinary binary)
 {
     this.binary = binary;
 }