Esempio n. 1
0
        private async void DeleteStrategy(Strategy strategy)
        {
            if (strategy == null) return;

            int tradesCount = Context.Trades.Count(x => x.StrategyID == strategy.ID);

            if (tradesCount > 0)
            {
                await DialogService.ShowMessageAsync(Parent, 
                    "Cannot delete", string.Format("Can't delete this strategy, it still has {0} trades in it.", tradesCount));
                return;
            }

            MessageDialogResult result = await DialogService.ShowMessageAsync(Parent,
                "Delete strategy",
                String.Format("Are you sure you want to delete {0}?", strategy.Name),
                MessageDialogStyle.AffirmativeAndNegative);

            if (result == MessageDialogResult.Affirmative)
            {
                Context.Strategies.Remove(strategy);
                Context.SaveChanges();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Set a trade's strategy.
        /// </summary>
        protected void SetStrategy(Trade trade, Strategy strategy)
        {
            trade.Strategy = strategy;

            Logger.Log(LogLevel.Info, "User script {0} set strategy of trade {1} to {2}", this.GetType().Name, trade, strategy);
        }