Exemplo n.º 1
0
        /*
         * Programmers: Leonardo Baldazzi, Tommaso Brandinelli
         * Company: OSS inc.
         * Program summary: Simulating Battleship Online via MYSQL Database
         * SubProgram summary: Log-In/Sign-Up user, download '.conf' files, check for updates
         * Class summary: Check for update, if true show progress bar and download
         *
         * Copyright (c) 2018-20 - All Rights Reserved
         */
        internal static void Check()
        {
            bool isChecked = true;

            /*
             * //Download lastest version file
             * var downloadClient = new WebClient();
             * downloadClient.DownloadFile(Dipendences.lastVersionFile, @"C:\Battleship Online\ver.txt");
             *
             * string[] versionDownloaded = System.IO.File.ReadAllLines(@"C:\Battleship Online\ver.txt");
             *
             * if(versionDownloaded[0] == Dipendences.version) //Check if this is the lastes version
             * {
             *  isChecked = false;
             * }
             *
             */

            if (!isChecked)
            {
                //Show update form
                Changelog ch = new Changelog();
                ch.ShowDialog();
            }
            else
            {
                Instruments.GMMessage("This is the lastest version!");
            }
        }
Exemplo n.º 2
0
        protected override void OnSubscribe(Instrument instrument)
        {
            // Get size of bar.
            barSize = (long)Global[barSizeCode];

            // Get spread instrument.
            spread = instrument;

            // Add legs instruments to bar factory.
            foreach (Leg leg in spread.Legs)
            {
                BarFactory.Add(leg.Instrument, BarType.Time, barSize);
            }

            // Remove instruments from strategy.
            Instruments.Clear();

            // Add legs instruments to strategy.
            foreach (Leg leg in spread.Legs)
            {
                AddInstrument(leg.Instrument);
            }

            processors = new System.Collections.Generic.LinkedList <OrderProcessor>();
            groups     = new Dictionary <Instrument, Group[]>();

            AddGroups();
        }
 void RunInspectors(LoggerEvent evt)
 {
     if (Instruments != null)
     {
         Instruments.RunInstruments(evt);
     }
 }
Exemplo n.º 4
0
 public CoinQueue(Instruments instrument)
 {
     this.Instrument     = instrument;
     Updater             = new UpdateClass();
     this.MinuteInterval = 60 * 24 * 2;
     Start();
 }
Exemplo n.º 5
0
        public InstrumentModel GetInstrument(string epic)
        {
            var market = Instruments.FirstOrDefault(m => m.Epic == epic);

            if (market == null)
            {
                var detail = GetMarketDetails(epic);

                market = new InstrumentModel();

                market.DealingRuleData = detail.dealingRules;
                market.InstrumentData  = detail.instrument;
                market.SnapshotData    = detail.snapshot;

                market.Epic           = epic;
                market.InstrumentName = market.InstrumentData.name;

                market.Offer = market.SnapshotData.offer;
                market.Bid   = market.SnapshotData.bid;
                market.High  = market.SnapshotData.high;
                market.Low   = market.SnapshotData.low;

                Instruments.Add(market);

                SubscribeL1WatchlistPrices();
            }

            return(market);
        }
        public ActionResult Details(int?instrumentid, int?artistid)
        {
            Debug.WriteLine("Adding InstrumentsArtists record! Instrument ID submitted = " + instrumentid + ". artist ID submitted = " + artistid);
            if (instrumentid == null || artistid == null)
            {
                Debug.WriteLine("instrument or artist id is null");
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Instruments instruments = db.Instruments.Find(instrumentid);
            Artists     artists     = db.Artists.Find(artistid);

            if (instruments == null)
            {
                Debug.WriteLine("No instrument found with the given instrumentid");
                return(HttpNotFound());
            }
            if (artists == null)
            {
                Debug.WriteLine("No artist found with the given artistid");
                return(HttpNotFound());
            }

            string query = "insert into InstrumentsArtists (Instruments_instrumentid, Artists_artistid) values (@instrumentid,@artistid)";

            SqlParameter[] sqlparams = new SqlParameter[2];
            //binding parameters
            sqlparams[0] = new SqlParameter("@instrumentid", instrumentid);
            sqlparams[1] = new SqlParameter("@artistid", artistid);

            //run create, update, and delete sql commands
            db.Database.ExecuteSqlCommand(query, sqlparams);

            return(RedirectToAction("Details", new { id = instrumentid }));
        }
Exemplo n.º 7
0
        /*Create an Instrument, assign it to a Player, assign a doubling instrument. Add to a new Part and add that to the appropriate sessions.
         * TODO  This is done based on user input on main interface and should be called for each allinstruments entry, either once the user has stopped editing or when they press refresh
         **/

        public void AssignParts(Instruments maininst, Instruments doubinst, int usrPlyrs, bool usrDbl, Instruments insttype, Session s)
        {
            Part prt = new Part();

            //usrPlyrs is number of selected players per part, got from GUI
            //usrDbl is whether the player is doubling
            int i;

            for (i = 0; i < usrPlyrs; i++)
            {
                prt.players.Add(new Player(usrDbl));
            }

            //Make Players and add Instruments
            foreach (Player p in prt.players)
            {
                p.instruments.Add(Functions.MakeInst(maininst));

                if (p.Hasdouble == true)
                {
                    p.instruments.Add(Functions.MakeInst(doubinst));
                }
            }

            //Add Part (plus all its children) to Session
            s.parts.Add(prt);
        }
Exemplo n.º 8
0
 public static void UpdatePosition(QuikConnectionManager.Position obj)
 {
     if (Positions.Any(k => k.AccountName == obj.AccountName && k.Instrument.Code == obj.SecurityCode))
     {
         Entities.Position p = Positions.First(k => k.AccountName == obj.AccountName && k.Instrument.Code == obj.SecurityCode);
         p.Update(obj.TotalNet, obj.BuyQty, obj.SellQty, obj.VarMargin);
         //p.TotalNet = obj.TotalNet;
         //p.BuyQty = obj.BuyQty;
         //p.SellQty = obj.SellQty;
         //p.VM = obj.VarMargin;
     }
     else
     {
         log.Warn("Update on unknown position {0} {1}", obj.AccountName, obj.SecurityCode);
     }
     // update portfolio
     try
     {
         Entities.Instrument i    = Instruments.First(k => k.Code == obj.SecurityCode);
         string             basec = i.Type == Entities.InstrumentType.Futures? i.Code:i.BaseContract;
         Entities.Portfolio p     = Portfolios.First(k => k.Account == obj.AccountName && k.BaseCode == basec);
         Entities.Position  pos   = p.Positions.First(k => k.AccountName == obj.AccountName && k.Instrument.Code == obj.SecurityCode);
         pos.Update(obj.TotalNet, obj.BuyQty, obj.SellQty, obj.VarMargin);
         //pos.TotalNet=obj.TotalNet;
         //pos.VM = obj.VarMargin;
         //pos.BuyQty = obj.BuyQty;
         //pos.SellQty = obj.SellQty;
     }
     catch { log.Warn("Can`t find portfolio for position update!"); }
 }
Exemplo n.º 9
0
        public void Initialize()
        {
            var instrumentsRequest = new JsonGetRequest <Instruments>(string.Format(InstrumentsRequestBasePath, _accountId));
            var response           = _restClient.Get(instrumentsRequest);

            response.Wait();

            _instruments = response.Result;

            _currencyPairNameResolver = new CurrencyPairNameResolver(_instruments.instruments);

            var instrumentCodes = new StringBuilder();

            foreach (var instrumentCode in _instrumentList)
            {
                var nameResolution = _currencyPairNameResolver.Resolve(instrumentCode);
                if (nameResolution.Status == InstrumentNameResolutionResultOption.Success)
                {
                    if (instrumentCodes.Length == 0)
                    {
                        instrumentCodes.Append(nameResolution.Mapping.ProviderInstrumentCode);
                    }
                    else
                    {
                        instrumentCodes.Append(',');
                        instrumentCodes.Append(nameResolution.Mapping.ProviderInstrumentCode);
                    }
                }
            }

            _resolvedInstrumentCodes = instrumentCodes.ToString();
        }
Exemplo n.º 10
0
        private static void ShowProducts(Albums albumy, Instruments instrumenty, Accesories akcesoria)
        {
            Console.WriteLine("|==============================================|");
            Console.WriteLine("|Z jakiej Kategorii chcesz Wyświetlić Produkty?|");
            Console.WriteLine("|==============================================|");
            Console.WriteLine("|0.Wszystkie                                   |");
            Console.WriteLine("|1.Albumy                                      |");
            Console.WriteLine("|2.Instrumenty                                 |");
            Console.WriteLine("|3.Akcesoria                                   |");
            Console.WriteLine("|==============================================|");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 0:
                albumy.PrintAlbums();
                instrumenty.PrintInstruments();
                akcesoria.PrintAccesories();
                break;

            case 1:
                albumy.PrintAlbums();
                break;

            case 2:
                instrumenty.PrintInstruments();
                break;

            case 3:
                akcesoria.PrintAccesories();
                break;
            }
        }
