예제 #1
0
        private void buttonSetStopLoss_Click(object sender, EventArgs e)
        {
            // buttonSetStopLoss.Focus();
            //bool setStopLoss = false;
            //if (stock.NoOfShares > 0 && stock.StopLoss.Value != Stop.numericUpDownValue.Value
            //  || stock.StopLoss.NoOfShares != (int)Stop.numericUpDownNoOfShares.Value
            //  || (!stock.Trade && checkBoxDayTrade.Checked))//trade check flipped
            //{
            //  setStopLoss = true;
            //buttonCancelPendingOrders_Click(null, null);
            //}


            //stock.StopLoss.Value = Stop.numericUpDownValue.Value;
            //stock.StopLoss.Type = (PricePointControl.OrderType)Stop.comboBoxOrderType.SelectedValue;
            //stock.StopLoss.Execution = (PricePointControl.Execution)Stop.comboBoxExecution.SelectedValue;
            //stock.StopLoss.FollowPrice = (PricePointControl.FollowPrice)Stop.toFollowComboBox.SelectedValue;
            //stock.StopLoss.Trigger = (TriggerType)Stop.triggerComboBox.SelectedValue;
            //stock.StopLoss.NoOfShares = (int)Stop.numericUpDownNoOfShares.Value;
            stock.StopLoss = Stop.Get();
            if (stock.StopLoss.Price > 0)
            {
                if (stock.StopLoss.NoOfShares > 0)
                {
                    //  MessageBox.Show("Enter No of Shares to sell when Price reaches Stop Loss Price.");
                    //  return;
                    //}

                    //Set Stop loss if not already set
                    //if (setStopLoss)
                    //{
                    //Robinhood.Init();
                    //Robinhood.PlaceOrder(stock.Ticker, stock.StopLoss, TimeInForce.GoodTillCancel);
                    ThreadPool.QueueUserWorkItem(PlaceStop, stock);
                    //MainForm.PlaceOrder(stock.Ticker, stock.StopLoss, TimeInForce.GoodTillCancel);
                    //}
                }
            }
        }
