Esempio n. 1
0
        private void ImportCurrentPrice( DateTime lastTradingDay )
        {
            Console.WriteLine( "  importing current price separately" );

            var tradedStock = myTom.GetObjectByKey<TradedStock>( this.Scope().Stock.TradedStock.EntityKey );

            // TODO: we need to pass the stock exchange !!
            var currentPriceProvider = Interpreter.Context.DatumProviderFactory.Create( DatumLocatorDefinitions.CurrentPrice );
            var closePrice = currentPriceProvider.FetchSingle<double>();

            // TODO: we cannot really make sure that the price is from this day
            var price = new StockPrice( tradedStock, lastTradingDay, null, null, null, closePrice.Value, null );
            price.DatumOrigin = myTom.DatumOrigins.GetOrCreate( closePrice.Site.Name );
            price.Timestamp = Maui.TypeConverter.DateToString( DateTime.Today ); // TODO: this should be handled by TOM internally
            myTom.StockPrices.AddObject( price );

            myTom.SaveChanges();
        }
Esempio n. 2
0
 /// <summary>
 /// Create a new StockPrice object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="timestamp">Initial value of the Timestamp property.</param>
 /// <param name="close">Initial value of the Close property.</param>
 public static StockPrice CreateStockPrice(global::System.Int64 id, global::System.String timestamp, global::System.Double close)
 {
     StockPrice stockPrice = new StockPrice();
     stockPrice.Id = id;
     stockPrice.Timestamp = timestamp;
     stockPrice.Close = close;
     return stockPrice;
 }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the StockPrices EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStockPrices(StockPrice stockPrice)
 {
     base.AddObject("StockPrices", stockPrice);
 }
Esempio n. 4
0
 public static double Yield( this MauiX.ICalc self, StockPrice from, StockPrice to )
 {
     return ( to.Close - from.Close ) * 100 / from.Close;
 }