Exemplo n.º 11
0
        private void GenReport()
        {
            //Load backtest result if it has been specified
            var backtestData = GetBacktestData();

            var selectedTags =
                Tags
                .Where(x => x.IsChecked)
                .Select(x => x.Item)
                .ToList();

            var selectedStrategies =
                Strategies
                .Where(x => x.IsChecked)
                .Select(x => x.Item)
                .ToList();

            var selectedInstruments =
                Instruments
                .Where(x => x.IsChecked)
                .Select(x => x.Item)
                .ToList();

            var trades = TradeFiltering.Filter(selectedTags, selectedStrategies, selectedInstruments, Context, TradeFilterSettings);

            Parent.GenerateReportFromTrades.Execute(trades);
        }
Exemplo n.º 12
0
 public static void AddInstrument(QuikConnectionManager.StaticInstrument obj)
 {
     if (Instruments.Any(k => k.Id == obj.Id))
     {
         //var i=Instruments.First(k => k.Id == obj.Id);
         log.Warn("Trying to add existing instrument Id={0} Code={1} Class={2} ", obj.Id, obj.Code, obj.Class);
     }
     else
     {
         if (obj.InstrumentType == "Futures")
         {
             Entities.Instrument instr = new Entities.Instrument(obj.Id, obj.Code, obj.Class, Entities.InstrumentType.Futures, obj.BaseContract, obj.BaseContractClass, obj.FullName);
             instr.DaysToMate   = obj.DaysToMate;
             instr.MaturityDate = Convert.ToDateTime(obj.MaturityDate).Date;
             Instruments.Add(instr);
         }
         else
         {
             Entities.Instrument instr = new Entities.Instrument(obj.Id, obj.Code, obj.Class, Entities.InstrumentType.Option, obj.FullName, obj.OptionType == "Call" ? Entities.OptionType.Call : Entities.OptionType.Put, obj.Strike, obj.BaseContract, obj.BaseContractClass);
             instr.DaysToMate   = obj.DaysToMate;
             instr.MaturityDate = Convert.ToDateTime(obj.MaturityDate).Date;
             Instruments.Add(instr);
         }
         log.Trace("New instrument added Id={0} Code={1} Class={2}", obj.Id, obj.Code, obj.Class);
     }
 }
Exemplo n.º 13
0
        private static void Aspetta(int v) //Aspetta qualcosa
        {
            if (v == 0)                    //Aspetta la posizione delle navi
            {
                int c = 0;

                Instruments.GMMessage("I'm waiting for the ships...");

                while (true)
                {
                    //Conta quante sono le posizioni
                    MySql.Usr.command.CommandText = "SELECT * FROM `Posizioni` WHERE `username` = '" + Dipendences.enemyUsername + "'";
                    MySqlDataReader readPos = MySql.Usr.command.ExecuteReader();

                    MySql.Usr.table.Load(readPos);

                    c = MySql.Usr.table.Rows.Count;

                    readPos.Close();

                    if (c == Dipendences.HOW_MANY_SHIPS)
                    {
                        MySql.Usr.table.Clear();


                        Console.Clear();
                        break;
                    }

                    MySql.Usr.table.Clear();
                }
            }
        }
Exemplo n.º 14
0
        internal static void Initialize()
        {
            Console.Clear();

            int pos = 0;

            //Clear matrix
            Array.Clear(Dipendences.campoNostro, 0, Dipendences.campoNostro.GetLength(0) * Dipendences.campoNostro.GetLength(1));
            Array.Clear(Dipendences.campoNemico, 0, Dipendences.campoNemico.GetLength(0) * Dipendences.campoNemico.GetLength(1));

            Game_Form.Put p = new Game_Form.Put(); //Chiedi le posizioni
            p.ShowDialog();

            foreach (int n in Dipendences.x) //Inserisci le posizioni dentro la matrice
            {
                Dipendences.campoNostro[n, Dipendences.y[pos]] = Dipendences.defStatus;

                pos++;
            }

            Instruments.GMMessage("Initializing AI.....");

            AI.Intialize();

            Console.Clear();

            Aggiorna();

            //Il primo turno è il mio

            Console.ReadKey();
        }
Exemplo n.º 15
0
        public Dictionary <string, IPriceCurve> GetDeltaScenarios(double bumpSize, DateTime?LastDateToBump)
        {
            var o = new Dictionary <string, IPriceCurve>();

            var insToBump = LastDateToBump.HasValue ?
                            Instruments.Where(x => x.LastSensitivityDate < LastDateToBump.Value.AddMonths(1)).ToList() :
                            Instruments.ToList();

            for (var i = 0; i < insToBump.Count; i++)
            {
                var insListClone = Instruments.Select(x => x.Clone()).ToList();
                switch (insListClone[i])
                {
                case AsianBasisSwap abs:
                    insListClone[i] = (AsianBasisSwap)insListClone[i].SetStrike(((AsianBasisSwap)insListClone[i]).Strike - bumpSize);
                    break;

                case Future fut:
                    insListClone[i] = (Future)insListClone[i].SetStrike(((Future)insListClone[i]).Strike - bumpSize);
                    break;
                }
                var bumpedCurve = new BasisPriceCurve(insListClone, Pillars, DiscountCurve, BaseCurve, BuildDate, CurveType, Solver)
                {
                    Currency = Currency, AssetId = AssetId, Name = Name
                };

                o.Add(PillarLabels[i], bumpedCurve);
            }

            return(o);
        }
Exemplo n.º 16
0
        /// <summary>Delete the database file associated with 'code'</summary>
        public void PurgeCachedInstrument(string code)
        {
            Instruments.RemoveIf(x => x.SymbolCode == code);
            var db_filepath = Instrument.CacheDBFilePath(Model.Settings, code);

            File.Delete(db_filepath);
        }
Exemplo n.º 17
0
        //returns basic page when you click on instruments
        public ActionResult CheckPrices(string InstrumentName)
        {
            List <int> lstInst = new List <int>();

            //finds rental object on instrument code
            //Instruments oInstrument = lstRentals.Find(x => x.InstrumentCode == iCode);

            foreach (var item in db.instruments.ToList())
            {
                if (InstrumentName == item.InstrumentName)
                {
                    lstInst.Add(item.InstrumentCode);
                }
            }

            //loads up viewbag for each item wanted
            Instruments oInstrument1 = db.instruments.Find(lstInst[0]);

            ViewBag.Instrument1 = oInstrument1;

            Instruments oInstrument2 = db.instruments.Find(lstInst[1]);

            ViewBag.Instrument2 = oInstrument2;

            /*for (var iCount = 0; iCount < lstInst.Count; iCount++)
             * {
             *  string sInstrument = "oInstrument" + iCount;
             *  Instruments sInstrument = db.instruments.Find(lstInst[iCount]);
             *  ViewBag.Instrument1 = oInstrument1;
             * }*/

            return(View());
        }
Exemplo n.º 18
0
        /// <summary>
        /// Prepares the collection of the quotes stored in the Quotes Manager cache.
        /// </summary>
        ///<param name="quotesManager">QuotesManager instance</param>
        public static IQMDataCollection PrepareListOfQMData(QuotesManager quotesManager)
        {
            QMDataCollection collection  = new QMDataCollection();
            BaseTimeframes   timeframes  = quotesManager.getBaseTimeframes();
            Instruments      instruments = quotesManager.getInstruments();

            int instrumentCount = instruments.size();

            for (int i = 0; i < instrumentCount; i++)
            {
                Instrument instrument     = instruments.get(i);
                int        timeframeCount = timeframes.size();
                for (int j = 0; j < timeframeCount; j++)
                {
                    string timeframe = timeframes.get(j);
                    int    y1        = instrument.getOldestQuoteDate(timeframe).Year;
                    int    y2        = instrument.getLatestQuoteDate(timeframe).Year;
                    if (y2 >= y1)
                    {
                        for (int y = y1; y <= y2; y++)
                        {
                            long size = quotesManager.getDataSize(instrument.getName(), timeframe, y);
                            if (size > 0)
                            {
                                collection.Add(new QMData(instrument.getName(), timeframe, y, size));
                            }
                        }
                    }
                }
            }

            return(collection);
        }
Exemplo n.º 19
0
        private static void AddNewProducts(Albums albumy, Instruments instrumenty, Accesories akcesoria)
        {
            Console.WriteLine("|==============================================|");
            Console.WriteLine("|Z jakiej Kategorii chcesz dodać Produkt?      |");
            Console.WriteLine("|==============================================|");
            Console.WriteLine("|1.Albumy                                      |");
            Console.WriteLine("|2.Instrumenty                                 |");
            Console.WriteLine("|3.Akcesoria                                   |");
            Console.WriteLine("|==============================================|");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 1:
                albumy.AddNewAlbums(GetAlbumTitle(), GetAlbumArtist());
                break;

            case 2:
                instrumenty.AddNewInstruments(GetItemType(), GetItemName(), GetProducent(), GetPrice());
                break;

            case 3:
                akcesoria.AddNewAccesories(GetItemName(), GetProducent(), GetPrice());
                break;
            }
        }
