コード例 #1
0
        void fupdate(object sender, bool setunions)
        {
            // set default search options
            if (setunions)
            {
                // if they have both dates and symbols selected, default
                // to intersection of both sets
                if (usedates.Checked && usestocks.Checked)
                {
                    _symdateand.Checked = true;
                }
                else
                {
                    _symdateand.Checked = false;
                }

                // if there are more than one year, more than one month,
                // or more than one day selected... default to a union of sets
                if ((yearlist.SelectedIndices.Count > 1) ||
                    (monthlist.SelectedIndices.Count > 1) ||
                    (daylist.SelectedIndices.Count > 1))
                {
                    _dateor.Checked = true;
                }
                // otherwise if dates are enabled, default to intersection only
                else if (yearlist.Enabled)
                {
                    _dateand.Checked = true;
                }
            }
            // if we're watching files
            if (_dw.Visible)
            {
                // clear window
                _dw.Clear();
                // get current filter
                TickFileFilter tff = GetFilter();
                // get matching files
                string [] files = tff.Allows(TikUtil.GetFiles());
                // display in window
                foreach (string file in files)
                {
                    _dw.GotDebug(System.IO.Path.GetFileNameWithoutExtension(file));
                }
            }



            // notify listeners
            if (FilterUpdate != null)
            {
                FilterUpdate(sender, new EventArgs());
            }
        }
