Ejemplo n.º 1
0
        static void StockPricesForAllInstruments()
        {
            ApiClient        api  = new ApiClient(_apiKey);
            InstrumentRespV1 inst = api.GetInstruments();

            // Get all stockprices for each Instrument
            foreach (var i in inst.Instruments)
            {
                //StockPricesRespV1 sp = api.GetStockPrices(i.InsId.Value, Convert.ToDateTime("2018-12-01"), DateTime.Today);

                StockPricesRespV1 sp = api.GetStockPrices(i.InsId.Value);
                Console.WriteLine(DateTime.Now.ToLongTimeString() + "  GetStockPrices() " + i.InsId.Value + " " + sp.StockPricesList.Count());
            }
        }
Ejemplo n.º 2
0
        /// <summary> Return list of all instruments</summary>
        public InstrumentRespV1 GetInstruments()
        {
            string url = string.Format(_urlRoot + "/v1/instruments/");
            HttpResponseMessage response = WebbCall(url, _authKey);

            if (response.IsSuccessStatusCode)
            {
                string           json = response.Content.ReadAsStringAsync().Result;
                InstrumentRespV1 res  = JsonConvert.DeserializeObject <InstrumentRespV1>(json);
                return(res);
            }
            else
            {
                Console.WriteLine("GetInstruments {0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }

            return(null);
        }
Ejemplo n.º 3
0
        // Get all Meta data about Instruments and connect data to Instrument Object.
        static void InstrumentsWithMetadata()
        {
            ApiClient api = new ApiClient(_apiKey);

            // get all Meta data
            CountriesRespV1 cr = api.GetCountries();
            BranchesRespV1  br = api.GetBranches();
            SectorsRespV1   sr = api.GetSectors();
            MarketsRespV1   mr = api.GetMarkets();

            // Get all Instruments
            InstrumentRespV1 inst = api.GetInstruments();

            // Connect Meta data to Instruments
            foreach (InstrumentV1 c in inst.Instruments)
            {
                CountryV1 country = cr.Countries.FirstOrDefault(o => o.Id == c.CountryId);
                c.CountryModel = country;

                MarketV1 Market = mr.Markets.FirstOrDefault(o => o.Id == c.MarketId);
                c.MarketModel = Market;


                BranchV1 Branch = br.Branches.FirstOrDefault(o => o.Id == c.BranchId);
                c.BranchModel = Branch;

                SectorV1 Sector = sr.Sectors.FirstOrDefault(o => o.Id == c.SectorId);
                c.SectorModel = Sector;
            }

            // Print Data to see all is ok
            foreach (InstrumentV1 c in inst.Instruments)
            {
                if (c.Instrument == Instrument.Index) // Index don't have any Branch or Sector
                {
                    Console.WriteLine(c.Name + " : " + c.CountryModel.Name + " : " + c.MarketModel.Name);
                }
                else
                {
                    Console.WriteLine(c.Name + " : " + c.CountryModel.Name + " : " + c.MarketModel.Name + " : " + c.BranchModel.Name + " : " + c.SectorModel.Name);
                }
            }
        }