Ejemplo n.º 1
0
        void OnReceiveQuotes(object sender, EventHandler.OpenAPI.Quotes e)
        {
            if (strategy && e.Total.Equals(string.Empty) == false && int.Parse(e.Time) < 154359)
            {
                bool accumulate = e.Price[4] == Sell && e.Price[5] == Buy;
                var  temp       = e.Total.Split(';');

                if (api.OnReceiveBalance && api.WindingClass.Equals(string.Empty) == false)
                {
                    SendNewOrder(e.Price, api.WindingClass);
                }

                if (api.OnReceiveBalance && api.Classification.Equals(string.Empty) == false)
                {
                    SendNewOrder(e.Price, api.Classification);
                }

                if (api.OnReceiveBalance && accumulate)
                {
                    if (e.Price[4] == Sell && e.Price[5] == Buy)
                    {
                        OnDetermineTheTrend(AccumulateSell += int.Parse(temp[0]), AccumulateBuy += int.Parse(temp[1]), e.Price[4], e.Price[5]);
                    }

                    else if (Sell > e.Price[4] || Buy > e.Price[5])
                    {
                        OnDetermineTheTrend(1, 0, e.Price[4], e.Price[5]);
                    }

                    else if (Sell < e.Price[4] || Buy < e.Price[5])
                    {
                        OnDetermineTheTrend(0, 1, e.Price[4], e.Price[5]);
                    }
                }
                if (accumulate == false)
                {
                    AccumulateSell = 0;
                    AccumulateBuy  = 0;
                    Sell           = e.Price[4];
                    Buy            = e.Price[5];
                }
                if (int.Parse(e.Time) > 154259 && api.Trend.Count > 0)
                {
                    int over = 0;

                    foreach (var kv in api.Trend)
                    {
                        over += kv.Value.Contains("-") ? -1 : 1;
                    }

                    api.Trend.Clear();

                    if (over != 0)
                    {
                        SendRollOverOrder(over);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void OnReceiveQuotes(object sender, EventHandler.OpenAPI.Quotes e)
        {
            BeginInvoke(new Action(() =>
            {
                var time = DateTime.ParseExact(e.Time, "HHmmss", null).ToString("HH : mm : ss");

                if (quotes10.Text.Equals(time) == false)
                {
                    quotes10.Text = time;
                }

                for (int i = 0; i < e.Price.Length; i++)
                {
                    var temp      = string.Concat("quotes", i).FindByName <Label>(this);
                    var param     = e.Price[i].ToString("N2");
                    var temporary = string.Concat("order", i).FindByName <Label>(this);

                    if (temp.Text.Equals(param) == false)
                    {
                        temp.Text = param;
                    }

                    if (e.SellOrder != null && i < 5 && e.SellOrder.ContainsValue(e.Price[i]))
                    {
                        var number = int.Parse(e.SellOrder.First(o => o.Value == e.Price[i]).Key).ToString();

                        if (temporary.Text.Equals(number))
                        {
                            continue;
                        }

                        temporary.Text = number;
                    }
                    else if (e.BuyOrder != null && i > 4 && e.BuyOrder.ContainsValue(e.Price[i]))
                    {
                        var number = int.Parse(e.BuyOrder.First(o => o.Value == e.Price[i]).Key).ToString();

                        if (temporary.Text.Equals(number))
                        {
                            continue;
                        }

                        temporary.Text = number;
                    }
                    else
                    {
                        temporary.Text = string.Empty;
                    }
                }
                Application.DoEvents();
            }));
        }