コード例 #1
0
ファイル: BarFactory.cs プロジェクト: ssh352/omniquant-server
        internal bool AddReminder(BarFactoryItem item, DateTime dateTime, ClockType type)
        {
            bool created = false;
            SortedList <long, List <BarFactoryItem> > slistByBarSize;

            if (!this.reminderTable.TryGetValue(dateTime, out slistByBarSize))
            {
                slistByBarSize = new SortedList <long, List <BarFactoryItem> >();
                this.reminderTable.Add(dateTime, slistByBarSize);
                created = true;
            }

            List <BarFactoryItem> list;

            if (!slistByBarSize.TryGetValue(item.barSize, out list))
            {
                list = new List <BarFactoryItem>();
                slistByBarSize.Add(item.barSize, list);
            }

            list.Add(item);

            if (created)
            {
                var clock = type == ClockType.Exchange ? this.framework.ExchangeClock : this.framework.Clock;
                return(clock.AddReminder(OnReminder, dateTime));
            }
            return(true);
        }
コード例 #2
0
ファイル: BarFactory.cs プロジェクト: ssh352/omniquant-server
        public void Remove(BarFactoryItem item)
        {
            var list = ItemLists[item.Instrument.Id];

            if (list == null)
            {
                return;
            }

            var found =
                list.Find(x => x.barType == item.barType && x.barSize == item.barSize && x.barInput == item.barInput);

            if (found != null)
            {
                list.Remove(found);
            }
            else
            {
                Console.WriteLine($"{DateTime.Now} BarFactory::Remove Item '{item}' is already removed");
            }
        }
コード例 #3
0
ファイル: BarFactory.cs プロジェクト: ssh352/omniquant-server
        // The most important one of all 'Add's
        public void Add(BarFactoryItem item)
        {
            if (item.factory != null)
            {
                throw new InvalidOperationException("BarFactoryItem is already added to another BarFactory instance.");
            }

            item.factory = this;
            int id    = item.Instrument.Id;
            var items = ItemLists[id] = ItemLists[id] ?? new List <BarFactoryItem>();

            if (
                items.Exists(
                    match =>
                    item.barType == match.barType && item.barSize == match.barSize &&
                    item.barInput == match.barInput && item.providerId == match.providerId))
            {
                Console.WriteLine($"{DateTime.Now} BarFactory::Add Item '{item}' is already added");
            }
            else
            {
                items.Add(item);
            }
        }
コード例 #4
0
        internal bool AddReminder(BarFactoryItem item, DateTime dateTime, ClockType type)
        {
            bool created = false;
            SortedList<long, List<BarFactoryItem>> slistByBarSize;
            if (!this.reminderTable.TryGetValue(dateTime, out slistByBarSize))
            {
                slistByBarSize = new SortedList<long, List<BarFactoryItem>>();
                this.reminderTable.Add(dateTime, slistByBarSize);
                created = true;
            }

            List<BarFactoryItem> list;
            if (!slistByBarSize.TryGetValue(item.barSize, out list))
            {
                list = new List<BarFactoryItem>();
                slistByBarSize.Add(item.barSize, list);
            }

            list.Add(item);

            if (created)
            {
                var clock = type == ClockType.Exchange ? this.framework.ExchangeClock : this.framework.Clock;
                return clock.AddReminder(OnReminder, dateTime);
            }
            return true;
        }
コード例 #5
0
        public void Remove(BarFactoryItem item)
        {
            var list = ItemLists[item.Instrument.Id];
            if (list == null)
                return;

            var found =
                list.Find(x => x.barType == item.barType && x.barSize == item.barSize && x.barInput == item.barInput);
            if (found != null)
                list.Remove(found);
            else
                Console.WriteLine($"{DateTime.Now} BarFactory::Remove Item '{item}' is already removed");
        }
コード例 #6
0
        // The most important one of all 'Add's
        public void Add(BarFactoryItem item)
        {
            if (item.factory != null)
                throw new InvalidOperationException("BarFactoryItem is already added to another BarFactory instance.");

            item.factory = this;
            int id = item.Instrument.Id;
            var items = ItemLists[id] = ItemLists[id] ?? new List<BarFactoryItem>();
            if (
                items.Exists(
                    match =>
                        item.barType == match.barType && item.barSize == match.barSize &&
                        item.barInput == match.barInput && item.providerId == match.providerId))
                Console.WriteLine($"{DateTime.Now} BarFactory::Add Item '{item}' is already added");
            else
                items.Add(item);
        }