public AddInstrumentTreatmentsModal(Model.Instrument instrument)
        {
            this.InitializeComponent();

            _instrument = instrument;
            FillTreatments();
        }
示例#2
0
 public Units(Model.Instrument _instrument, double _risk, double _currentPrice, double _stopLoss)
 {
     instrument   = _instrument;
     risk         = _risk;
     stopLoss     = _stopLoss;
     currentPrice = _currentPrice;
 }
        public AddInstrumentModal(Model.Drawer selectedDrawer)
		{
			this.InitializeComponent();

            _selectedDrawer = selectedDrawer;
            _instrumentToAdd = new Model.Instrument();

            UpdateNumberOfTreatments();
		}
示例#4
0
        public static List <Model.Instrument> All()
        {
            string responseString               = Data.OANDARestResponse.Get(Constants.url.INSTRUMENTS);
            var    instrumentResponse           = JsonSerializer.Deserialize <InstrumentResponse>(responseString);
            List <Model.Instrument> instruments = new List <Model.Instrument>();

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


                instruments.Add(_instrument);
            }

            return(instruments);
        }
示例#5
0
        public static List <Model.Instrument> AllFromFile()
        {
            string responseString = System.IO.File.ReadAllText(Constants.AssemblyPath() + @"\Data\OANDA\Instruments.json");


            var instrumentResponse = JsonSerializer.Deserialize <InstrumentResponse>(responseString);
            List <Model.Instrument> instruments = new List <Model.Instrument>();

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

                instruments.Add(_instrument);
            }

            return(instruments);
        }
        private void btnUpdateInstrument_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string instrumentName = txtInstrumentName.Text.Trim();

            if (AreValidFields(instrumentName) == false)
            {
                return;
            }

            Model.Instrument instrumentToUpdate = Controllers.BusinessController.Instance.FindById <Model.Instrument>(_instrumentId);

            if (instrumentToUpdate != null)
            {
                instrumentToUpdate.Name = instrumentName;

                if (Controllers.BusinessController.Instance.Update <Model.Instrument>(instrumentToUpdate))
                {
                    this.Close();
                    return;
                }
            }

            MessageBox.Show("No se pudo actualizar el instrumento", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
        }
        public ManageInstrumentTreatmentsModal(Model.Instrument instrument)
        {
            this.InitializeComponent();

            _instrument = instrument;
        }
示例#8
0
        public static Model.Instrument Run()
        {
            List <Model.Instrument> instruments = Data.Instrument.AllFromFile().OrderBy(x => x.Name).ToList();
            var builder = new StringBuilder();
            var input   = Console.ReadKey(intercept: true);
            int i       = 0;

            Model.Instrument match = null;
            while (input.Key != ConsoleKey.Enter)
            {
                var currentInput = builder.ToString();
                if (input.Key == ConsoleKey.Tab)
                {
                    if (i == 0)
                    {
                        match = instruments.FirstOrDefault(item => item.Name != currentInput && item.Name.StartsWith(currentInput, true, CultureInfo.InvariantCulture));
                        for (int y = 0; y < instruments.Count; y++)
                        {
                            if (instruments[y].Name == match.Name)
                            {
                                i = y;
                            }
                        }
                    }


                    else
                    {
                        match = instruments[i];
                    }

                    if (string.IsNullOrEmpty(match.Name))
                    {
                        input = Console.ReadKey(intercept: true);
                        continue;
                    }

                    ClearCurrentLine();
                    builder.Clear();

                    Console.Write(match.Name);
                    builder.Append(match.Name);
                    i += 1;
                }
                else
                {
                    if (input.Key == ConsoleKey.Backspace && currentInput.Length > 0)
                    {
                        builder.Remove(builder.Length - 1, 1);
                        ClearCurrentLine();

                        currentInput = currentInput.Remove(currentInput.Length - 1);
                        Console.Write(currentInput);
                    }
                    else
                    {
                        i = 0;
                        var key = input.KeyChar;
                        builder.Append(key);
                        Console.Write(key);
                    }
                }

                input = Console.ReadKey(intercept: true);
            }

            Console.Write(input.KeyChar);

            Console.WriteLine(match.Name);
            return(match);
        }