示例#1
0
        public static void GetLittleStops()
        {
            _littleDeals = new Dictionary <DateTime, List <LittleTableViewer> >();
            string filePath = Path.Combine(Application.StartupPath, Config.MiscFolderName, Folder, FileName);

            if (File.Exists(filePath))
            {
                List <LittleTableViewer> deals = new List <LittleTableViewer>();
                DateTime date = DateTime.Today;
                using (StreamReader streamReader = new StreamReader(filePath, Encoding.UTF8))
                {
                    while (!streamReader.EndOfStream)
                    {
                        string   line      = streamReader.ReadLine();
                        string[] parametrs = line.Split(';');
                        if (parametrs.Length > 1)
                        {
                            LittleTableViewer tbV = new LittleTableViewer();
                            tbV.Instrument = TradeInstrument.GetIssuer2Name(parametrs[0]);
                            int isLong = Int32.Parse(parametrs[1]);
                            switch (isLong)
                            {
                            case 0:
                                tbV.IsLong = false;
                                break;

                            case 1:
                                tbV.IsLong = true;
                                break;
                            }
                            tbV.OpenValue = StringFunctions.ParseDecimal(parametrs[2]);
                            tbV.StopValue = StringFunctions.ParseDecimal(parametrs[3]);
                            if (String.IsNullOrEmpty(parametrs[4]))
                            {
                                tbV.Profit = null;
                            }
                            else
                            {
                                tbV.Profit = StringFunctions.ParseDouble(parametrs[4]);
                            }
                            deals.Add(tbV);
                        }
                        else
                        {
                            if (deals.Count > 0)
                            {
                                _littleDeals.Add(date, deals);
                                deals.Clear();
                            }
                            date = StringFunctions.GetDate(line, "dd.MM.yyyy");
                        }
                    }
                    _littleDeals.Add(date, deals);
                }
            }
        }
示例#2
0
        private static ObservableCollection <LittleTableViewer> FillLittleTable(Dictionary <TradeInstrument.Issuer, double> instrumentList)
        {
            List <LittleTableViewer> deals = new List <LittleTableViewer>();

            foreach (KeyValuePair <TradeInstrument.Issuer, double> dealProps in instrumentList)
            {
                LittleTableViewer dealParams = new LittleTableViewer();
                dealParams.Instrument = dealProps.Key;
                dealParams.IsLong     = false;
                dealParams.OpenValue  = 0.0m;
                dealParams.StopValue  = (decimal)dealProps.Value;
                dealParams.Profit     = null;
                deals.Add(dealParams);
            }
            return(new ObservableCollection <LittleTableViewer>(deals));
        }
示例#3
0
        private static void SetRomanIssuer(LittleTableViewer props)
        {
            string shortFileName = TradeInstrument.GetIssuerCode(props.Instrument);
            string fullPath      = SetFile(shortFileName);

            using (ExcelClass xls = new ExcelClass())
            {
                xls.OpenDocument(fullPath, false);
                int firstFreeRow = int.Parse(xls.GetCellStringValue(1, 1));

                xls.SetCellValue(9, firstFreeRow, Deal.GetDirection(props.IsLong));
                xls.SetCellValue(10, firstFreeRow, props.OpenValue.ToString());
                xls.SetCellValue(11, firstFreeRow, props.StopValue.ToString());
                xls.SetCellValue(12, firstFreeRow, props.Profit.ToString());
                xls.CloseDocumentSave();
            }
        }