コード例 #2
0
        /// <summary>
        /// upload todays tickdata to a portal
        /// </summary>
        /// <param name="space"></param>
        /// <param name="un"></param>
        /// <param name="pw"></param>
        /// <param name="ticket"></param>
        /// <param name="workpath"></param>
        /// <param name="debug"></param>
        /// <returns></returns>
        public static bool UploadTodaysTicks(string space, string un, string pw, int ticket, string workpath, DebugDelegate debug)
        {
            bool r = true;

            try
            {
                List <string> files = TikUtil.GetFilesFromDate();
                string        fn    = workpath + "\\TickData." + Util.ToTLDate() + ".zip";
                r &= ZipFile(fn, files, string.Empty, debug);
                if (TradeLink.AppKit.AssemblaDocument.Create(space, un, pw, fn, ticket, false))
                {
                    if (debug != null)
                    {
                        debug("tick data upload succeeded for: " + fn);
                    }
                }
                else
                {
                    if (debug != null)
                    {
                        r &= false;
                        debug("tick data upload failed for: " + fn);
                    }
                }
                if (System.IO.File.Exists(fn))
                {
                    try
                    {
                        System.IO.File.Delete(fn);
                    }
                    catch (Exception ex)
                    {
                        r &= false;
                        if (debug != null)
                        {
                            debug("unable to delete local copy: " + fn);
                            debug(ex.Message + ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                r &= false;
                if (debug != null)
                {
                    debug("unknown error uploading ticks. ");
                    debug(ex.Message + ex.StackTrace);
                }
            }
            return(r);
        }
コード例 #3
0
ファイル: Log.cs プロジェクト: michaelwills/tradelink
        string getfn(string path, string logname, bool dateinlogname)
        {
            string fn   = string.Empty;
            int    inst = -1;

            do
            {
                inst++;
                string inststring = inst < 0 ? string.Empty : "." + inst.ToString();
                fn = path + "\\" + logname + (dateinlogname ? "." + _date : "") + inststring + ".txt";
            } while (!TikUtil.IsFileWritetable(fn));
            return(fn);
        }
コード例 #4
0
        public bool ConvertFiles(DoubleDel progress)
        {
            bool ok  = true;
            int  c   = 1;
            int  max = Files.Length;

            // foreach file
            foreach (string fn in Files)
            {
                // read the file
                var csv = Util.getfile(fn, debug);
                // update progress
                progress((double)c++ / max);
                ok &= !string.IsNullOrWhiteSpace(csv);
                if (!ok)
                {
                    debug("Error reading: " + fn);
                    continue;
                }
                // parse data
                var data = Util.ParseCsvData(csv, debug);
                // convert it
                var ks = convert(data);
                ok &= ks.Count > 0;
                if (!ok)
                {
                    debug("No ticks converted in: " + fn);
                    continue;
                }
                // write to ticks
                ok &= TikUtil.TicksToFile(ks.ToArray(), debug);

                // update status
                if (!ok)
                {
                    debug("Error writing ticks to TIK file.");
                }
            }
            return(ok);
        }
コード例 #5
0
        private void _inputbut_Click(object sender, EventArgs e)
        {
            // make sure we only convert one group at a time
            if (bw.IsBusy)
            {
                debug("wait until conversion completes..."); return;
            }
            // see if we're converting from files or webservices
            switch (_conval)
            {
            // webservice list
            case Converter.EuronextDaily:
            case Converter.YahooDaily:
            case Converter.GoogleDaily:
                // reset progress
                progress(0);
                // get list of symbols from user
                string symi = Microsoft.VisualBasic.Interaction.InputBox("Enter list of symbols to pull from " + _conval.ToString() + Environment.NewLine + "(eg LVS,GOOG,GE)", "Enter symbol list", string.Empty, 0, 0);
                // remove spaces and capitalize
                symi = symi.Replace(" ", string.Empty).ToUpper();
                // parse
                string[] syms  = symi.Split(',');
                int      count = 0;
                foreach (string sym in syms)
                {
                    try
                    {
                        // get barlists for those symbols
                        BarList bl;
                        if (_conval == Converter.GoogleDaily)
                        {
                            bl = BarListImpl.DayFromGoogle(sym);
                        }
                        else if (_conval == Converter.YahooDaily)
                        {
                            bl = BarListImpl.DayFromYahoo(sym);
                        }
                        else if (_conval == Converter.EuronextDaily)
                        {
                            if (!System.Text.RegularExpressions.Regex.IsMatch(sym, "[A-Z0-9]{12}", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                            {
                                debug("\"" + sym + "\" is not a valid ISIN.  Euronext expects ISINs!");
                                continue;
                            }
                            bl = BarListImpl.DayFromEuronext(sym);
                        }
                        else
                        {
                            continue;
                        }
                        // convert to tick files
                        if (!TikUtil.TicksToFile(TikUtil.Barlist2Tick(bl), debug))
                        {
                            debug("Error saving downloaded bars.");
                        }
                        // notify
                        debug("downloaded " + bl.Count + " bars of daily data for " + sym + " from " + _conval.ToString());
                    }
                    catch (Exception ex)
                    {
                        debug(sym + " converter error: " + ex.Message + ex.StackTrace);
                    }
                    // update progress
                    progress((double)count++ / syms.Length);
                }
                debug("completed daily download.");
                // we're done
                return;
            }
            OpenFileDialog of = new OpenFileDialog();

            // allow selection of multiple inputs
            of.Multiselect = true;
            // keep track of bytes so we can approximate progress
            long bytes = 0;

            if (of.ShowDialog() == DialogResult.OK)
            {
                List <string> symbols = new List <string>();
                foreach (string file in of.FileNames)
                {
                    _path = Path.GetDirectoryName(file);
                    string sn = Path.GetFileName(file);
                    // get size of current file and append to total size
                    FileInfo fi = new FileInfo(file);
                    bytes += fi.Length;
                    string sym = string.Empty;
                    switch (_conval)
                    {
                    case Converter.QCollector_eSignal:
                        string [] r = Path.GetFileNameWithoutExtension(sn).Split('_');
                        if (r.Length != 2)
                        {
                            sym = Microsoft.VisualBasic.Interaction.InputBox("Symbol data represented by file: " + sn, "File's Symbol", string.Empty, 0, 0);
                        }
                        else
                        {
                            sym = r[0];
                        }
                        break;

                    default:
                        // guess symbol
                        string guess = Util.rxm(sn, "[^a-z]*([a-z]{1,6})[^a-z]+");
                        // remove extension
                        guess = Util.rxr(guess, "[.].*", string.Empty);
                        // see if it's a clean match, if not don't guess
                        if (!Util.rxmok(guess, "^[a-z]+$"))
                        {
                            guess = string.Empty;
                        }
                        sym = Microsoft.VisualBasic.Interaction.InputBox("Symbol data represented by file: " + sn, "File's Symbol", guess, 0, 0);
                        break;
                    }
                    if (sym != string.Empty)
                    {
                        symbols.Add(sym);
                    }
                }
                // estimate total ticks
                _approxtotal = (int)((double)bytes / 51);
                // reset progress bar
                progress(0);
                // start background thread to convert
                bw.RunWorkerAsync(new convargs(of.FileNames, symbols.ToArray()));
                debug("started conversion");
            }
        }