Example #1
0
        public static void Run(string symbol)
        {
            Initialize(symbol);
            TicksFactory factory = CreateFactory(symbol);
            List <KeyValuePair <DateTime, double> > bids  = factory.Bids;
            List <KeyValuePair <DateTime, double> > asks  = factory.Asks;
            UnilateralTickCollection <DateTime>     ticks = new UnilateralTickCollection <DateTime>(asks);

            RunTest(bids, asks, ticks, ProcessSell);
            Save(symbol + " sell");
            ticks = new UnilateralTickCollection <DateTime>(bids);
            RunTest(bids, asks, ticks, ProcessBuy);
            Save(symbol + " buy");
        }
Example #2
0
        static TicksFactory CreateFactory(string symbol)
        {
            TicksFactory result = new TicksFactory();
            string       path   = Config.QuoteDirectory + "\\" + symbol;

            string[] files = Directory.GetFiles(path);
            foreach (var element in files)
            {
                if (element.Contains("2010"))
                {
                    result.LoadDukas(element);
                    Console.WriteLine("{0} has been loaded", element);
                }
            }
            Console.WriteLine("factory is preparing...");
            result.Prepare();
            Console.WriteLine("factory is prepared...");
            return(result);
        }
Example #3
0
        private static void Run(string path, StreamWriter stream)
        {
            Console.WriteLine(path);
            TicksFactory factory = new TicksFactory();

            factory.LoadDukas(path);
            factory.Prepare();
            List <KeyValuePair <DateTime, double> > bids = factory.Bids;
            List <KeyValuePair <DateTime, double> > asks = factory.Asks;
            int    count   = bids.Count;
            double average = 0;

            for (int index = 0; index < count; ++index)
            {
                average += (bids[index].Value + asks[index].Value) / 2;
            }
            average /= count;
            string name = Path.GetFileNameWithoutExtension(path);
            string st   = string.Format("{0} = {1}", name, average);

            stream.WriteLine(st);
        }
Example #4
0
        public TicksUnit()
        {
            TicksFactory factory = new TicksFactory();

            factory.Parse(Resources.Ticks, cPattern, 1, 2, 3);
            m_items = factory.Bids;
            m_items.Sort(Compare);
            m_from    = m_items[0].Key;
            m_to      = m_items[m_items.Count - 1].Key;
            m_ticks   = new UnilateralTickCollection <DateTime>(m_items);
            m_minimum = double.PositiveInfinity;
            m_maximum = double.NegativeInfinity;
            foreach (var element in m_items)
            {
                if (element.Value < m_minimum)
                {
                    m_minimum = element.Value;
                }
                if (element.Value > m_maximum)
                {
                    m_maximum = element.Value;
                }
            }
        }