Exemplo n.º 20
0
        private async Task HandleOrderBook(OrderBook orderBook)
        {
            var instrument = Instruments.SingleOrDefault(x =>
                                                         string.Compare(x.Name, orderBook.AssetPair, StringComparison.InvariantCultureIgnoreCase) == 0);

            if (instrument != null)
            {
                if (orderBook.Prices.Any())
                {
                    decimal bestBid = 0;
                    decimal bestAsk = 0;

                    if (orderBook.IsBuy)
                    {
                        _lastBids[instrument.Name] = bestBid = orderBook.Prices.Select(x => x.Price).OrderByDescending(x => x).First();
                        bestAsk = _lastAsks[instrument.Name];
                    }
                    else
                    {
                        _lastAsks[instrument.Name] = bestAsk = orderBook.Prices.Select(x => x.Price).OrderBy(x => x).First();
                        bestBid = _lastBids[instrument.Name];
                    }

                    if (bestBid > 0 && bestAsk > 0)
                    {
                        var tickPrice = new TickPrice(instrument, orderBook.Timestamp, bestAsk, bestBid);
                        await _tickPriceHandler.Handle(tickPrice);
                    }
                }
            }
        }
        private void Search()
        {
            Instruments.Clear();
            var contract = new Contract
            {
                Symbol         = SymbolTextBox.Text,
                SecurityType   = TWSUtils.SecurityTypeConverter((InstrumentType)InstrumentTypeBox.SelectedItem),
                Exchange       = ExchangeBox.Text == "All" ? "" : ExchangeBox.Text,
                IncludeExpired =
                    IncludeExpiredCheckBox.IsChecked != null && (bool)IncludeExpiredCheckBox.IsChecked
            };

            if (Expirationpicker.SelectedDate.HasValue)
            {
                contract.Expiry = Expirationpicker.SelectedDate.Value.ToString("yyyyMM");
            }

            if (StrikeTextBox.Text != "")
            {
                double strike;
                bool   success = double.TryParse(StrikeTextBox.Text, out strike);
                if (success)
                {
                    contract.Strike = strike;
                }
            }

            _client.RequestContractDetails(_nextRequestID, contract);
        }
        private void _client_ContractDetails(object sender, ContractDetailsEventArgs e)
        {
            var instrument = TWSUtils.ContractDetailsToInstrument(e.ContractDetails);

            instrument.Datasource   = _thisDS;
            instrument.DatasourceID = _thisDS.ID;
            if (e.ContractDetails.Summary.Exchange != null && _exchanges.ContainsKey(e.ContractDetails.Summary.Exchange))
            {
                instrument.Exchange   = _exchanges[e.ContractDetails.Summary.Exchange];
                instrument.ExchangeID = instrument.Exchange.ID;
            }
            else
            {
                Dispatcher.Invoke(() => _logger.Log(NLog.LogLevel.Error, "Could not find exchange in database: " + e.ContractDetails.Summary.Exchange));
                return;
            }

            if (e.ContractDetails.Summary.PrimaryExchange != null && _exchanges.ContainsKey(e.ContractDetails.Summary.PrimaryExchange))
            {
                instrument.PrimaryExchange   = _exchanges[e.ContractDetails.Summary.PrimaryExchange];
                instrument.PrimaryExchangeID = instrument.PrimaryExchange.ID;
            }
            else if (!string.IsNullOrEmpty(e.ContractDetails.Summary.PrimaryExchange))
            {
                Dispatcher.Invoke(() => _logger.Log(NLog.LogLevel.Error, "Could not find exchange in database: " + e.ContractDetails.Summary.PrimaryExchange));
                return;
            }

            Dispatcher.Invoke(() => Instruments.Add(instrument));
        }
Exemplo n.º 23
0
 public Element(Instruments instrument, int x, int y)
 {
     inst     = instrument;
     this.x   = x;
     this.y   = y;
     argument = 3;
 }
Exemplo n.º 24
0
        private void LoadAutoCompleteData()
        {
            if (this.txtKeyMember.InvokeRequired || this.cbInstruments.InvokeRequired)
            {
                LoadAutoCompleteData_Del d = new LoadAutoCompleteData_Del(LoadAutoCompleteData);
                this.Invoke(d);
            }
            else
            {
                AutoCompleteStringCollection namesource = new AutoCompleteStringCollection();
                namesource.AddRange((from m in Members select m.UIName).ToArray());

                txtKeyMember.AutoCompleteMode         = AutoCompleteMode.Suggest;
                txtKeyMember.AutoCompleteSource       = AutoCompleteSource.CustomSource;
                txtKeyMember.AutoCompleteCustomSource = namesource;

                txtMember.AutoCompleteMode         = AutoCompleteMode.Suggest;
                txtMember.AutoCompleteSource       = AutoCompleteSource.CustomSource;
                txtMember.AutoCompleteCustomSource = namesource;

                cbInstruments.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                cbInstruments.AutoCompleteSource = AutoCompleteSource.ListItems;
                cbInstruments.Items.AddRange(Instruments.ToArray());
                cbInstruments.DisplayMember = "ShortName";
                cbInstruments.ValueMember   = "Isin";
            }
        }
        public ActionResult showDetails(int instrumentid)
        {
            Debug.WriteLine("Receiving instrumentid as " + instrumentid);
            //grabbing the instrument
            Instruments inst = db.Instruments.SqlQuery("select * from Instruments where instrumentid = @id", new SqlParameter("id", instrumentid)).FirstOrDefault();

            return(PartialView("_showInstrument", inst));
        }
Exemplo n.º 26
0
        // GET api/values/5


        // POST api/values
        public void Add([FromBody] Instruments product)
        {
            DataContext         store       = new DataContext(@"Data Source=localhost\SQLEXPRESS01;database=store;Integrated Security = True;");
            Table <Instruments> instruments = store.GetTable <Instruments>();

            instruments.InsertOnSubmit(product);
            store.SubmitChanges();
        }
Exemplo n.º 27
0
        public static void PlayRandomTone(Instruments instrument)
        {
            int       toneIndex  = GetUniqueRandomToneIndex(avoidTone);
            AudioClip toneToPlay = instruments[instrument].audioClips[toneIndex];

            SFXPlayer.PlaySound(toneToPlay);
            avoidTone = toneIndex;
        }
Exemplo n.º 28
0
        public ActionResult DeleteConfirmed(int id)
        {
            Instruments instruments = db.Instruments.Find(id);

            db.Instruments.Remove(instruments);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 29
0
 public ActionResult CreateInstrument(Instruments newInstruments)
 {
     if ((int)Session["Role_ID"] == 3 || (int)Session["Role_ID"] == 2)
     {
         instrumentsDAO InstrumentToCreate = _mapper.SingleInstrument(newInstruments);
         _InstrumentDataAccess.CreateInstruments(InstrumentToCreate);
     }
     return(RedirectToAction("InstrumentsView"));
 }
Exemplo n.º 30
0
 public static void AddPosition(QuikConnectionManager.Position obj)
 {
     if (!Positions.Any(k => k.AccountName == obj.AccountName && k.Instrument.Code == obj.SecurityCode))
     {
         Entities.Instrument instr;
         if (obj.AccountName == "FOUXK_001")
         {
             Console.Write("fnfyng");
         }
         try
         {
             instr = Instruments.First(k => k.Code == obj.SecurityCode);
             var pos = new Entities.Position(obj.AccountName, instr, obj.TotalNet, obj.BuyQty, obj.SellQty, obj.VarMargin);
             Positions.Add(pos);
             log.Info("New position added. SecCode={0} Account={1}", obj.SecurityCode, obj.AccountName);
             if (pos.Instrument.Type == Entities.InstrumentType.Futures)
             {
                 if (Portfolios.Any(k => k.BaseCode == pos.Instrument.Code && k.Account == pos.AccountName))
                 {
                     Portfolios.First(k => k.BaseCode == pos.Instrument.Code && k.Account == pos.AccountName).Positions.Add(pos);
                     log.Info("Futures Position added to existing portfolio.");
                 }
                 else
                 {   // create new portfolio
                     Entities.Portfolio port = new Entities.Portfolio(pos.Instrument.Code, pos.AccountName);
                     port.Positions.Add(pos);
                     Portfolios.Add(port);
                     log.Info("New portfolio created. Name={0} Base={1} Account={2}", port.Name, port.BaseCode, port.Account);
                 }
             }
             else if (pos.Instrument.Type == Entities.InstrumentType.Option)
             {
                 if (Portfolios.Any(k => k.BaseCode == pos.Instrument.BaseContract && k.Account == pos.AccountName))
                 {
                     Portfolios.First(k => k.BaseCode == pos.Instrument.BaseContract && k.Account == pos.AccountName).Positions.Add(pos);
                     log.Info("Option Position added to existing portfolio.");
                 }
                 else
                 {   // create new portfolio
                     Entities.Portfolio port = new Entities.Portfolio(pos.Instrument.BaseContract, pos.AccountName);
                     port.Positions.Add(pos);
                     Portfolios.Add(port);
                     log.Info("New portfolio created. Name={0} Base={1} Account={2}", port.Name, port.BaseCode, port.Account);
                 }
             }
         }
         catch (SystemException exep)
         {
             log.Error("Try to add position for unknown instrument {0} {1} {2}", obj.SecurityCode, obj.AccountName, obj.TotalNet);
             log.Error(exep.Message);
         }
     }
     else
     {
         log.Warn("Try to add existing position. {0} {1}", obj.AccountName, obj.SecurityCode);
     }
 }
Exemplo n.º 31
0
 public static void Export(Instruments instruments)
 {
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.Filter = WYZTracker.Core.Properties.Resources.INSFilter;
     if (sfd.ShowDialog() == DialogResult.OK)
     {
         XmlSerializer formatter = new XmlSerializer(typeof(Instruments));
         Stream objFileStream = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write, FileShare.None);
         formatter.Serialize(objFileStream, instruments);
         objFileStream.Close();
     }
 }
