Esempio n. 1
0
        private void AddCommandExecute(object obj)
        {
            if (System.IO.Directory.Exists(FolderPath))
            {
                if (BuySellOnSignalSymbolConfigs == null)
                {
                    BuySellOnSignalSymbolConfigs = new ObservableCollection <BuySellOnSignalSymbolConfig>();
                }

                if (!BuySellOnSignalSymbolConfigs.Any(s => s.Exchange == SelectedExchange && s.Symbol == SelectedInstrument.TradingSymbol))
                {
                    Random r = new Random();
                    BuySellOnSignalSymbolConfig config = new BuySellOnSignalSymbolConfig()
                    {
                        Seperator         = ",",
                        SignalProfitType  = SignalProfitType,
                        StartTime         = StartTime,
                        TrailingStopLoss  = TrailingStopLoss,
                        ContractSize      = ContractSize,
                        TickProfit        = TickProfit,
                        Exchange          = SelectedExchange,
                        Symbol            = SelectedInstrument.TradingSymbol,
                        MaxLoss           = MaxLoss,
                        Extension         = SelectedFileFormat,
                        LotSize           = SelectedInstrument.LotSize,
                        MaxProfit         = MaxProfit,
                        MappedSymbolName  = MappedSymbolName,
                        DataDirectoryPath = FolderPath,
                        DataFileExtesnion = SelectedFileFormat,
                    };
                    string tradingSymbol = string.Format("{0}:{1}", config.Exchange, config.Symbol);
                    if (SelectedReversalConfig != null)
                    {
                        config.ReversalInfoes = SelectedReversalConfig.ReversalInfoes;
                    }
                    BuySellOnSignalSymbolConfigs.Add(config);
                    Events.RaiseAskForStockSubscriptionEvent(tradingSymbol, StockSubscribeMode.LTP, true);
                    _configuredStocksDictionary[tradingSymbol] = config;
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        MessageBox.Show(string.Format("Symbol '{0}' is already added to the list. Try adding different symbol!", SelectedInstrument.TradingSymbol), "Duplicate Stock", MessageBoxButton.OK, MessageBoxImage.Error);
                    });
                }
            }
            else
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    MessageBox.Show("Please enter valid director path.", "Invalid Folder Path", MessageBoxButton.OK, MessageBoxImage.Error);
                });
            }
        }
Esempio n. 2
0
 private void UpdateDayProfitLoss()
 {
     Application.Current.Dispatcher.InvokeAsync(() =>
     {
         var activeStockProfitLoss = BuySellOnSignalSymbolConfigs.Where(s => s.OpenPosition != 0).Sum(s => s.CurrentProfitLoss);
         if (GlobalProfitLossSetting == null)
         {
             return;
         }
         var dayProfitLoss = GlobalProfitLossSetting.InactiveDayProfitLoss + activeStockProfitLoss;
         if (dayProfitLoss != GlobalProfitLossSetting.CurrentProfitLoss)
         {
             GlobalProfitLossSetting.CurrentProfitLoss = dayProfitLoss;
             Events.RaiseDayProfitLossChanged(GlobalProfitLossSetting.CurrentProfitLoss);
         }
     });
 }
Esempio n. 3
0
        private void Events_PositionUpdateEvent(string tradingSymbol, Position position)
        {
            Application.Current.Dispatcher.InvokeAsync(() =>
            {
                if (BuySellOnSignalSymbolConfigs == null)
                {
                    return;
                }
                var stock = BuySellOnSignalSymbolConfigs.FirstOrDefault(s => string.Format("{0}:{1}", s.Exchange, s.Symbol) == tradingSymbol);

                if (stock != null && position.Product == "MIS" && position.Quantity != stock.NetQuantity)
                {
                    stock.CurrentProfitLoss = position.PNL;
                    stock.BuyValue          = position.BuyValue;
                    stock.SellValue         = position.SellValue;
                    stock.NetQuantity       = position.Quantity;
                    stock.Multiplier        = position.Multiplier;
                    stock.OpenPosition      = position.Quantity;
                }
            });
        }
Esempio n. 4
0
        private void Events_StatusChangedEvent(string exchange, string symbol, string status)
        {
            StrategyStockStatus strategyStatus = StrategyStockStatus.Added;

            if (BuySellOnSignalSymbolConfigs == null)
            {
                return;
            }
            var stock = BuySellOnSignalSymbolConfigs.FirstOrDefault(s => s.Exchange == exchange && symbol == s.Symbol);

            if (BuySellOnSignalSymbolConfigs != null && Enum.TryParse(status, out strategyStatus))
            {
                if (stock != null)
                {
                    stock.Status = strategyStatus;
                }
            }
            else if (stock != null)
            {
                stock.DebugStatus = status;
            }
        }