Ejemplo n.º 1
0
        private void DecodeData()
        {
            TickTime TimeOrigin = Data.FirstKey;
            string   data       = Data[TimeOrigin];

            Data.Remove(TimeOrigin); //Remove data after reading

            string[] Packets = Asmodat.Abbreviate.String.ToList(data, "\r");


            if (Packets == null || Packets.Length <= 0)
            {
                return;
            }

            for (int i = 0; i < Packets.Length; i++)
            {
                string packet = Packets[i];
                TimeOrigin += i;

                if (System.String.IsNullOrEmpty(packet))
                {
                    continue;
                }

                List <Rate> Rates = this.DecodeRates(packet, ref TimeOrigin);

                if (Rates.Count <= 0)
                {
                    Rate Rate = this.ToRateOnChange(packet, ref TimeOrigin);

                    if (Rate != null && Rate.Token >= 0)
                    {
                        Rate.Pair = ForexConfiguration.OrderPair[Rate.Token];
                        Rate.ChartData.TickTime = TimeOrigin;
                        Rates.Add(Rate);
                    }
                    else
                    {
                        //"UP\\DEAL\\EUR/USD\\1000\\1000\\0\\0\\0\\256044115\\121334263\\1137.75\\1.13775000\\49040.82\\0\\"
                    }
                }

                if (ForexRates != null && ForexRates.Loaded)
                {
                    ForexRates.UpdateDataRates(Rates.ToArray());
                }

                ForexArchive.Update(ServiceConfiguration.TimeFrame.LIVE, Rates);
                ForexArchive.Updates += Rates.Count;
            }
        }
Ejemplo n.º 2
0
        public void DealClose(string confirmation, int tolerance, int expiration)
        {
            if (System.String.IsNullOrEmpty(confirmation))
            {
                return;
            }

            Deal deal = this.GetDealByConfirmationNumber(confirmation);


            if (deal == null)
            {
                return;
            }



            string product = deal.Product;


            if (!IsReady || !ForexConfiguration.ProductSettings.ContainsKey(product) || !ForexRates.Data.ContainsKey(product))
            {
                return;
            }

            ProductSetting Settings = ForexConfiguration.ProductSettings[product];
            Rate           rate     = ForexRates.GetRate(product);

            DealRequest DRequest = new DealRequest(expiration);

            DRequest.Product            = deal.Product;
            DRequest.Amount             = Math.Abs(int.Parse(deal.Contract)); //It can be negative if positionis short
            DRequest.ConfirmationNumber = deal.ConfirmationNumber;
            DRequest.DealSequence       = deal.DealSequence;
            DRequest.DealReference      = deal.DealReference;
            DRequest.Contract           = deal.Contract;
            DRequest.ASK       = rate.OFFER;
            DRequest.BID       = rate.BID;
            DRequest.BuySell   = deal.BuySell;// DRequest.Buy = !DRequest.Buy; //Reverse Order for closing purpouses
            DRequest.Buy       = !DRequest.Buy;
            DRequest.Close     = true;
            DRequest.Rate      = deal.Rate;
            DRequest.Tolerance = tolerance;

            this.Save(DRequest);
        }