/// <summary>
 /// Initializes a new instance of the <see cref="DownloaderServiceConnection"/> class.
 /// </summary>
 /// <param name="downloaderService">
 /// The downloader service.
 /// </param>
 public DownloaderServiceConnection(IDownloaderService downloaderService)
 {
     var handler = new Handler(this.SendMessage);
     this.messenger = new Messenger(handler);
     this.downloaderService = downloaderService;
 }
 /// <summary>
 /// Create the remote service and marshaler.
 /// </summary>
 /// <remarks>
 /// This is how we pass the client information back to the service so 
 /// the client can be properly notified of changes. 
 /// Do this every time we reconnect to the service.
 /// </remarks>
 /// <param name="m">
 /// The messenger to use.
 /// </param>
 public void OnServiceConnected(Messenger m)
 {
     this.downloaderService = ServiceMarshaller.CreateProxy(m);
     this.downloaderService.OnClientUpdated(this.downloaderServiceConnection.GetMessenger());
 }
 public WebApiModelService(IDownloaderService downloaderService, IApiModelCacheService apiModelCacheService)
 {
     _downloaderService = downloaderService;
     _apiModelCacheService = apiModelCacheService;
 }
 /// <summary>
 /// Returns a stub object that, when connected, will listen for 
 /// marshalled IDownloaderService methods and translate them into calls 
 /// to the supplied interface.
 /// </summary>
 /// <param name="itf">
 /// An implementation of IDownloaderService that will be called when
 /// remote method calls are unmarshalled.
 /// </param>
 /// <returns>
 /// A stub that will listen for marshalled IDownloaderService methods.
 /// </returns>
 public static IDownloaderServiceConnection CreateStub(IDownloaderService itf)
 {
     return new DownloaderServiceConnection(itf);
 }
 /// <summary>
 /// Create the remote service and marshaler.
 /// </summary>
 /// <remarks>
 /// This is how we pass the client information back to the service so
 /// the client can be properly notified of changes.
 /// Do this every time we reconnect to the service.
 /// </remarks>
 /// <param name="m">
 /// The messenger to use.
 /// </param>
 public void OnServiceConnected(Messenger m)
 {
     _downloaderService = DownloaderServiceMarshaller.CreateProxy(m);
     _downloaderService.OnClientUpdated(_downloaderServiceConnection.GetMessenger());
 }
Example #6
0
            public static Data GetData(Stock stock, IDownloaderService downloaderService, HistoricalData historicalData)
            {
                Data result = new Data();

                result.Quotes = historicalData.Quotes.Values.Select(x => new Skender.Stock.Indicators.Quote
                {
                    Date   = x.Date,
                    Low    = Convert.ToDecimal(x.Low),
                    High   = Convert.ToDecimal(x.High),
                    Open   = Convert.ToDecimal(x.Open),
                    Close  = Convert.ToDecimal(x.Close),
                    Volume = Convert.ToDecimal(x.Volume)
                }).ToList();

                var market = new Stock()
                {
                    Country = new Others(), Symbol = stock.Country.Id == Singapore.CountryId ? "^STI" : "^PSI20"
                };

                market.HistoricalData = downloaderService.GetHistoricalData(market, historicalData.BeginDate, historicalData.EndDate).Result;

                var commodity = new Stock()
                {
                    Country = new Others(), Symbol = "O87.SI"
                };

                commodity.HistoricalData = downloaderService.GetHistoricalData(commodity, historicalData.BeginDate, historicalData.EndDate).Result;

                result.MarketQuotes    = new List <Skender.Stock.Indicators.Quote>();
                result.CommodityQuotes = new List <Skender.Stock.Indicators.Quote>();

                for (var i = 0; i < historicalData.Quotes.Count; i++)
                {
                    var date = historicalData.Quotes.ElementAt(i).Key;
                    var closestMarketDate    = market.HistoricalData.Quotes.Keys.LastOrDefault(x => x <= date);
                    var closestCommodityDate = commodity.HistoricalData.Quotes.Keys.LastOrDefault(x => x <= date);

                    if (closestMarketDate == default)
                    {
                        result.MarketQuotes.Add(new Skender.Stock.Indicators.Quote {
                            Date = date
                        });
                    }
                    else
                    {
                        result.MarketQuotes.Add(new Skender.Stock.Indicators.Quote
                        {
                            Date   = date,
                            Low    = Convert.ToDecimal(market.HistoricalData.Quotes[closestMarketDate].Low),
                            High   = Convert.ToDecimal(market.HistoricalData.Quotes[closestMarketDate].High),
                            Open   = Convert.ToDecimal(market.HistoricalData.Quotes[closestMarketDate].Open),
                            Close  = Convert.ToDecimal(market.HistoricalData.Quotes[closestMarketDate].Close),
                            Volume = Convert.ToDecimal(market.HistoricalData.Quotes[closestMarketDate].Volume)
                        });
                    }

                    if (closestCommodityDate == default)
                    {
                        result.CommodityQuotes.Add(new Skender.Stock.Indicators.Quote {
                            Date = date
                        });
                    }
                    else
                    {
                        result.CommodityQuotes.Add(new Skender.Stock.Indicators.Quote
                        {
                            Date   = date,
                            Low    = Convert.ToDecimal(commodity.HistoricalData.Quotes[closestCommodityDate].Low),
                            High   = Convert.ToDecimal(commodity.HistoricalData.Quotes[closestCommodityDate].High),
                            Open   = Convert.ToDecimal(commodity.HistoricalData.Quotes[closestCommodityDate].Open),
                            Close  = Convert.ToDecimal(commodity.HistoricalData.Quotes[closestCommodityDate].Close),
                            Volume = Convert.ToDecimal(commodity.HistoricalData.Quotes[closestCommodityDate].Volume)
                        });
                    }
                }

                return(result);
            }
Example #7
0
 public void OnServiceConnected(Messenger messenger)
 {
     //("MainActivity.OnServiceConnected messenger:" + messenger.ToString());
     this._expansionDownloaderService = DownloaderServiceMarshaller.CreateProxy(messenger);
     this._expansionDownloaderService.OnClientUpdated(this._downloaderServiceConnection.GetMessenger());
 }
Example #8
0
 public void TearDown()
 {
     this._downloadService = null;
     this._stock           = null;
 }
Example #9
0
 public void TearDown()
 {
     _downloadService = null;
     _stock           = null;
 }