Ejemplo n.º 1
0
        private void Events_OpenPositionsChangedEvent(string exchange, string symbol, int openPositions)
        {
            var stock = JobbingStocks.FirstOrDefault(s => s.Exchange == exchange && symbol == s.Symbol);

            if (stock != null)
            {
                stock.OpenPositionsCount = openPositions;
            }
        }
Ejemplo n.º 2
0
        private void Events_StockLastPriceChangeEvent(string exchange, string symbol, decimal lastPrice)
        {
            var stock = JobbingStocks.FirstOrDefault(s => s.Exchange == exchange && symbol == s.Symbol);

            if (stock != null)
            {
                stock.CurrentPrice = lastPrice;
            }
        }
Ejemplo n.º 3
0
        private void Events_TargetStopLossChangeEvent(string exchange, string symbol, decimal targetPrice, decimal stopLossPrice)
        {
            var stock = JobbingStocks.FirstOrDefault(s => s.Exchange == exchange && symbol == s.Symbol);

            if (stock != null)
            {
                stock.TargetPrice   = targetPrice;
                stock.StopLossPrice = stopLossPrice;
            }
        }
Ejemplo n.º 4
0
        private void Events_TargetStopLossHitEvent(string exchange, string symbol, int targetHitCount, int stopLossHitCount)
        {
            var stock = JobbingStocks.FirstOrDefault(s => s.Exchange == exchange && symbol == s.Symbol);

            if (stock != null)
            {
                stock.TargetHitCount   = targetHitCount;
                stock.StopLossHitCount = stopLossHitCount;
            }
        }
Ejemplo n.º 5
0
        private void Events_JobbingStatusChangedEvent(string exchange, string symbol, string status)
        {
            JobbingStatus jobbingStatus = JobbingStatus.NotStarted;

            if (Enum.TryParse(status, out jobbingStatus))
            {
                var stock = JobbingStocks.FirstOrDefault(s => s.Exchange == exchange && symbol == s.Symbol);
                if (stock != null)
                {
                    stock.Status = jobbingStatus;
                }
            }
        }
Ejemplo n.º 6
0
        public void AddStockForJobbing()
        {
            JobbingStockBase stock = Activator.CreateInstance(SelectedJobbingType.Value) as JobbingStockBase;

            stock.Exchange          = Exchange;
            stock.Symbol            = Symbol;
            stock.SaveDirectoryName = ConfigurationFileNames.JobbingStockDir;
            try
            {
                var ltp = KiteInstance.Kite.GetLTP(new string[] { string.Format("{0}:{1}", Exchange, Symbol) });
                stock.CurrentPrice = ltp.FirstOrDefault().Value.LastPrice;
                if (SelectedJobbingType.Value == typeof(StrongPullBackJobbing))
                {
                    (stock as StrongPullBackJobbing).PullBackPercentage = Convert.ToDouble(SelectedPullBackPercentage.Value);
                }
                else if (SelectedJobbingType.Value == typeof(PivotJobbing))
                {
                    (stock as PivotJobbing).PivotPrice        = stock.CurrentPrice;
                    (stock as PivotJobbing).IncrementalMethod = IncrementalMethod;
                    (stock as PivotJobbing).IncrementalNumber = IncrementalNumber;
                }
                stock.JobbingType = SelectedJobbingType.Key;
                switch (ProfitMarginType)
                {
                case ProfitMarginType.Percentage:
                    stock.Margin = stock.CurrentPrice.FindPercentagValue(Margin);
                    break;

                case ProfitMarginType.Absolute:
                    stock.Margin = Margin;
                    break;
                }
                JobbingStocks.Add(stock);
            }
            catch (Exception ex)
            {
            }
        }