public bool AddSymbol(string name, float timeframe, out SymbolInAction symbol)
 {
     symbol = SymbolInActions.FirstOrDefault(x => x.Name == name && x.TimeFrame == timeframe);
     if (symbol == null || (symbol != null && symbol.IsDirty))
     {
         if (symbol != null)
         {
             symbol.RefreshScripts();
             symbol.IsDirty = false;
         }
         else
         {
             symbol = new SymbolInAction(name, timeframe);
             SymbolInAction tmp = symbol;
             Dispatcher.FromThread(OrderManager.UIThread).Invoke(() =>
             {
                 SymbolInActions.Add(tmp);
             });
             foreach (IController controller in Controllers)
             {
                 if (controller.IsConnected)
                 {
                     symbol.FillInSymbolDefinition(controller);
                     symbol.FillInContractDetails(controller);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
 public void RemoveSymbol(SymbolInAction symbol)
 {
     Dispatcher.FromThread(OrderManager.UIThread).Invoke(() =>
     {
         SymbolInActions.Remove(symbol);
     });
 }
Exemple #3
0
        private void before_mc_loaded(object sender)
        {
            var            mc     = sender as MultiSelectComboBox;
            MainViewModel  vm     = (MainViewModel)this.DataContext;
            SymbolInAction symbol = null;
            var            si     = vm.SelectedItem;

            if (si.GetType() == typeof(Script))
            {
                symbol = ((Script)si).Symbol;
            }
            else if (si.GetType() == typeof(Strategy))
            {
                symbol = ((Strategy)si).Script.Symbol;
            }
            mc.ItemsSource = symbol.AccountCandidates;
        }
Exemple #4
0
 private static void EnableExecution(ItemsControl control, bool enable = true)
 {
     foreach (object item in control.Items)
     {
         SymbolInAction symbol = item as SymbolInAction;
         if (symbol != null)
         {
             symbol.IsEnabled = enable;
             foreach (var script in symbol.Scripts)
             {
                 script.IsEnabled = symbol.IsEnabled;
                 foreach (var strategy in script.Strategies)
                 {
                     strategy.IsEnabled = symbol.IsEnabled;
                 }
             }
         }
     }
 }