Esempio n. 1
0
        /// <summary>
        /// Updates the given weekday of the Week with the new information found in 'day'.
        /// </summary>
        /// <param name="day">A day instance to update the week with - the old one is completely overridden.</param>
        public void UpdateDay(Weekday day)
        {
            var wd = Weekdays.FirstOrDefault(d => d.Day == day.Day);

            if (wd == null)
            {
                Weekdays.Add(day);
            }
            else
            {
                wd.Activities = day.Activities;
            }
        }
Esempio n. 2
0
        private MainViewModel()
        {
            Controllers = new ObservableCollection <IController>();
            MessageList = new ObservableCollection <Message>();
            LogList     = new ObservableCollection <Log>();

            Orders = new ObservableCollectionEx <DisplayedOrder>();
            Orders.CollectionChanged += Orders_CollectionChanged;
            ((INotifyPropertyChanged)Orders).PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Status")
                {
                    poViewSource.View.Refresh();
                    execViewSource.View.Refresh();
                }
            };

            SymbolInActions = new ObservableCollection <SymbolInAction>();

            poViewSource         = new CollectionViewSource();
            poViewSource.Source  = Orders;
            poViewSource.Filter += PendingOrders_Filter;
            PendingOrdersView    = poViewSource.View;

            execViewSource         = new CollectionViewSource();
            execViewSource.Source  = Orders;
            execViewSource.Filter += Execution_Filter;
            ExecutionView          = execViewSource.View;

            // retrieving the settings
            ReadSettings();
            ReadAccountAlias();

            // reading all order types
            var types = typeof(IBOrderType).Assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(IBOrderType)));

            foreach (var t in types)
            {
                AllIBOrderTypes.Add((IBOrderType)Activator.CreateInstance(t));
            }
            types = typeof(FTOrderType).Assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(FTOrderType)));
            foreach (var t in types)
            {
                AllFTOrderTypes.Add((FTOrderType)Activator.CreateInstance(t));
            }
            //VendorOrderTypes.Add("Order Types for IB", AllIBOrderTypes);
            //VendorOrderTypes.Add("Order Types for FT", AllFTOrderTypes);
            VendorOrderTypes.Add(new VendorOrderType {
                Name = "Order Types for Interative Broker", OrderTypes = AllIBOrderTypes
            });
            VendorOrderTypes.Add(new VendorOrderType {
                Name = "Order Types for FuTu NiuNiu", OrderTypes = AllFTOrderTypes
            });


            TimeZones.Add(new TimeZone {
                Id = "HKT", TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"), Description = "China Standar Time"
            });
            TimeZones.Add(new TimeZone {
                Id = "EST", TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"), Description = "Eastern Standard Time (North America)"
            });
            //TimeZones.Add(new TimeZone { Id = "CDT", TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Central Daylight Time"), Description = "Eastern Standard Time (North America)" });

            Weekdays.Add(new WeekDay {
                Value = 0, Name = "Sun"
            });
            Weekdays.Add(new WeekDay {
                Value = 1, Name = "Mon"
            });
            Weekdays.Add(new WeekDay {
                Value = 2, Name = "Tue"
            });
            Weekdays.Add(new WeekDay {
                Value = 3, Name = "Wed"
            });
            Weekdays.Add(new WeekDay {
                Value = 4, Name = "Thu"
            });
            Weekdays.Add(new WeekDay {
                Value = 5, Name = "Fri"
            });
            Weekdays.Add(new WeekDay {
                Value = 6, Name = "Sat"
            });

            StopLossSource.Add("In Points/Dollars");
            StopLossSource.Add("In Ticks");
            StopLossSource.Add("In Percentage");
            StopLossSource.Add("From AFL script");
            //
            _hub.Subscribe <IController>(OnControllerConnected);
        }