Exemplo n.º 1
0
        /// <summary>
        /// Button event that deletes a Watchlist.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDeleteList_Click(object sender, EventArgs e)
        {
            bool       success  = false;
            string     listName = radioLists.SelectedValue;
            IWatchList wl       = new WatchList();

            if (listName.Length > 0)
            {
                List <WatchListItem> items = wl.items.Where(x => x.ListName.Equals(listName)).ToList();
                foreach (WatchListItem w in items)
                {
                    wl.RemoveFromList(w.Symbol, w.ListName);
                }

                success = wlm.DeleteWatchList(listName);
                if (success)
                {
                    setStatus(String.Format("List \"{0}\" deleted successfully.", listName), true);
                }
                else
                {
                    setStatus(String.Format("List \"{0}\" could not be deleted.", listName), false);
                }
                updateList(true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Button event that removes an item from a Watchlist.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            bool   success  = false;
            string symbol   = ((Button)sender).Attributes["Symbol"];
            string listName = ((Button)sender).Attributes["ListName"];

            if (symbol.Length > 0 && listName.Length > 0)
            {
                IWatchList wl = new WatchList();
                success = wl.RemoveFromList(new Symbol(symbol), listName);

                if (success)
                {
                    setStatus(String.Format("{0} removed from list \"{1}.\"", symbol, listName), true);
                }

                //check if all instances of that symbol are removed before strategy stops watching it
                TraderContext db = new TraderContext();
                if (db.WatchListItems.Where(x => x.SymbolName.Equals(symbol)).Count() == 0 && db.Positions.Where(x => x.SymbolName.Equals(symbol) && x.status == AlgoTrader.Interfaces.positionStatus.Open).Count() == 0)
                {
                    strategy.stopWatching(symbol);
                }
            }
            updateList(true);
        }