Exemplo n.º 32
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try
            {
                //Setting header information
                QuotesHeaders headers = new QuotesHeaders();
                DateTime start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 10, 10, 0);
                DateTime end = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 10, 11, 0);
                if (new DateTime().DayOfWeek == DayOfWeek.Saturday)
                {
                    TimeSpan ts1 = new TimeSpan(1, 0, 0, 0);
                   start= start.Subtract(ts1);
                  end=  end.Subtract(ts1);
                }
                else if (new DateTime().DayOfWeek == DayOfWeek.Sunday)
                {
                    start.AddDays(-2);
                    end.AddDays(-2);
                }

                DateTimeRange dtr = new DateTimeRange();
                dtr.startDateTime = start;
                dtr.endDateTime = end;
				dtr.region = "NY";
                headers.datetimerange = dtr;

                //Setting instruments
                Instrument ticker = new Instrument();
                ticker.id = "IBM US";
                ticker.yellowkeySpecified = true;
                ticker.typeSpecified = true;
                ticker.yellowkey = MarketSector.Equity;
                ticker.type = InstrumentType.TICKER;
                Instruments instrs = new Instruments();
                instrs.instrument = new Instrument[] { ticker };

                 SubmitGetAllQuotesRequest req = new SubmitGetAllQuotesRequest();
                req.headers = headers;
                req.instruments = instrs;
                
			Console.WriteLine("Sending submit get all quotes request");
	        SubmitGetAllQuotesResponse resp = ps.submitGetAllQuotesRequest(req);
	        String responseId = resp.responseId;
            Console.WriteLine("Submit get all quotes request status: " + resp.statusCode.description +
					 " responseId: " + resp.responseId);

            RetrieveGetAllQuotesRequest rreq = new RetrieveGetAllQuotesRequest();
	        rreq.responseId = responseId;
	        RetrieveGetAllQuotesResponse rresp = ps.retrieveGetAllQuotesResponse(rreq);
            Console.WriteLine("Sending retrieve get all quotes request");
			// Keep polling for response till the data is available
			do
			{
                System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
				rresp = ps.retrieveGetAllQuotesResponse(rreq);
			} while (rresp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);


                	// Display data
			if (rresp.statusCode.code == PerSecurity.SUCCESS)
			{
				Console.WriteLine("Retrieve get all quotes request successful.  Response ID:" + rresp.responseId);
				for (int i = 0; i < rresp.instrumentDatas.Length; i++)
				{
					Console.WriteLine("Data for :"
                            + rresp.instrumentDatas[i].instrument.id + " "
                            + rresp.instrumentDatas[i].instrument.yellowkey);
					for (int j = 0; j < rresp.instrumentDatas[i].quotes.Length; j++)
					{
                        for (int k = 0; k < rresp.instrumentDatas[i].quotes[j].matchedQuote.Length; k++)
                        {
								Console.WriteLine(" type = "
                                        + rresp.instrumentDatas[i].quotes[j].matchedQuote[k].type +
										", price =  "
                                        + rresp.instrumentDatas[i].quotes[j].matchedQuote[k].price
										+ ", volume =  "
                                        + rresp.instrumentDatas[i].quotes[j].matchedQuote[k].volume
										        );
							}
					}
				}
			}
			else if (rresp.statusCode.code == PerSecurity.REQUEST_ERROR)
                Console.WriteLine("Error in submitted request");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 33
0
 public EngineModel GetNoteModel(Instruments.InstrumentNote note)
 {
     EngineModel model = content.Load<Model>(noteBaseModel);
     model.Position = new Vector3(noteInfo[note].X, noteBaseY, noteBaseZ);
     model.Scale = noteBaseScale;
     model.SetTexture(0, content.Load<Texture2D>(noteInfo[note].Texture));
     return model;
 }
Exemplo n.º 34
0
        public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
        {
            try
            {
                //Setting request header information
                GetDataHeaders getDataHdrs = new GetDataHeaders();
                getDataHdrs.secmasterSpecified = true;
                getDataHdrs.secmaster = true;

                //Setting instruments for request
                Instruments instrs = new Instruments();
                instrs.macro = new Macro[2];
                instrs.macro[0] = new Macro();
                instrs.macro[0].primaryQualifier = new PrimaryQualifier();
                instrs.macro[0].primaryQualifier.primaryQualifierType = MacroType.SECTYP;
                instrs.macro[0].primaryQualifier.primaryQualifierValue = "OPT_CHAIN";

                instrs.macro[0].secondaryQualifier = new SecondaryQualifier[1];
                instrs.macro[0].secondaryQualifier[0] = new SecondaryQualifier();
                instrs.macro[0].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals;
                instrs.macro[0].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.SECURITY_DES;
                instrs.macro[0].secondaryQualifier[0].secondaryQualifierValue = "SPX Index";
                instrs.macro[0].overrides = new Override[1];
                //A sample of incorrect macro
                instrs.macro[1] = new Macro();
                instrs.macro[1].primaryQualifier = new PrimaryQualifier();
                instrs.macro[1].primaryQualifier.primaryQualifierType = MacroType.SECTYP;
                instrs.macro[1].primaryQualifier.primaryQualifierValue = "OPTCHAIN";

                instrs.macro[1].secondaryQualifier = new SecondaryQualifier[1];
                instrs.macro[1].secondaryQualifier[0] = new SecondaryQualifier();
                instrs.macro[1].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals;
                instrs.macro[1].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.SECURITY_DES;
                instrs.macro[1].secondaryQualifier[0].secondaryQualifierValue = "SPX Index";
               
                //Setting fields for the request
                string[] field = new string[] { "NAME", "TICKER", "PX_LAST" };

                //Submit get data request
                Console.WriteLine("Sending submit get data request");
                SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest();
                sbmtGtDtreq.headers = getDataHdrs;
                sbmtGtDtreq.fields = field;
                sbmtGtDtreq.instruments = instrs;

                SubmitGetDataResponse sbmtGtDtresp = ps.submitGetDataRequest(sbmtGtDtreq);
                System.Console.WriteLine("status " + sbmtGtDtresp.statusCode.description);
                System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtDtresp.responseId);

                //retrieve get data request. The response ID sent for the request is the response ID
                //received from SubmitGetDataRequest()

                Console.WriteLine("Retrieve data request");
                RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest();
                rtrvGtDrReq.responseId = sbmtGtDtresp.responseId;
                RetrieveGetDataResponse rtrvGtDrResp = new RetrieveGetDataResponse();

                //Keep sending the request until status code is "0"(success)
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                    rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq);
                }
                while (rtrvGtDrResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

                if (rtrvGtDrResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    Console.WriteLine("Retrieve get data request successful");
                    for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++)
                    {
                        if (rtrvGtDrResp.instrumentDatas[i].code.Equals("0"))
                        {
                            System.Console.WriteLine("Data for :" + rtrvGtDrResp.instrumentDatas[i].instrument.id +
                                "  " + rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey);
                            for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++)
                            {
                                if (rtrvGtDrResp.instrumentDatas[i].data[j].isArray == true)
                                {
                                    //In case this is a bulk field request
                                    for (int k = 0; k < rtrvGtDrResp.instrumentDatas[i].data[j].
                                        bulkarray.Length; k++)
                                    {
                                        Console.WriteLine("-------------------------");
                                        for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].data[j].
                                            bulkarray[k].data.Length; l++)
                                            Console.WriteLine(rtrvGtDrResp.instrumentDatas[i].data[j]
                                                .bulkarray[k].data[l].value);
                                    }
                                }
                                else

                                    System.Console.WriteLine("	" + sbmtGtDtreq.fields[j] + " : " + 
                                        rtrvGtDrResp.instrumentDatas[i].data[j].value);
                            }
                        }
                        //If an incorrect macro was passed in the request, display the error code and the incorrect macro
                        else
                        {
                            System.Console.WriteLine("\n Error Code " + rtrvGtDrResp.instrumentDatas[i].code +
                                ": incorrect macro. The Macro object is as follows:");
                            Console.WriteLine("Primary Qualifier -");
                            Console.WriteLine("Primary Qualifier type:" + rtrvGtDrResp.instrumentDatas[i].
                                macro.primaryQualifier.primaryQualifierType);
                            Console.WriteLine("Primary Qualifier value:" + rtrvGtDrResp.instrumentDatas[i].
                                macro.primaryQualifier.primaryQualifierValue);
                            Console.WriteLine("Secondary Qualifier -");
                            for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].macro.secondaryQualifier.Length; l++)
                            {
                                Console.WriteLine("Secondary Qualifier type :" + rtrvGtDrResp.instrumentDatas[i].
                                    macro.secondaryQualifier[l].secondaryQualifierType);
                                Console.WriteLine("Secondary Qualifier Value :" + rtrvGtDrResp.instrumentDatas[i].
                                    macro.secondaryQualifier[l].secondaryQualifierValue);
                                Console.WriteLine("Secondary Qualifier Operator :" + rtrvGtDrResp.instrumentDatas[i].
                                    macro.secondaryQualifier[l].secondaryQualifierOperator);
                            }
                        }

                    }
                    
                }
                else if (rtrvGtDrResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    Console.WriteLine("Error in the submitted request");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "  " + e.StackTrace);
            }
        }
