예제 #1
0
        /// <summary>
        /// Sets all existing values to the given value.
        /// </summary>
        public void Set(double dNewValue)
        {
            WorkDate endDate = this.YoungestDate;

            for (WorkDate keyDate = this.OldestDate.Clone(); keyDate <= endDate; keyDate++)
            {
                this[keyDate] = dNewValue;
            }
        }
예제 #2
0
        /// <summary>
        /// Multiplies all values of the container with the given factor.
        /// </summary>
        public void Scale(double dScale)
        {
            WorkDate endDate = this.YoungestDate;

            for (WorkDate keyDate = this.OldestDate.Clone(); keyDate <= endDate; keyDate++)
            {
                this[keyDate] *= dScale;
            }
        }
예제 #3
0
 /// <summary>
 /// Removes all data drawing from the chart. All other settings like size are untouched.
 /// </summary>
 public void Clear()
 {
     m_plotsets.Clear();
     m_strTitle  = null;
     m_strLabelY = null;
     m_fromDate  = null;
     m_toDate    = null;
     m_dMaxValue = Double.MinValue;
     m_dMinValue = Double.MaxValue;
 }
예제 #4
0
 /// <summary>
 /// Erzeugt eine neue Dpotposition
 /// </summary>
 public DepotPosition(string strWKN, int nQuantity, WorkDate buyDate, double dBuyPrice)
 {
     this.m_strWKN    = strWKN;
     this.Quantity    = nQuantity;
     this.BuyDate     = buyDate;
     this.BuyPrice    = dBuyPrice;
     this.TrailingGap = 0.0;
     this.StopLoss    = 0.0;
     this.Price       = dBuyPrice;
 }
예제 #5
0
        /// <summary>
        /// Laedt Kursdaten aus der Datei
        /// </summary>
        private void LoadQuotes(EasyStoreReader easystore, DataContainer quotes)
        {
            DateTime priceDate = new DateTime();
            string   strKey, strValue;

            while (easystore.GetNextKeyValue(out strKey, out strValue))
            {
                DateTime.TryParse(strKey, out priceDate);
                WorkDate workdate = new WorkDate(priceDate.Year, priceDate.Month, priceDate.Day);
                quotes[workdate] = Double.Parse(strValue);
            }
        }
예제 #6
0
        /// <summary>
        /// Liefert einen neuen DataContainer, der inhaltlich die
        /// gleichen Key-Value-Paare enhaelt, wie der aktuelle DataContainer.
        /// Alle Element-Objekte (was auch immer) wird neu erzeugt.
        /// </summary>
        public DataContainer Clone(WorkDate fromDate, WorkDate toDate)
        {
            DataContainer dcTarget = new DataContainer();

            for (WorkDate keyDate = new WorkDate(fromDate); keyDate <= toDate; keyDate++)
            {
                if (this.Contains(keyDate))
                {
                    dcTarget[keyDate] = this[keyDate];
                }
            }

            return(dcTarget);
        }
예제 #7
0
        /// <summary>
        /// Verkauft ein Wertpapier mit den angegebenen Daten zum
        /// aktuellen Preis im Depot. Evtl. muss vor dem Verkauf
        /// eine Kursaktualisierung durchgefuehrt werden.
        /// </summary>
        /// <param name="strWKN">WKN, bzw. ID</param>
        /// <param name="nQuantity">Stueckzahl</param>
        /// <param name="sellDate">Verkaufsdatum</param>
        public void Sell(string strWKN, int nQuantity, WorkDate sellDate)
        {
            if (m_positions.ContainsKey(strWKN))
            {
                DepotPosition depotposition = m_positions[strWKN];

                nQuantity = Math.Min(nQuantity, depotposition.Quantity);
                depotposition.Quantity -= nQuantity;
                m_dCash += nQuantity * depotposition.Price * (1.0 - m_dProvisionRate);
                m_nTrades++;

                if (depotposition.Quantity == 0)
                {
                    m_positions.RemoveAt(m_positions.IndexOfKey(strWKN));
                }

                System.Console.WriteLine("Sell {0}: {1} on {2}", depotposition.WKN, nQuantity, sellDate);
            }
        }
