Beispiel #1
0
        public string Translate(MsMkt msMkt, bool reverseDateOrder)
        {
            string str       = "";
            int    startLine = 0;

            if (mp.UseHeaders)
            {
                Add(header(mp.UseQuotes));
                if (Count > 0)
                {
                    startLine = 1;
                }
            }

            ticker = msMkt.Ticker;
            if (msMkt.Reset())
            {
                do
                {
                    DateTime.FromOADate((double)msMkt.CurrentDay.dtd.d);
                    if (!reverseDateOrder)
                    {
                        addLine(msMkt.CurrentDay.dtd);
                    }
                    else
                    {
                        insertLine(msMkt.CurrentDay.dtd, startLine);
                    }
                } while (msMkt.Next());
            }

            string path =
                $"{mp.TxtPath}\\{NgUtils.CheckTickerName(ticker)}.{mp.Extension}";

            try
            {
                File.WriteAllLines(path, ToArray(), Encoding.ASCII);
            }
            catch (IOException ex)
            {
                str = "Exception: File " + path + " could not be accessed as it was open in another process";
            }
            catch (Exception ex)
            {
                str = "Exception: File " + path + " experienced an unknown exception: " + ex.Message;
            }

            return(str);
        }
Beispiel #2
0
        private string insertLine(MsBaseStructs.RecDay day, int startLine)
        {
            string line = "";

            foreach (ColumnInfo colInfo in (List <ColumnInfo>)mp.ColInfoList)
            {
                addField(day, colInfo, ref line);
            }
            if (mp.FieldDelim.Length > 0)
            {
                line = NgUtils.RemoveTrailingChar(line, mp.FieldDelim[0]);
            }
            Insert(startLine, line);
            return(line);
        }
Beispiel #3
0
        public void Add(string symbol, string name)
        {
            ushort fNr = 0;

            for (ushort index = 1; (int)index <= maxEntries; ++index)
            {
                if (fnAvailable[(int)index])
                {
                    fNr = index;
                    fnAvailable[(int)index] = false;
                    NgUtils.MyDeleteFile($"{(object) DirPath}MsSmart\\C{(object) index}.mws");
                    break;
                }
            }

            Add(symbol, name, fNr);
        }
Beispiel #4
0
        private string header(bool useQuotes)
        {
            string str1 = "";

            foreach (ColumnInfo colInfo in (List <ColumnInfo>)mp.ColInfoList)
            {
                string str2 = colInfo.outputName;
                if (str2.ToLower() == "dummy time")
                {
                    str2 = "Time";
                }
                int totalWidth = mp.FieldWidth;
                if (useQuotes)
                {
                    totalWidth -= 2;
                }
                if (totalWidth < 0)
                {
                    totalWidth = 0;
                }
                string str3 = str2.PadRight(totalWidth);
                if (useQuotes)
                {
                    str3 = "\"" + str3 + "\"";
                }
                str1 = str1 + str3 + mp.FieldDelim;
            }

            string str4 = str1.Trim();

            if (mp.FieldDelim.Length > 0)
            {
                str4 = NgUtils.RemoveTrailingChar(str4.Trim(), mp.FieldDelim[0]);
            }
            return(str4.Trim());
        }
Beispiel #5
0
        public void Get()
        {
            if (XmRec)
            {
                Sym01  = NgUtils.ConvertCharArray2String(Xmstr.fi);
                MsName = NgUtils.ConvertCharArray2String(Xmstr.fn);
                try
                {
                    Fjd = CalFunc.Ymd2jd(Xmstr.fd01);
                }
                catch
                {
                    try
                    {
                        Fjd = CalFunc.Ymd2jd(Xmstr.fd02);
                    }
                    catch
                    {
                        Fjd = 0;
                    }
                }

                try
                {
                    Ljd = CalFunc.Ymd2jd(Xmstr.ld);
                }
                catch
                {
                    Ljd = 0;
                }

                FileNo    = Xmstr.rn;
                Interval  = Xmstr.interval;
                Composite = Xmstr.Comp > (byte)0;
            }
            else
            {
                Sym01 = new string(Emstr.sym01);
                string str1 = cleanCharArrayToString(Emstr.xFn);
                string str2 = cleanCharArrayToString(Emstr.fn);
                MsName = str1.Length <= 0 ? str2 : str1;
                try
                {
                    Fjd = CalFunc.Ymd2jd(Emstr.fd);
                }
                catch
                {
                    try
                    {
                        Fjd = (int)ms2ieee(Mstr.d1);
                    }
                    catch
                    {
                        Fjd = 0;
                    }
                }

                try
                {
                    Ljd = CalFunc.MsDate2Jd((double)(int)ms2ieee(Mstr.d2));
                }
                catch
                {
                    Ljd = 0;
                }

                FileNo    = Emstr.rn;
                Interval  = Mstr.interval;
                Composite = Emstr.compFlag1 == (byte)1;
            }

            Sym01.IndexOf(char.MinValue);
            Sym01  = Sym01.Replace("\0", "");
            MsName = MsName.Replace("\0", "");
            if (!Sym01.ToLower().StartsWith("mp_"))
            {
                return;
            }
            dp = 7;
        }