Exemplo n.º 35
0
         public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
        {
            //Setting request headers
            GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
            DateRange dtRange = new DateRange();
            Duration duration = new Duration();
            duration.days = 3;
            dtRange.duration = duration;
            getHistHeaders.daterange = dtRange;

            //Setting instruments
            Instruments instrs = new Instruments();
            instrs.macro = new Macro[2];
            instrs.macro[0] = new Macro();
            instrs.macro[0].primaryQualifier = new PrimaryQualifier();
            instrs.macro[0].primaryQualifier.primaryQualifierType = MacroType.SECTYP;
            instrs.macro[0].primaryQualifier.primaryQualifierValue = "CONVERTS";

            instrs.macro[0].secondaryQualifier = new SecondaryQualifier[1];
            instrs.macro[0].secondaryQualifier[0] = new SecondaryQualifier();
            instrs.macro[0].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals;
            instrs.macro[0].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.TICKER;
            instrs.macro[0].secondaryQualifier[0].secondaryQualifierValue = "F";

            //A sample of incorrect macro
            instrs.macro[1] = new Macro();
            instrs.macro[1].primaryQualifier = new PrimaryQualifier();
            instrs.macro[1].primaryQualifier.primaryQualifierType = MacroType.SECTYP;
            instrs.macro[1].primaryQualifier.primaryQualifierValue = "converts_err";

            instrs.macro[1].secondaryQualifier = new SecondaryQualifier[1];
            instrs.macro[1].secondaryQualifier[0] = new SecondaryQualifier();
            instrs.macro[1].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals;
            instrs.macro[1].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.TICKER;
            instrs.macro[1].secondaryQualifier[0].secondaryQualifierValue = "F";

            //Setting get history request parameters
            string[] fields =  new string[] {"PX_LAST"}; 
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
            sbmtGtHistReq.headers = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
            sbmtGtHistReq.fields = fields;
            try
            {
                Console.WriteLine("Submit Get History request");
                SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq);
                System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtHistResp.responseId);

                Console.WriteLine("Retrieve data request");
                RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;
                RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

                //Keep sending the request until status code is "0"(success)
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                    rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq);
                }
                while (rtrvGtHistResp.statusCode.code== PerSecurity.DATA_NOT_AVAILABLE );

                //Displaying data
                if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                    {
                        if(rtrvGtHistResp.instrumentDatas[i].code.Equals("0"))
                        {
                        System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                            "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                        Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString());
                        for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                        {

                            Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.
                                instrumentDatas[i].data[j].value);
                        }
                        }
                        else
                        {
                             System.Console.WriteLine("\nError Code " + rtrvGtHistResp.instrumentDatas[i].code + ": incorrect macro. The Macro object is as follows:");
                            Console.WriteLine("Primary Qualifier - ");
                            Console.WriteLine("Primary Qualifier type:" + rtrvGtHistResp.instrumentDatas[i].
                                macro.primaryQualifier.primaryQualifierType);
                            Console.WriteLine("Primary Qualifier value:" + rtrvGtHistResp.instrumentDatas[i].
                                macro.primaryQualifier.primaryQualifierValue);
                            Console.WriteLine("Secondary Qualifier -");
                            for (int l = 0; l < rtrvGtHistResp.instrumentDatas[i].macro.secondaryQualifier.
                                Length; l++)
                            {
                                Console.WriteLine("Secondary Qualifier type :" + rtrvGtHistResp.instrumentDatas[i].
                                    macro.secondaryQualifier[l].secondaryQualifierType);
                                Console.WriteLine("Secondary Qualifier Value :" + rtrvGtHistResp.instrumentDatas[i]
                                    .macro.secondaryQualifier[l].secondaryQualifierValue);
                                Console.WriteLine("Secondary Qualifier Operator :" + rtrvGtHistResp.instrumentDatas[i]
                                    .macro.secondaryQualifier[l].secondaryQualifierOperator);
                            }
                        }
                    }
                }
                else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                {
                    Console.WriteLine("Error in the submitted request");
                }
			}

        
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
Exemplo n.º 36
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try
            {
                // Setting header for the request
                GetFundamentalsHeaders getFundHeaders = new GetFundamentalsHeaders();
                GetDataHeaders getDataHeaders = new GetDataHeaders();
                getDataHeaders.closingvaluesSpecified = true;
                getDataHeaders.closingvalues = true;
                getDataHeaders.secmasterSpecified = true;
                getDataHeaders.secmaster = true;
                getDataHeaders.derivedSpecified = true;
                getDataHeaders.derived = true;

                // Setting instruments for the request
			Instrument ticker = new Instrument();
			ticker.id = "IBM US";
			ticker.type = InstrumentType.TICKER;
			ticker.yellowkey = MarketSector.Equity;

			Instrument bbUniqueId = new Instrument();
			bbUniqueId.id = "EQ0086119600001000";
			bbUniqueId.type = InstrumentType.BB_UNIQUE;
			Instrument[] instr = new Instrument[] { ticker, bbUniqueId };
			
			String[] field = new String[] { "TOP_ANALYST_PERFORM_RANK_TRR" };


                // Sending submit get data request
			SubmitGetDataRequest sbmtGetDtReq = new SubmitGetDataRequest();
			sbmtGetDtReq.headers = getDataHeaders;
			sbmtGetDtReq.fields = field;
			Instruments instrmnts = new Instruments();
			instrmnts.instrument = instr;
			sbmtGetDtReq.instruments = instrmnts;
			Console.WriteLine("Sending submit get bulk data request");
			SubmitGetDataResponse sbmtGetDtResp = ps
					.submitGetDataRequest(sbmtGetDtReq);
			Console.WriteLine("Submit get data request status: "
					+ sbmtGetDtResp.statusCode.description
					+ "  response ID: " + sbmtGetDtResp.responseId);


                // Sending retrieve get data request
			RetrieveGetDataRequest rtvGetDtReq = new RetrieveGetDataRequest();
			rtvGetDtReq.responseId = sbmtGetDtResp.responseId;
			RetrieveGetDataResponse rtvGetDtResp = new RetrieveGetDataResponse();
            Console.WriteLine("Sending retrieve get data request");
			
			// Keep polling for response till the data is available
			do {
                System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
				rtvGetDtResp = ps.retrieveGetDataResponse(rtvGetDtReq);

			} while (rtvGetDtResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);
			

                // Display data
			if (rtvGetDtResp.statusCode.code == PerSecurity.SUCCESS) {
				Console.WriteLine("Retrieve get data request successful. Response ID: "
						+ rtvGetDtResp.responseId);
				for (int i = 0; i < rtvGetDtResp.instrumentDatas.Length; i++) {
                    InstrumentData data = rtvGetDtResp.instrumentDatas[i];
					Console.WriteLine(data.instrument.id);
					Data[] datas = data.data;
					for (int j = 0; j < datas.Length; j++) {
						//Displaying bulk data
						if (datas[j].isArray) {

							for (int k = 0; k < datas[j].bulkarray.Length; k++)
                                for (int l = 0; l < datas[j].bulkarray[k].data.Length; l++) {
                                    Console.WriteLine(datas[j].bulkarray[k].data[l].type
													+ ": "
                                                    + datas[j].bulkarray[k].data[l].value);
								}
						} 
						//Displaying non-bulk data
						else
							Console.WriteLine(datas[j].value);
                        	}
				}
			} else if (rtvGetDtResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                Console.WriteLine("Error in submitted request");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 37
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try{
            // Setting headers for the request
            GetDataHeaders getDataHeaders = new GetDataHeaders();
            getDataHeaders.closingvaluesSpecified = true;
            getDataHeaders.closingvalues = true;
            getDataHeaders.secmasterSpecified = true;
            getDataHeaders.secmaster = true;
            getDataHeaders.derivedSpecified = true;
            getDataHeaders.derived = true;

            // Setting list of instruments for data request
            Instrument ticker = new Instrument();
            ticker = new Instrument();
            ticker.id = "IBM US";
            ticker.type= InstrumentType.TICKER;
            ticker.yellowkey = MarketSector.Equity;

            Instrument[] instr = new Instrument[] { ticker };

            String[] field = new String[] { "ID_BB_UNIQUE", "TICKER",
					"PX_LAST", "PX_ASK", "PX_BID", "VWAP_DT" };

            BvalFieldSet fieldset = new BvalFieldSet();
            fieldset.fieldmacro = BvalFieldMacro.BVAL_BOND;


            // Submit get data request
			SubmitGetDataRequest sbmtGetDtReq = new SubmitGetDataRequest();
			sbmtGetDtReq.headers = getDataHeaders;
			sbmtGetDtReq.fields = field;
			sbmtGetDtReq.fieldsets = new BvalFieldSet[] { fieldset };
			Instruments instrmnts = new Instruments();
            instrmnts.instrument = instr;
			sbmtGetDtReq.instruments = instrmnts ;
			Console.WriteLine("Sending submit get data request");
			SubmitGetDataResponse sbmtGetDtResp = ps
					.submitGetDataRequest(sbmtGetDtReq);
            Console.WriteLine("Submit get data request status: " + sbmtGetDtResp.statusCode.description +
					 " responseId: " + sbmtGetDtResp.responseId);

            // Submit retrieve data
			RetrieveGetDataRequest rtvGetDtReq = new RetrieveGetDataRequest();
			rtvGetDtReq.responseId = sbmtGetDtResp.responseId;
			RetrieveGetDataResponse rtvGetDtResp = new RetrieveGetDataResponse();
            Console.WriteLine("Sending retrieve get data request");

			// Keep polling for response till the data is available
			do
			{
                System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
				rtvGetDtResp = ps.retrieveGetDataResponse(rtvGetDtReq);
			} while (rtvGetDtResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

            // Display data
			if (rtvGetDtResp.statusCode.code == PerSecurity.SUCCESS)
			{
				Console.WriteLine("Retrieve get data request successful.  Response ID:" + rtvGetDtResp.responseId);
				for (int i = 0; i < rtvGetDtResp.instrumentDatas.Length; i++)
				{
					Console.WriteLine("Data for :"
							+ rtvGetDtResp.instrumentDatas[i].instrument.id + " "
                            + rtvGetDtResp.instrumentDatas[i].instrument.yellowkey);
                    for (int j = 0; j < rtvGetDtResp.instrumentDatas[i].data.Length; j++)
					{
						Console.WriteLine("  "
								+ rtvGetDtResp.fields[j]
								+ ": "
                                + rtvGetDtResp.instrumentDatas[i].data[j].value);
					}
				}
			}
			else if (rtvGetDtResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                Console.WriteLine("Error in submitted request");
        }
            catch (Exception e)
		{
            Console.WriteLine(e.Message);
		}
        }
Exemplo n.º 38
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {

            //Setting request header information
            GetCompanyHeaders gtCompHdrs = new GetCompanyHeaders();
            gtCompHdrs.creditrisk = true;


            //Setting instruments
            Instrument ticker = new Instrument();
            ticker.id = "AAPL US";
            ticker.yellowkey = MarketSector.Equity;
            ticker.yellowkeySpecified = true;


            //Setting the get Company request parameter
            SubmitGetCompanyRequest sbmtGtCompReq = new SubmitGetCompanyRequest();
            sbmtGtCompReq.headers = gtCompHdrs;
            Instruments instrs = new Instruments();
            instrs.instrument = new Instrument[] { ticker };
            sbmtGtCompReq.instruments = instrs;

            //Setting fields for the request
            sbmtGtCompReq.fields = new string[] { "ID_BB_COMPANY", "ID_BB_ULTIMATE_PARENT_CO_NAME" };

            try
            {
                Console.WriteLine("Submit Get Company Request");

                SubmitGetCompanyResponse sbmtGtCompResp = ps.submitGetCompanyRequest(sbmtGtCompReq);

                System.Console.WriteLine("status " + sbmtGtCompResp.statusCode.description);
                System.Console.WriteLine("Submit Get Company request -  response ID = " + sbmtGtCompResp.responseId);

                //retrieve get company request. The response ID sent for the request is the response ID
                //received from SubmitGetCompanyRequest()
                Console.WriteLine("Retrieve Company request");

                RetrieveGetCompanyRequest rtvGrCompReq = new RetrieveGetCompanyRequest();
                rtvGrCompReq.responseId = sbmtGtCompResp.responseId;
                RetrieveGetCompanyResponse rtrvGtCompResp = new RetrieveGetCompanyResponse();

                //Keep sending the request if status is 100
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                    rtrvGtCompResp = ps.retrieveGetCompanyResponse(rtvGrCompReq);
                }
                while (rtrvGtCompResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

                if (rtrvGtCompResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    //Displaying the rtrvGtCompResp
                    for (int i = 0; i < rtrvGtCompResp.instrumentDatas.Length; i++)
                    {
                        Console.WriteLine("Data for :" + rtrvGtCompResp.instrumentDatas[i].instrument.id +
                            "  " + rtrvGtCompResp.instrumentDatas[i].instrument.yellowkey);
                        for (int j = 0; j < rtrvGtCompResp.instrumentDatas[i].data.Length; j++)
                        {
                            if (rtrvGtCompResp.instrumentDatas[i].data[j].isArray == true)
                            {
                                //In case this is a bulk field request
                                for (int k = 0; k < rtrvGtCompResp.instrumentDatas[i].data[j].bulkarray.Length; k++)
                                {
                                    Console.WriteLine("-------------------------_");
                                    for (int l = 0; l < rtrvGtCompResp.instrumentDatas[i].data[j].
                                        bulkarray[k].data.Length; l++)
                                        Console.WriteLine(rtrvGtCompResp.instrumentDatas[i].data[j].bulkarray[k].data[l].value);
                                }
                            }
                            else
                                Console.WriteLine("	" + rtrvGtCompResp.fields[j] + " : " + rtrvGtCompResp.instrumentDatas[i].data[j].value);
                        }
                    }
                }
                else if (rtrvGtCompResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    Console.WriteLine("Error in the submitted request");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 39
0
 public void SetInstrument(Instruments instrument)
 {
     _midiOut.Send(MidiMessage.ChangePatch((int) instrument, Chanel).RawData);
 }
Exemplo n.º 40
0
		public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
		{
			
			//Set request header
			GetDataHeaders getDataHeaders = new GetDataHeaders();
			getDataHeaders.secmaster = true;
            getDataHeaders.secmasterSpecified = true;
			getDataHeaders.closingvalues = true;
			getDataHeaders.closingvaluesSpecified = true;
			
			//Defining the instruments for the bulk request
			Instrument ticker = new Instrument();
			ticker.id = "IBM US";
			ticker.yellowkeySpecified = true;
			ticker.yellowkey = MarketSector.Equity;
			ticker.typeSpecified = false;
			ticker.type = InstrumentType.TICKER;

			
			Console.WriteLine("Submit get Data request");
			SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest();
			sbmtGtDtreq.headers = getDataHeaders;
			sbmtGtDtreq.fields = new string[]{"TOP_ANALYST_PERFORM_RANK_TRR"};//Bulk field 
            Instruments instrs = new Instruments();
            instrs.instrument = new Instrument[] { ticker };
            sbmtGtDtreq.instruments = instrs;
			try
			{
				SubmitGetDataResponse sbmtGtDtresp = ps.submitGetDataRequest(sbmtGtDtreq);
				System.Console.WriteLine("Request ID = "  + sbmtGtDtresp.requestId + " " + sbmtGtDtresp.responseId);
				System.Console.WriteLine("status of Get Data request :  " + sbmtGtDtresp.statusCode.description);
			
				Console.WriteLine("Retrieve get data request");
				RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest();
				rtrvGtDrReq.responseId = sbmtGtDtresp.responseId;
				RetrieveGetDataResponse rtrvGtDrResp = new RetrieveGetDataResponse();
				do
				{
					System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
					rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq);
			}
				while(rtrvGtDrResp.statusCode.code==PerSecurity.DATA_NOT_AVAILABLE);
                if(rtrvGtDrResp.statusCode.code==PerSecurity.SUCCESS){
				Console.WriteLine("Response ID " +  rtrvGtDrResp.responseId);
                for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++)
                {
                    System.Console.WriteLine("Data for :" + rtrvGtDrResp.instrumentDatas[i].instrument.id +
                        "  " + rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey);
                    for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++)
                    {
                        if (rtrvGtDrResp.instrumentDatas[i].data[j].isArray == true)
                        {
                            for (int k = 0; k < rtrvGtDrResp.instrumentDatas[i].data[j].bulkarray.Length; k++)
                            {
                                Console.WriteLine("-------------------------");
                                for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].data[j].
                                    bulkarray[k].data.Length; l++)
                                    Console.WriteLine(rtrvGtDrResp.instrumentDatas[i].
                                        data[j].bulkarray[k].data[l].value);
                            }
                        }
                        else

                            System.Console.WriteLine("	" + sbmtGtDtreq.fields[j] + " : " +
                                rtrvGtDrResp.instrumentDatas[i].data[j].value);
                    }
                }
				}
                else if (rtrvGtDrResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                {
                    Console.WriteLine("Error in the submitted request");
                }
			}
			catch(Exception e)
			{
				Console.WriteLine(e.Message);
			}
		}
Exemplo n.º 41
0
        public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
        {
            //Setting request headers
            GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
            DateRange dtRange = new DateRange();
            dtRange.period = new Period();
            dtRange.period.start = DateTime.Today.Subtract(TimeSpan.FromDays(7));
            dtRange.period.end = DateTime.Today;
            getHistHeaders.daterange = dtRange;
            getHistHeaders.version = PerSecurity_Dotnet.PerSecurityWSDL.Version.@new;
            //Setting instruments
            Instrument ticker = new Instrument();
            ticker = new Instrument();
            ticker.id = "IBM US";
            ticker.yellowkey = MarketSector.Equity;
            ticker.yellowkeySpecified = true;

            Instrument bbUniqueId = new Instrument();
            bbUniqueId.id = "EQ0086119600001000";
            bbUniqueId.yellowkeySpecified = true;
            bbUniqueId.yellowkey = MarketSector.Equity;
            bbUniqueId.type = InstrumentType.BB_UNIQUE;
            bbUniqueId.typeSpecified = true;

            Instrument[] instr = new Instrument[]{ticker, bbUniqueId};
            Instruments instrs = new Instruments();
            instrs.instrument = instr;

            //Setting get history request parameters
            string[] fields =  new string[] {"PX_LAST","PX_HIGH","PX_LOW" }; 
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
            sbmtGtHistReq.headers = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
            sbmtGtHistReq.fields = fields;
            try
            {
                Console.WriteLine("Submit Get History request");
                SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq);
                System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtHistResp.responseId);

                Console.WriteLine("Retrieve data request");
                RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;
                RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

                //Keep sending the request until status code is "0"(success)
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                    rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq);
                }
                while (rtrvGtHistResp.statusCode.code== PerSecurity.DATA_NOT_AVAILABLE );

                //Displaying data
                if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                    {
                        System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                            "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                        Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString());
                        for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                        {

                            Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.
                                instrumentDatas[i].data[j].value);
                        }
                    }
                }
                else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                {
                    Console.WriteLine("Error in the submitted request");
                }
			}

        
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
Exemplo n.º 42
0
        public void run(PerSecurityWS ps)
        {
            try
            {
                //Setting request headers
                GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
                getHistHeaders.display_pricing_srcSpecified = true;
                getHistHeaders.display_pricing_src = true;

                Instrument ticker = new Instrument();
                ticker = new Instrument();
                ticker.id = "IBM";
                ticker.yellowkey = MarketSector.Equity;
                ticker.yellowkeySpecified = true;

                Instrument[] instr = new Instrument[] { ticker };
                Instruments instrs = new Instruments();
                instrs.instrument = instr;

                string[] fields = new string[] { "PX_LAST" };
                SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
                sbmtGtHistReq.headers = getHistHeaders;
                sbmtGtHistReq.instruments = instrs;
                sbmtGtHistReq.fields = fields;
              
                    Console.WriteLine("Submit Get History request");
                    SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq);
                    System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                    System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtHistResp.responseId);

                    Console.WriteLine("Retrieve data request");
                    RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                    rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;
                    RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

                    //Keep sending the request until status code is "0"(success)
                    do
                    {
                        System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                        rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq);
                    }
                    while (rtrvGtHistResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

                    //Displaying data
                    if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS)
                    {
                        for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                        {
                            System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                                "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                            Console.WriteLine("Date: " + rtrvGtHistResp.instrumentDatas[i].date.ToString());
                            Console.WriteLine("Pricing Source: " + rtrvGtHistResp.instrumentDatas[i].pricingSource);
                            for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                            {

                                Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.
                                    instrumentDatas[i].data[j].value);
                            }
                        }
                    }
                    else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    {
                        Console.WriteLine("Error in the submitted request");
                    }

                   
                 }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message + e.StackTrace);
                }
            }
         public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try{
                //Setting headers
                GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
                getHistHeaders.display_pricing_srcSpecified = true;
                getHistHeaders.display_pricing_src = true;

                Instrument ticker = new Instrument();
                ticker.id = "IBM US";
                ticker.typeSpecified = true;
                ticker.yellowkeySpecified = true;
                ticker.type = InstrumentType.TICKER;
                ticker.yellowkey = MarketSector.Equity;
                Instrument[] instr = new Instrument[] { ticker };
                Instruments instrs = new Instruments();
                instrs.instrument = instr;

                String[] fields = new String[] { "PX_LAST" };

                //Sending Request
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
			sbmtGtHistReq.headers = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
			sbmtGtHistReq.fields = fields;
			Console.WriteLine("Submit Get History request");
			SubmitGetHistoryResponse sbmtGtHistResp = ps
					.submitGetHistoryRequest(sbmtGtHistReq);
            Console.WriteLine("Submit Get Data request - Status: "
					+ sbmtGtHistResp.statusCode.description + " response ID = "
					+ sbmtGtHistResp.responseId);
            Console.WriteLine("Sending retrieve data request");
			RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
			rtrvGtHistReq.responseId=sbmtGtHistResp.responseId;
			RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

                	// Keep polling for response till the data is available
			do {
				System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
				rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq);
			} while (rtrvGtHistResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

			// Displaying data
			if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS) {
				Console.WriteLine("Retrieve get data request successful Response ID: " + rtrvGtHistResp.responseId);
				for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++) {
					Console.WriteLine("Data for :"
                            + rtrvGtHistResp.instrumentDatas[i].instrument.id
							+ " "
                            + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                    Console.WriteLine("Time: " + rtrvGtHistResp.instrumentDatas[i].date.Hour.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Minute.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Second.ToString());
                    Console.WriteLine("Pricing Source: " + rtrvGtHistResp.instrumentDatas[i].pricingSource);
                    for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                    {
						Console.WriteLine(fields[j]
								+ " : "
                                + rtrvGtHistResp.instrumentDatas[i].data[j].value);
					}
				}
			} else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
				Console.WriteLine(" Error in the submitted request" );

            }catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
         }
