예제 #1
0
        // Called once for each transaction for which a match will be searched.
        void IStockMatch.BeginMatch(SingleTransaction s)
        {
            int ret = asofDate.CompareTo(s.TransactionDate);
            if (ret < 0)
            {
                //if (debug)
                //    System.Console.WriteLine("Transaction happened on {0,15:d} after date {1,15:d}. Ignoring...", s.TransactionDate, asofDate);
                return;
            }

            TimeSpan ts = new TimeSpan();
            ts = asofDate - s.TransactionDate;

            if (debug)
            {
                System.Console.WriteLine("--------------------------------------------------------------------------------------------------------");
                s.Dump();
            }

            if (s.IsAcquisition())
            {
                thisstockqty += s.TransactionQty;
                if (ts.Days > longtermdays)
                    thisstockqtyLT += s.TransactionQty;
            }
            else
            {

                thisstockqty -= s.TransactionQty;
                if (ts.Days > longtermdays)
                    thisstockqtyLT -= s.TransactionQty;
            }
            if (debug)
                System.Console.WriteLine("BEGIN MATCH Stock balance for {0,6} as of {1,15:d} is {2,15}. Long term quantities {3,15}", s.StockCode, asofDate, thisstockqty, thisstockqtyLT);
        }
예제 #2
0
        void IStockMatch.NoMatchFound(SingleTransaction s)
        {
            if (asofDate.CompareTo(s.TransactionDate) < 0)
            {
                if (debug)
                    System.Console.WriteLine("Transaction happened on {0,15:d} after date {1,15:d}. Ignoring...", s.TransactionDate, asofDate);
                return;
            }

            TimeSpan ts = new TimeSpan();
            ts = asofDate - s.TransactionDate;

            //Prefix LT or ST to the transaction
            if (ts.Days > longtermdays)
                System.Console.Write("LONG TERM  ");
            else
                System.Console.Write("SHORT TERM ");
            
            // Output the transaction details
            s.Dump();

            // Keep track of stock balance for unsold stocks
            if (s.IsAcquisition())
                thisstockqty += s.TransactionQty;
            else
                thisstockqty -= s.TransactionQty;
        }
예제 #3
0
        void IStockMatch.NoMatchFound(SingleTransaction s)
        {
            if (asofDate.CompareTo(s.TransactionDate) < 0)
            {
                if (debug)
                    System.Console.WriteLine("Transaction happened on {0,15:d} after date {1,15:d}. Ignoring...", s.TransactionDate, asofDate);
                return;
            }

            // Keep track of stock balance for unsold stocks
            if (!s.IsAcquisition())
            {
                System.Console.Write("Unmatched sell transaction!!!");
                s.Dump();
                return;
            }

            thisstockqty += s.TransactionQty;
            totalcost += s.TransactionQty * (s.TransactionPrice + s.UnitCharges);
        }