Esempio n. 1
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine(
                    "Usage: dxf_instrument_profile_live_sample <host:port>[update=<time-period>]\n" +
                    "where\n" +
                    "    host:port   - The valid host and port to download instruments (https://tools.dxfeed.com/ipf)\n" +
                    "    time-period - The update period in ISO8601 duration format (optional)\n\n" +
                    "examples: " +
                    "    dxf_instrument_profile_live_sample https://tools.dxfeed.com/ipf[update=P30S]\n" +
                    "    dxf_instrument_profile_live_sample https://user:[email protected]/ipf[update=P30S]\n"
                    );
                return;
            }

            var path = args[0];

            try {
                var connection = new InstrumentProfileConnection(path);
                connection.OnError += OnErrorHandler;
                var updateListener = new UpdateListener();
                connection.AddUpdateListener(updateListener);
                connection.Start();

                Console.WriteLine("Press enter to stop");
                Console.ReadLine();

                connection.Close();
            } catch (Exception exc) {
                Console.WriteLine($"Exception occured: {exc}");
            }
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine(
                    "Usage: " +
                    "    dxf_instrument_profile_live_sample <ipf-url>[update=<time-period>] [<token>]\n" +
                    "where\n" +
                    "    ipf-url     - The valid url to download instruments (https://tools.dxfeed.com/ipf)\n" +
                    "    time-period - The update period in ISO8601 duration format (optional, non-live connection)\n" +
                    "    token       - The bearer token\n" +
                    "\n" +
                    "Non-live connection (periodical GET requests) examples: " +
                    "    dxf_instrument_profile_live_sample https://tools.dxfeed.com/ipf[update=P30S]\n" +
                    "    dxf_instrument_profile_live_sample https://tools.dxfeed.com/ipf[update=P30S] Z2V0LmR4ZmVlZCxhbW...\n" +
                    "    dxf_instrument_profile_live_sample https://user:[email protected]/ipf[update=P30S]\n" +
                    "Live connection examples (with 'live=true' query parameter): " +
                    "    dxf_instrument_profile_live_sample https://tools.dxfeed.com/ipf?TYPE=STOCK\n" +
                    "    dxf_instrument_profile_live_sample https://tools.dxfeed.com/ipf?TYPE=OPTION&UNDERLYING=AAPL,IBM Z2V0LmR4ZmVlZCxhbW...\n" +
                    "    dxf_instrument_profile_live_sample https://user:[email protected]/ipf\n\n"
                    );
                return;
            }

            var    path  = args[0];
            string token = null;

            if (args.Length > 1)
            {
                token = args[1];
            }

            try
            {
                var connection = string.IsNullOrEmpty(token)
                    ? new InstrumentProfileConnection(path)
                    : new InstrumentProfileConnection(path, token);
                connection.OnError += OnErrorHandler;
                var updateListener = new UpdateListener();
                connection.AddUpdateListener(updateListener);
                connection.Start();

                Console.WriteLine("Press enter to stop");
                Console.ReadLine();

                connection.Close();
            }
            catch (Exception exc)
            {
                Console.WriteLine($"Exception occured: {exc}");
            }
        }