Exemplo n.º 44
0
		public void run(PerSecurityWS ps)
		{
			try
			{
				//Setting overrides
				Override[] ovride = new Override[4];
				ovride[0] = new Override();
				ovride[0].field = "VWAP_START_DT";
                DateTime start = DateTime.Today;
                ovride[0].value = start.ToString();// "20080227";
				ovride[1] = new Override();
				ovride[1].field = "VWAP_END_DT";
                DateTime end = DateTime.Today.Subtract(TimeSpan.FromDays(5));
                ovride[1].value = end.ToString();//"20080227";
                ovride[2] = new Override();
				ovride[2].field = "VWAP_START_TIME";
				ovride[2].value = "1000";
				ovride[3] = new Override();
				ovride[3].field = "VWAP_END_TIME";
				ovride[3].value = "1100";
			
				//Setting the instruments for request
				Instrument bbUniqueId = new Instrument();
                bbUniqueId.id = "EQ0086119600001000";
				bbUniqueId.yellowkeySpecified = false;
				bbUniqueId.type = InstrumentType.BB_UNIQUE;
				bbUniqueId.typeSpecified = true;
				bbUniqueId.overrides = ovride;

				Instrument ticker = new Instrument();
				ticker.id = "IBM US";
				ticker.yellowkeySpecified = true;
				ticker.yellowkey = MarketSector.Equity;
				ticker.typeSpecified = false;
				ticker.type = InstrumentType.TICKER;
				ticker.overrides = ovride;
				
				
				//Setting request header
				GetDataHeaders getDataHeaders = new GetDataHeaders();
				getDataHeaders.secmaster = true;
				getDataHeaders.secmasterSpecified = true;
                getDataHeaders.closingvalues = true;
				getDataHeaders.closingvaluesSpecified = true;
			    getDataHeaders.programflag = ProgramFlag.daily;
				getDataHeaders.rundate = DateTime.Today.ToString();
				getDataHeaders.time = "1430";
           		getDataHeaders.derived = true;

				//Submit get data request
				Console.WriteLine("Submit get data request");
				SubmitGetDataRequest sbmtGtDrReq = new SubmitGetDataRequest();
				sbmtGtDrReq.headers = getDataHeaders;
				sbmtGtDrReq.fields = new string[]{"ID_BB_UNIQUE","TICKER","PX_LAST","PX_ASK","PX_BID","VWAP_DT"};
                Instruments instrs = new Instruments();
                instrs.instrument = new Instrument[] {ticker, bbUniqueId};
                sbmtGtDrReq.instruments = instrs;
				SubmitGetDataResponse sbmtGetDtResp= ps.submitGetDataRequest(sbmtGtDrReq);
				System.Console.WriteLine("Submit get data response Id = "  + sbmtGetDtResp.responseId + "\n");
			
				System.Threading.Thread.Sleep(100000);
				//Submit scheduled request for the get data request sent above
				Console.WriteLine("Submit scheduled request");
				SubmitScheduledRequest sbmtSchReq =  new SubmitScheduledRequest();
				SubmitScheduledResponse sbmtSchResp = ps.submitScheduledRequest(sbmtSchReq);
				Console.WriteLine("Submit Schedule request responseID : " + sbmtSchResp.responseId + "\n");
		    
				//Submit retrieve scheduled request to display all the scheduled files and check to see
				//if the daily job requested was addeds
				Console.WriteLine("Retrieve scheduled request");
				RetrieveScheduledRequest schReq = new RetrieveScheduledRequest();
				schReq.responseId = sbmtSchResp.responseId;
				RetrieveScheduledResponse schResp = new RetrieveScheduledResponse();
				
				//Keep sending the request until the entire response is received
				do
			   {
					System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
					schResp = ps.retrieveScheduledResponse(schReq);
				}
				while(schResp.statusCode.code==PerSecurity.DATA_NOT_AVAILABLE);
				Console.WriteLine(schResp.responseId);
             
				for(int i=0;i<schResp.fileDatas.Length;i++)
				{
                    if (schResp.fileDatas[i].responseId == sbmtGetDtResp.responseId)
                        Console.WriteLine("Response ID requested by submit get data request: " + 
                            schResp.fileDatas[i].responseId);
                    else
                        Console.WriteLine("Response ID: " + schResp.fileDatas[i].responseId + "\n");
					Console.WriteLine("Response Header for retrieve schedule request");
					Console.WriteLine("Date: " +  schResp.fileDatas[i].headers.getdataHeaders.rundate + 
                        " Time: " + schResp.fileDatas[i].headers.getdataHeaders.time + " Scheduled: " + 
                        schResp.fileDatas[i].headers.getdataHeaders.programflag);
					Console.WriteLine("Fields");
					for(int j=0;j<schResp.fileDatas[i].fields.Length;j++)
					{
						Console.WriteLine(schResp.fileDatas[i].fields[j]);
					}
					Console.WriteLine("Instruments");
					for(int j=0;j<schResp.fileDatas[i].instruments.instrument.Length;j++)
					{
                        Console.WriteLine("ID: " + schResp.fileDatas[i].instruments.instrument[j].id + 
                            "Type: " + schResp.fileDatas[i].instruments.instrument[j].type);
					}
						
				}
				
				//Sending a request to cancel the request for the daily job
				Console.WriteLine("Submit Cancel request");
				CancelHeaders cancelHeaders = new CancelHeaders();
				cancelHeaders.programflag  = ProgramFlag.daily;
				SubmitCancelRequest sbCancelReq = new SubmitCancelRequest();
				sbCancelReq.responseId[0] = sbmtGetDtResp.responseId;
				sbCancelReq.headers = cancelHeaders;
				Boolean flag = true;
				SubmitCancelResponse sbCancelResp = ps.submitCancelRequest(sbCancelReq);
				if(sbCancelResp.statusCode.code==0)
				{
					Console.WriteLine("Submit Cancel request response ID: " + sbCancelResp.responseId);
				}
				
				//Checked the scheduled request to check if the daily job has been removed
				Console.WriteLine("Submit scheduled request");
				SubmitScheduledRequest sbmtSchReqCheck = new SubmitScheduledRequest();
				SubmitScheduledResponse sbmtSchRespCheck = ps.submitScheduledRequest(sbmtSchReqCheck);
				Console.WriteLine("Submit Schedule request responseID : " + sbmtSchRespCheck.responseId + "\n");
				
				Console.WriteLine("Retrieve scheduled request");
				RetrieveScheduledRequest schReqCheck = new RetrieveScheduledRequest();
				schReqCheck.responseId = sbmtSchRespCheck.responseId;
				RetrieveScheduledResponse schRespCheck = new RetrieveScheduledResponse();
				do
				{
					System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
					schRespCheck = ps.retrieveScheduledResponse(schReqCheck);
				}
				while(schRespCheck.fileDatas==null);
				Console.WriteLine("response ID for retrieveSchedule respone: " + schResp.responseId);
				String dispRespId = null;
				for(int i=0;i<schRespCheck.fileDatas.Length;i++)
				{
					
					if(schRespCheck.fileDatas[i].responseId==sbmtGetDtResp.responseId)
					  
					{
						flag= true;
						dispRespId	= schRespCheck.fileDatas[i].responseId;
					}
					else
						flag=false;
						
				}
				if(flag)
					Console.WriteLine("The daily job with response ID: " + dispRespId + 
                        "wasnt cancelled successfully");
				else
					Console.WriteLine("The daily job was cancelled successfully");
			}
			catch(Exception e)
			{
				Console.WriteLine(e.Message + e.StackTrace);
			}

			
		}