예제 #2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            stock.Ticker = textBoxTicker.Text;
            if (string.IsNullOrEmpty(stock.Ticker))
            {
                MessageBox.Show("Must Enter a Valid Ticker.");
                return;
            }

            //stock.PriceTarget.Value = PriceTarget.numericUpDownValue.Value;
            //stock.PriceTarget.TrailPrcntg = PriceTarget.trailPrcntgNumericUpDown.Value;
            //stock.PriceTarget.Type = (PricePointControl.OrderType)PriceTarget.comboBoxOrderType.SelectedValue;
            //stock.PriceTarget.Execution = (PricePointControl.Execution)PriceTarget.comboBoxExecution.SelectedValue;
            //stock.PriceTarget.Trigger = (TriggerType)PriceTarget.triggerComboBox.SelectedValue;
            //stock.PriceTarget.FollowPrice = (PricePointControl.FollowPrice)PriceTarget.toFollowComboBox.SelectedValue;
            //stock.PriceTarget.NoOfShares = (int)PriceTarget.numericUpDownNoOfShares.Value;
            stock.PriceTarget = PriceTarget.Get();
            //if (stock.PriceTarget.Value > 0 && stock.PriceTarget.NoOfShares == 0)
            //{
            //  MessageBox.Show("Enter No of Shares to sell when Price reaches Price Target.");
            //  return;
            //}


            //stock.Entry.Type = (PricePointControl.OrderType)Entry.comboBoxOrderType.SelectedValue;
            //stock.Entry.Execution = (PricePointControl.Execution)Entry.comboBoxExecution.SelectedValue;
            //stock.Entry.Trigger = (TriggerType)Entry.triggerComboBox.SelectedValue;
            //stock.Entry.FollowPrice = (PricePointControl.FollowPrice)Entry.toFollowComboBox.SelectedValue;
            //stock.Entry.NoOfShares = (int)Entry.numericUpDownNoOfShares.Value;
            //stock.Entry.Value = Entry.numericUpDownValue.Value;
            //stock.Entry.TrailPrcntg = Entry.trailPrcntgNumericUpDown.Value;
            stock.Entry = Entry.Get();
            //if (stock.Entry.Value > 0 && stock.Entry.NoOfShares == 0)
            //{
            //  MessageBox.Show("Enter No of Shares to but when Price reaches Entry Price.");
            //  return;
            //}

            //stock.StopLoss.Value = Stop.numericUpDownValue.Value;
            //stock.StopLoss.TrailPrcntg = Stop.trailPrcntgNumericUpDown.Value;
            //stock.StopLoss.Type = (PricePointControl.OrderType)Stop.comboBoxOrderType.SelectedValue;
            //stock.StopLoss.Execution = (PricePointControl.Execution)Stop.comboBoxExecution.SelectedValue;
            //stock.StopLoss.Trigger = (TriggerType)Stop.triggerComboBox.SelectedValue;
            //stock.StopLoss.FollowPrice = (PricePointControl.FollowPrice)Stop.toFollowComboBox.SelectedValue;
            //stock.StopLoss.NoOfShares = (int)Stop.numericUpDownNoOfShares.Value;
            stock.StopLoss = Stop.Get();
            //if (stock.StopLoss.Value > 0)
            //{
            //  if (stock.StopLoss.NoOfShares == 0)
            //  {
            //    MessageBox.Show("Enter No of Shares to sell when Price reaches Stop Loss Price.");
            //    return;
            //  }

            //  ////Set Stop loss if not already set
            //  //if (setStopLoss)
            //  //{
            //  //  //Robinhood.Init();
            //  //  //Robinhood.PlaceOrder(stock.Ticker, stock.StopLoss, TimeInForce.GoodTillCancel);
            //  //  stock.StopLoss.NoOfShares *= -1;
            //  //  if(stock.Trade)
            //  //    ThreadPool.QueueUserWorkItem(PlaceStop,stock);
            //  //  //MainForm.PlaceOrder(stock.Ticker, stock.StopLoss, TimeInForce.GoodTillCancel);
            //  //}
            //}

            stock.DayTrade     = checkBoxDayTrade.Checked;
            stock.ManageTrade  = checkManageTrade.Checked;
            stock.NoOfShares   = (int)NoOfShares.Value;
            stock.CostBasis    = CostBasis.Value;
            stock.Volatility   = Volatility.Value;
            stock.MaxLoss      = MaxLossAmnt.Value;
            stock.MaxPrctgLoss = Math.Round(MaxLossPrcntg.Value, 2);
            save = true;
            this.Close();
        }
예제 #3
0
        /// <summary>
        /// Gets the map stop.
        /// </summary>
        /// <param name="lat">The lat.</param>
        /// <param name="lng">The LNG.</param>
        /// <param name="locationRadius">The location radius.</param>
        /// <param name="interval">The interval.</param>
        /// <returns></returns>
        public static IEnumerable <MapStopEntity> GetMapStop(float lat, float lng, int locationRadius, int interval = 30)
        {
            var list = new List <MapStopEntity>();

            using (var estimateTime = new EstimateTime())
            {
                try
                {
                    estimateTime.Load(interval);
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            var stops  = Stop.Get(lat, lng, locationRadius);
            var routes = Route.Get(stops.Select(x => x.RouteId).Distinct().ToArray());

            foreach (var stop in stops)
            {
                var isNew  = false;
                var entity = list.FirstOrDefault(x => x.Id == stop.StopLocationId);
                if (entity == null)
                {
                    entity = new MapStopEntity
                    {
                        Id        = stop.StopLocationId,
                        Name      = stop.Name,
                        NameEn    = stop.NameEn,
                        Latitude  = stop.Latitude,
                        Longitude = stop.Longitude,
                        Routes    = new List <MapStopRouteEntity>(),
                    };
                    isNew = true;
                }

                var route = routes.FirstOrDefault(x => x.Id == stop.RouteId);

                if (route != null)
                {
                    var routeEntity = new MapStopRouteEntity
                    {
                        Id           = route.Id,
                        ProviderName = route.ProviderName,
                        Name         = route.PathAttributeName,
                        NameEn       = route.PathAttributeNameEn,
                        Estimate     = EstimateTime.Get(route.Id, stop.Id)
                    };

                    entity.Routes.Add(routeEntity);
                }

                if (isNew)
                {
                    list.Add(entity);
                }
            }

            return(list);
        }