Exemplo n.º 1
0
        private void gwInstruments_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (loaded == true)
            {
                if (e.ColumnIndex == 4)
                {
                    DataGridViewTextBoxCell cellID = (DataGridViewTextBoxCell)gwInstruments.Rows[e.RowIndex].Cells[5];
                    int ID = Convert.ToInt32(cellID.Value);


                    DataGridViewCheckBoxCell      cellIsFavorite = (DataGridViewCheckBoxCell)gwInstruments.Rows[e.RowIndex].Cells[e.ColumnIndex];
                    MyTrade.Core.Model.Instrument instrument     = (MyTrade.Core.Model.Instrument)gwInstruments.Rows[e.RowIndex].DataBoundItem;
                    instrument.IsFavorite = Convert.ToBoolean(cellIsFavorite.Value);
                    MyTrade.Core.SqliteDataAccess.StockInstruments.UpdateIsFavorite(instrument);
                }
            }
        }
Exemplo n.º 2
0
        public static List <MyTrade.Core.Model.Instrument> All()
        {
            string responseString = Data.Call.Get(Constants.url.Instruments);

            JArray a = JArray.Parse(responseString);
            IList <jInstrument> jInstruments = a.Select(p => new jInstrument
            {
                name           = (string)p["name"],
                symbol         = (string)p["symbol"],
                tradable       = (bool)p["tradable"],
                easy_to_borrow = (bool)p["easy_to_borrow"],
                exchange       = (string)p["exchange"]
            }).ToList();


            var tradable = from x in jInstruments
                           where x.tradable == true && x.easy_to_borrow == true  // && x.exchange== "NASDAQ"
                           orderby x.name
                           select x;


            List <MyTrade.Core.Model.Instrument> instruments = new List <MyTrade.Core.Model.Instrument>();

            foreach (var item in tradable)
            {
                MyTrade.Core.Model.Instrument _instrument = new MyTrade.Core.Model.Instrument();
                _instrument.Name        = item.symbol;
                _instrument.DisplayName = item.name;
                _instrument.Type        = item.exchange;
                _instrument.PipLocation = 1;
                _instrument.IsFavorite  = false;
                instruments.Add(_instrument);
            }



            //foreach (var item in instrumentResponse.instruments)
            //{

            //
            //}

            return(instruments);
        }
Exemplo n.º 3
0
        public static List <MyTrade.Core.Model.Instrument> All()
        {
            string responseString     = Data.OANDARestResponse.Get(Constants.url.INSTRUMENTS);
            var    instrumentResponse = JsonConvert.DeserializeObject <InstrumentResponse>(responseString);
            List <MyTrade.Core.Model.Instrument> instruments = new List <MyTrade.Core.Model.Instrument> ();

            foreach (var item in instrumentResponse.instruments)
            {
                MyTrade.Core.Model.Instrument _instrument = new MyTrade.Core.Model.Instrument();
                _instrument.Name        = item.name;
                _instrument.DisplayName = item.displayName;
                _instrument.Type        = item.type;
                _instrument.PipLocation = Math.Abs(item.pipLocation);
                _instrument.IsFavorite  = false;

                instruments.Add(_instrument);
            }

            return(instruments);
        }