Exemplo n.º 45
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try
            {
                //Setting headers
                GetActionsHeaders getActionHeaders = new GetActionsHeaders();
                getActionHeaders.actions_date = ActionsDate.entry;
                String[] actions = new String[] { "DVD_CASH", "DISTRIBUTIONS" };
                getActionHeaders.actions = actions;

                //Setting Instruments 
                Instruments instruments = new Instruments();
                Instrument instr = new Instrument();
                instr.id = "COP US";
                instr.yellowkeySpecified = true;
                instr.typeSpecified = true;
                instr.yellowkey = MarketSector.Equity;
                instr.type = InstrumentType.TICKER;
                instruments.instrument = new Instrument[] { instr };

                //Submitting request
                SubmitGetActionsRequest req = new SubmitGetActionsRequest();
                req.headers = getActionHeaders;
                req.instruments = instruments;
                SubmitGetActionsResponse resp = null;
                resp = ps.submitGetActionsRequest(req);
                String responseId = resp.responseId;
                Console.WriteLine("Submit get actions request status: " + resp.statusCode.description +
                         " responseId: " + responseId);

                //Submit retrieve request
                RetrieveGetActionsRequest rtrvReq = new RetrieveGetActionsRequest();
                rtrvReq.responseId = responseId;
                Console.WriteLine("Sending retrieve get actions request");
                RetrieveGetActionsResponse rtrvResp = new RetrieveGetActionsResponse();

                // Keep polling for response till the data is available
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                    rtrvResp = ps.retrieveGetActionsResponse(rtrvReq);
                } while (rtrvResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

                //Display data
                if (rtrvResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    Console.WriteLine("Retrieve get quotes request successful.  Response ID:" + rtrvResp.responseId);
                    for (int i = 0; i < rtrvResp.instrumentDatas.Length; i++)
                    {
                        Console.WriteLine("Data for :"
                                + rtrvResp.instrumentDatas[i].instrument.id + " "
                                + rtrvResp.instrumentDatas[i].instrument.yellowkey
                                );
                        Console.WriteLine(", Company id = " + rtrvResp.instrumentDatas[i].standardFields.companyId.ToString());
                        Console.WriteLine(", Security id = " + rtrvResp.instrumentDatas[i].standardFields.securityId.ToString());
                        if (rtrvResp.instrumentDatas[i].data != null)
                        {
                            for (int j = 0; j < rtrvResp.instrumentDatas[i].data.Length; j++)
                            {
                                Console.WriteLine(": field =  "
                                        + rtrvResp.instrumentDatas[i].data[j].field
                                        + ", value =  "
                                        + rtrvResp.instrumentDatas[i].data[j].value);
                            }
                        }

                    }
                }
                else if (rtrvResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    Console.WriteLine("Error in submitted request");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 46
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {

            //Setting request header information	
            GetDataHeaders getDataHeaders = new GetDataHeaders();
            getDataHeaders.secmaster = true;
            getDataHeaders.secmasterSpecified = true;
            getDataHeaders.closingvalues = true;
            getDataHeaders.closingvaluesSpecified = true;
            getDataHeaders.derived = true;
            getDataHeaders.derivedSpecified = true;


            //Setting Instrument information
            //Instrument bbUniqueId = new Instrument();
            //bbUniqueId.id = "EQ0086119600001000";
            //bbUniqueId.type = InstrumentType.BB_UNIQUE;
            //bbUniqueId.typeSpecified = true;

            //Instrument ticker = new Instrument();
            //ticker.id = "IBM";
            //ticker.yellowkey = MarketSector.Equity;
            //ticker.yellowkeySpecified = true;
            //ticker.type = InstrumentType.TICKER;
            //ticker.typeSpecified = true;


            Instrument bbUniqueId = new Instrument();
            bbUniqueId.id = "GB0003252318";
            bbUniqueId.type = InstrumentType.ISIN;
            bbUniqueId.typeSpecified = true;

            //Setting the get data request parameter
            SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest();
            sbmtGtDtreq.headers = getDataHeaders;
         //   sbmtGtDtreq.fields = new string[] { "ID_BB_UNIQUE", "TICKER", "PX_LAST", "PX_ASK", "PX_BID", "VWAP_DT" };
            sbmtGtDtreq.fields = new string[] { "ID_BB_UNIQUE", "PX_LAST"};
          Instruments instrs = new Instruments();
            System.Collections.Generic.List<Instrument> instrsList = new System.Collections.Generic.List<Instrument>();
        //    instrsList.Add(ticker);
            instrsList.Add(bbUniqueId);
            //instrs.instrument = new Instrument[] { ticker, bbUniqueId };
            instrs.instrument = new Instrument[] {bbUniqueId };
            sbmtGtDtreq.instruments = new Instruments();
            sbmtGtDtreq.instruments = instrs;

            try
            {
                Console.WriteLine("Submit Get Data Request");
                SubmitGetDataResponse sbmtGtDtresp = ps.submitGetDataRequest(sbmtGtDtreq);
                System.Console.WriteLine("status " + sbmtGtDtresp.statusCode.description);
                System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtDtresp.responseId);

                //retrieve get data request. The response ID sent for the request is the response ID
                //received from SubmitGetDataRequest()
                Console.WriteLine("Retrieve data request");
                RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest();
                rtrvGtDrReq.responseId = sbmtGtDtresp.responseId;
                RetrieveGetDataResponse rtrvGtDrResp = new RetrieveGetDataResponse();

                //Keep sending the request if status is 100
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                    rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq);
                }
                while (rtrvGtDrResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

                if (rtrvGtDrResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    //Displaying the RetrieveGetDataResponse
                    for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++)
                    {
                        Console.WriteLine("Data for :" + rtrvGtDrResp.instrumentDatas[i].instrument.id +
                            "  " + rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey);
                        for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++)
                        {
                            if (rtrvGtDrResp.instrumentDatas[i].data[j].isArray == true)
                            {
                                //In case this is a bulk field request
                                for (int k = 0; k < rtrvGtDrResp.instrumentDatas[i].data[j].bulkarray.Length; k++)
                                {
                                    Console.WriteLine("-------------------------");
                                    for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].data[j].
                                        bulkarray[k].data.Length; l++)
                                        Console.WriteLine(rtrvGtDrResp.
                                            instrumentDatas[i].data[j].bulkarray[k].data[l].value);
                                }
                            }
                            else
                                Console.WriteLine("	" + sbmtGtDtreq.fields[j] + " : " + rtrvGtDrResp.
                                    instrumentDatas[i].data[j].value);
                        }
                    }
                }
                else if (rtrvGtDrResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    Console.WriteLine("Error in the submitted request");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "   " + e.StackTrace);
            }
        }