示例#1
0
 public Simulation(ref OpenRatesBlotter ORBlotter, ref OpenSettingsBlotter OSBlotter, ref Archive ARCHIVE, ref Account ACCOUNT, ref DataBase DATABASE)
 {
     ANALYSIS       = new Analysis(ref ARCHIVE, ref ACCOUNT);
     this.ARCHIVE   = ARCHIVE;
     this.OSBlotter = OSBlotter;
     this.ORBlotter = ORBlotter;
     this.ACCOUNT   = ACCOUNT;
     this.DATABASE  = DATABASE;
 }
示例#2
0
        public bool AlternateProduct(OpenRatesBlotter ORBlotter, TimeFrame TFrame, int count, string product, ref int shift, ref int shiftAlternative, int maxShift, ref string alternative, ref string counterAlternative)
        {
            List <string> LSProd      = ARCHIVE.GetProducts();
            int           iLCPCount   = ARCHIVE.GetDATACount(TFrame, product);
            int           iLastPoints = count;
            int           iStartIdx   = iLCPCount - iLastPoints;
            Rates         RATE        = ORBlotter.Get(product);
            int           iDecimals   = RATE.Decimals;

            double dBestCompare  = double.MinValue;
            double dWorstCompare = double.MaxValue;

            alternative = counterAlternative = "";

            foreach (string sP in LSProd)
            {
                if (sP == product)
                {
                    continue;
                }

                Rates RATESecond      = ORBlotter.Get(sP);
                int   iDecimalsSecond = RATESecond.Decimals;

                int iLCPCountSecondary         = ARCHIVE.GetDATACount(TFrame, sP);
                List <ChartPoint> LCPPrimary   = ARCHIVE.GetDATA(TFrame, product, iStartIdx, iLastPoints);
                List <ChartPoint> LCPSecondary = ARCHIVE.GetDATA(TFrame, sP, iLCPCountSecondary - iLastPoints, iLastPoints);
                int iShift = 0;

                double dCompaison = this.CompareCharts(LCPPrimary, LCPSecondary, iDecimals, iDecimalsSecond, maxShift, ref iShift);

                if (dCompaison > dBestCompare)
                {
                    dBestCompare = dCompaison;
                    alternative  = sP;
                    shift        = iShift;
                }

                if (dCompaison < dWorstCompare)
                {
                    dWorstCompare      = dCompaison;
                    counterAlternative = sP;
                    shiftAlternative   = iShift;
                }
            }


            if (shift != 0 || alternative == "" || counterAlternative == "")
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#3
0
        public void Update(OpenRatesBlotter ORBlotter)
        {
            List <Rates> LRATES = ORBlotter.GetData;
            int          count  = LRATES.Count;

            DATA.Clear();

            for (int i = 0; i < count; i++)
            {
                DATA.Add(LRATES[i].CCY_Pair, CEDC_Configuration.GetProductSetting(TOKEN, LRATES[i].CCY_Pair));
            }
        }
示例#4
0
        public AutoTreader(ref Archive ARCHIVE, ref OpenRatesBlotter ORBlotter, ref OpenDealsBlotter ODBlotter, ref OpenSettingsBlotter OSBlotter, ref Account ACCOUNT)
        {
            this.ARCHIVE   = ARCHIVE;
            this.ODBlotter = ODBlotter;
            this.ORBlotter = ORBlotter;
            this.OSBlotter = OSBlotter;
            this.ACCOUNT   = ACCOUNT;
            this.ANALYSIS  = new Analysis(ref ARCHIVE, ref ACCOUNT);

            foreach (TimeFrame TFrame in ARCHIVE.LTFrames)
            {
                DATA.Add(TFrame, new ConcurrentDictionary <string, ChartPointPredition>());
            }
        }
示例#5
0
        public Form1()
        {
            DATABASE = new DataBase(USERID);

            ACCOUNT = DATABASE.Load_Account(USERID);
            if (ACCOUNT == null)
            {
                ACCOUNT = new Account();
            }

            CEDA_Authentyficator.ApplicationName = APPNAME;
            CEDA_Authentyficator.IPAddress       = "demorates.efxnow.com";// "87.205.102.39";
            CEDA_Authentyficator.Language        = "English";
            CEDA_Authentyficator.MachineName     = "EUROCOM";


            this.StartConnection();



            InitializeComponent();



            PSBlotter = new ProductsSettingsBlotter(TOKEN);
            ODBlotter = new OpenDealsBlotter(TOKEN, USERID);
            ORBlotter = new OpenRatesBlotter();


            this.SendString(TOKEN + "\r");
            this.UpdateDeals();
            this.UpdateAccount();



            TimrStartup.Enabled = true;
        }
示例#6
0
        public List <string> GetLiquids(List <string> LSProducts, OpenRatesBlotter ORBlotter, double minPercentage, int deep, double spreadFactor, TimeFrame TFrame)
        {
            List <string> LSLiquidProducts = new List <string>();

            foreach (string product in ARCHIVE.GetProducts())
            {
                Rates             RATE          = ORBlotter.Get(product);
                int               iMinutesFrame = ABBREVIATIONS.ToMinutes(TFrame);
                List <ChartPoint> LCPoints      = ARCHIVE.GetDATA(TFrame, product);


                DateTime DTLast100 = ABBREVIATIONS.GreenwichMeanTime.AddMinutes(-deep * iMinutesFrame);

                List <ChartPoint> LCPLast100 = (from CP in LCPoints where CP.Time > DTLast100 select CP).ToList();

                if (this.LiquidPercentage(LCPLast100, RATE, spreadFactor) > minPercentage)
                {
                    LSLiquidProducts.Add(product);
                }
            }


            return(LSLiquidProducts);
        }
示例#7
0
        public bool Rates(List <string> SLDecodedData, ref OpenRatesBlotter ORBlotter)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
            bool ResponseRecived = false;

            int  count       = SLDecodedData.Count;
            int  KEY         = -1;
            bool BlockFound  = false;
            bool UpdateFound = false;
            int  position    = -1;

            int i;

            for (i = 0; i < count; i++)
            {
                string PART   = SLDecodedData[i];
                int    length = PART.Length;
                BlockFound  = false;
                UpdateFound = false;

                if (PART.Contains("BUP") || PART.Contains("DEAL") || PART.Contains("ORD"))
                {
                }


                if ((position = PART.IndexOf("\r")) >= 0)
                {
                    PART            = PART.Substring(position + 1, length - (position + 1));
                    length          = PART.Length;
                    ResponseRecived = true;
                }



                if (length == 0)
                {
                    continue;
                }

                if (!(PART.Contains("/") && length == 7) && (PART[0] == 'S' || PART[0] == '$' || PART[0] == 'R')) //Delimiters !PART.Contains("/") &&
                {
                    string SUB       = PART.Substring(1, length - 1);
                    int    CCY_Token = int.Parse(SUB);

                    if (PART.Contains("R"))
                    {
                        UpdateFound = true;
                    }
                    else
                    {
                        BlockFound = true;
                    }

                    KEY = CCY_Token;
                }


                if (BlockFound)
                {
                    if (SLDecodedData.Count <= (i + 9))
                    {
                        break;
                    }

                    Rates RATE = new AsmodatForexEngineAPI.Rates();

                    RATE.CCY_Token = KEY;
                    RATE.CCY_Pair  = SLDecodedData[i + 1];
                    RATE.BID       = double.Parse(SLDecodedData[i + 2]);
                    RATE.ASK       = double.Parse(SLDecodedData[i + 3]);
                    RATE.HIGH      = double.Parse(SLDecodedData[i + 4]);
                    RATE.LOW       = double.Parse(SLDecodedData[i + 5]);
                    RATE.Dealable  = false;
                    RATE.American  = false;
                    if (SLDecodedData[i + 6] == "D")
                    {
                        RATE.Dealable = true;
                    }
                    if (SLDecodedData[i + 7] == "A")
                    {
                        RATE.American = true;
                    }
                    RATE.Decimals = int.Parse(SLDecodedData[i + 8]);
                    RATE.CLOSE    = double.Parse(SLDecodedData[i + 9]);

                    ORBlotter.Add(RATE);

                    i += 9;
                }
                else if (UpdateFound)
                {
                    if (SLDecodedData.Count <= (i + 4))
                    {
                        break;
                    }

                    double BID      = double.Parse(SLDecodedData[i + 1]);
                    double ASK      = double.Parse(SLDecodedData[i + 2]);
                    bool   Dealable = false;
                    if (SLDecodedData[i + 3] == "D")
                    {
                        Dealable = true;
                    }
                    DateTime Time;
                    try
                    {
                        Time = DateTime.ParseExact(SLDecodedData[i + 4], "MM/dd/yyyy HH:mm:ss", null);// "02/06/2014 11:39:01"
                    }
                    catch
                    {
                        try
                        {
                            Time = DateTime.ParseExact(SLDecodedData[i + 9], "MM/dd/yyyy HH:mm:ss", null);// "02/06/2014 11:39:01"
                        }
                        catch
                        {
                            i += 1;
                            break;
                        }
                    }

                    Rates RATE = ORBlotter.Get(KEY);

                    RATE.BID      = BID;
                    RATE.ASK      = ASK;
                    RATE.Dealable = Dealable;
                    RATE.Time     = Time;

                    ORBlotter.Add(RATE);

                    i += 4;
                }
            }

            return(ResponseRecived);
        }