예제 #8
0
        /// <summary>
        /// Gibt des Inhalt des Depots tabellarisch aus.
        /// </summary>
        /// <param name="today">Aktuelles Datum</param>
        public void Dump(WorkDate today)
        {
            int nPosition = 1;

            Console.Out.WriteLine();
            Console.Out.WriteLine("## Anz.  WKN   Kaufpr. Kaufdatum  Kurs    Age Perf. StopLoss");

            foreach (DepotPosition position in m_positions.Values)
            {
                Console.Out.WriteLine("{0:00} {1:0000} {2} {3:0000.00} {4} {5:0000.00} {6:000} {7:000.0} {8:0000.00}   ", nPosition, position.Quantity, position.WKN, position.BuyPrice, position.BuyDate, position.Price, position.Age(today), position.Performance, position.StopLoss);
                nPosition++;
            }

            for (int i = 10 - nPosition; i > 0; i--)
            {
                Console.Out.WriteLine("                                                        ");
            }

            Console.Out.WriteLine("Trades: {0:00}  Depotwert: {1:n}   Cash: {2:n}   Equity: {3:n}", this.Trades, this.Asset, this.Cash, this.Equity);
        }
예제 #9
0
        /// <summary>
        /// Greift auf ein Key-Value-Paar zu und ermoeglicht:
        /// 1. Lesen eines Values mit dem angegebenen Key (Datum)
        /// 2. Ueberschreiben eines vorhandenen Values mit dem angegebenen Key (Datum)
        /// 3. Hinzufuegen eines neuen Key-Value-Paares
        /// </summary>
        ///
        /// <code>
        ///       DataContainer quotes = new DataContainer();
        ///       WorkDate datum1 = new WorkDate(2005,1,1);
        ///       quotes[datum1] = 45.7;          // fuegt ein neues Element ein
        ///       quotes[datum1] = 12.1;          // veraendert ein vorhandenes Element
        ///       double dValue  = quotes[datum]; // Liest den Wert am Datum
        /// </code>
        public double this[WorkDate workdate]
        {
            get { return(m_data[workdate]); }

            set
            {
                WorkDate myworkdate = new WorkDate(workdate);
                m_data[myworkdate] = value;

                if (myworkdate < m_MinDate)
                {
                    m_MinDate = myworkdate;
                }

                if (myworkdate > m_MaxDate)
                {
                    m_MaxDate = myworkdate;
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Fuellt alle Luecken mit dem letzten gueltigen Wert auf.
        /// </summary>
        /// <returns>Anzahl der Luecken, die aufgefuellt wurden.
        public int FillGaps()
        {
            double dOldValue   = 0;
            int    nFilledGaps = 0;

            for (WorkDate keyDate = new WorkDate(m_MinDate); keyDate <= m_MaxDate; keyDate++)
            {
                if (this.Contains(keyDate))
                {
                    dOldValue = this[keyDate];
                }
                else
                {
                    this[keyDate] = dOldValue;
                    nFilledGaps++;
                }
            }

            return(nFilledGaps);
        }
예제 #11
0
 /// <summary>
 /// Berechnet die Dauer der aktuellen Anlage in Tagen.
 /// Bei Zukaeufen wird ab dem letzten Kaufdatum gezaehlt.
 /// </summary>
 /// <param name="workdate">Aktuelles Datum</param>
 /// <returns>Dauer der Anlage in Tagen</returns>
 public long Age(WorkDate workdate)
 {
     return(workdate - m_BuyDate);
 }
예제 #12
0
        public double GetPrice(string strWKN, WorkDate workdate)
        {
            DataContainer data = GetQuotes(strWKN);

            return(data[workdate]);
        }
예제 #13
0
        public bool HasPrice(string strWKN, WorkDate workdate)
        {
            DataContainer data = GetQuotes(strWKN);

            return(data.Contains(workdate));
        }
예제 #14
0
 /// <summary>
 /// Entfernt alle Key-Value-Elemente aus dem Container
 /// </summary>
 public void Clear()
 {
     m_data.Clear();
     m_MinDate = WorkDate.MaxDate;
     m_MaxDate = WorkDate.MinDate;
 }
예제 #15
0
 /// <summary>
 /// Prueft, ob ein Datum (Key) im Container vorhanden ist
 /// </summary>
 /// <returns><c>true</c>, wenn das Datum existiert, ansonsten <c>false</c></returns>
 public bool Contains(WorkDate workdate)
 {
     return(m_data.ContainsKey(workdate));
 }