Exemplo n.º 1
0
        private decimal m_vixDiscount;                                  // VIX.XO - @VX (front month)

        public PricesConsole(string ip, int port, bool publish = false)
        {
            m_es = "@ESH18";                                                // front-month ES symbol

            // Populate the VX and Contango month strings
            m_vxMonth[0] = "H18";                                           // front-month @VX ("mYY" only, not full symbol)
            for (int i = 1; i < MONTH_COUNT; ++i)
            {
                m_vxMonth[i] = GDate.AddMonths(m_vxMonth[i - 1], 1);
                m_contangoMonth[i - 1] = m_vxMonth[i - 1] + m_vxMonth[i];
            }

            //m_pubsub = new RedisIQFeed(ip, port);
            m_pubsub = new ZmqIQFeed();
            m_pubsub.StartPriceSubscriber(ip, port);
            m_pubsub.OnSubscriberReceive += M_subscriber_Receive;

            //m_publisher = new ZMQPublisher();
            //m_subscriber = new ZMQSubscriber();
            //m_subscriberClientTask = Task.Factory.StartNew(() => m_subscriber.SubscriptionLoop());

            Task.Run(() => DisplaySubs());
            Task.Run(() => DisplayVIXES());

            if (publish)
            {
                // Load symbols and spread formulas (and subscribe to these symbols)
                ReloadSymbols();
                ReloadSpreads();
            }
        }
Exemplo n.º 2
0
        static void SubscribeVIXES(string mYY)
        {
            // Subscribe VIX/ES
            string m0 = mYY;
            string m1 = GDate.AddMonths(mYY, 1);
            string m2 = GDate.AddMonths(mYY, 2);
            string m3 = GDate.AddMonths(mYY, 3);
            string m4 = GDate.AddMonths(mYY, 4);
            string m5 = GDate.AddMonths(mYY, 5);

            m_updates.SetId("vix", "VIX.XO");
            m_prices.SubscribePrices("VIX.XO");
            m_updates.SetId("vx0", "@VX" + m0);
            m_updates.SetId("vx1", "@VX" + m1);
            m_updates.SetId("vx2", "@VX" + m2);
            m_updates.SetId("vx3", "@VX" + m3);
            m_updates.SetId("vx4", "@VX" + m4);
            m_updates.SetId("vx5", "@VX" + m5);
            m_prices.SubscribePrices("@VX" + m0);
            m_prices.SubscribePrices("@VX" + m1);
            m_prices.SubscribePrices("@VX" + m2);
            m_prices.SubscribePrices("@VX" + m3);
            m_prices.SubscribePrices("@VX" + m4);
            m_prices.SubscribePrices("@VX" + m5);
            string es_m0 = "H18";

            m_updates.SetId("spu", "@ES" + es_m0);
            m_prices.SubscribePrices("@ES" + es_m0);
        }
Exemplo n.º 3
0
        private void VerifyDJIA(DateTime date, string djia)
        {
            GDate gdate       = new GDate(date, date);
            var   actual_djia = GeoHash.GetDowJonesAsync(gdate).ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.AreEqual(djia, actual_djia, $"Data line {validated+1}");
        }
Exemplo n.º 4
0
        public void TestEastPost20080526()
        {
            DateTime test   = new DateTime(2008, 05, 27);
            var      result = GDate.ForLongitude(test, 0);

            Assert.AreEqual("2008-05-27", result.ToString());
            Assert.AreEqual("2008-05-26", result.DowJonesString());
        }
Exemplo n.º 5
0
        public int CompareTo(AddressModel other)
        {
            if (other is null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            return(GDate.CompareTo(other.GDate));
        }
Exemplo n.º 6
0
        public void TestGetDowJonesAsync()
        {
            GDate  gdate         = new GDate(2005, 05, 26); // https://geohashing.site/images/thumb/5/51/Coordinates.png/600px-Coordinates.png
            string expected_djia = "10458.68";

            var djia = GeoHash.GetDowJonesAsync(gdate).ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.AreEqual(expected_djia, djia);
        }
Exemplo n.º 7
0
        public void TestGetDJIAEast()
        {
            DateTime date          = new DateTime(2008, 05, 27);
            GDate    gdate         = GDate.ForLongitude(date, -29);
            string   expected_djia = "12620.90";

            var djia = GeoHash.GetDowJonesAsync(gdate).ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.AreEqual(expected_djia, djia);
        }
Exemplo n.º 8
0
        static void SubscribeCopper(string mYY)
        {
            // Subscribe CME/LME Copper
            string m0 = mYY;
            string m1 = GDate.AddMonths(mYY, 1);

            m_updates.SetId("hg0", "QHG" + m0);
            m_updates.SetId("hg1", "QHG" + m1);
            m_updates.SetId("lme", "M.CU3=LX");
            m_prices.SubscribePrices("QHG" + m0);
            m_prices.SubscribePrices("QHG" + m1);
            m_prices.SubscribePrices("M.CU3=LX");
        }
Exemplo n.º 9
0
        public void TestCalculateGeoHash()
        {
            GDate  gdate = new GDate(2005, 05, 26);
            string djia  = "10458.68";

            string expected_fraction0 = "857713";
            string expected_fraction1 = "544543";

            var fractions  = GeoHash.CalculateFractions(djia, gdate);
            var sfraction0 = fractions[0].ToString().Substring(2, 6);
            var sfraction1 = fractions[1].ToString().Substring(2, 6);

            Assert.AreEqual(expected_fraction0, sfraction0);
            Assert.AreEqual(expected_fraction1, sfraction1);
        }
Exemplo n.º 10
0
        //https://cex.io/api/currency_limits

        public string CreateAuthRequest()
        {
            string timestamp = Math.Floor(GDate.DateTimeToUnixTimestamp(DateTime.Now)).ToString();

            //HMACSHA512 hmac = new HMACSHA512(U8.GetBytes(apiSecret));
            HMACSHA256 hmac = new HMACSHA256(U8.GetBytes(ApiSecret));

            byte[] hashmessage = hmac.ComputeHash(U8.GetBytes(timestamp + ApiKey));
            string sign        = ToHexString(hashmessage);

            string authRequest = @"{
                ""e"": ""auth"",
                ""auth"": {
                    ""key"": """ + ApiKey + @""",
                    ""signature"": """ + sign + @""",
                    ""timestamp"": " + timestamp + @"
                }
            }";

            return(authRequest);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Gets a timestamp in milliseconds.
 /// </summary>
 /// <returns>Timestamp in milliseconds.</returns>
 public static string GetUnixTimeStamp(this DateTime baseDateTime)
 {
     //var dtOffset = new DateTimeOffset(baseDateTime);
     //return dtOffset.ToUnixTimeMilliseconds().ToString();
     return(GDate.DateTimeToUnixTimeMilliseconds(baseDateTime).ToString());
 }
Exemplo n.º 12
0
        public void InitFilter()
        {
            int left = 20;
            int top  = 15;

            foreach (FilterInfo f in FilterInfos)
            {
                switch (f.controltype)
                {
                case "dropdown":
                    GDropDown controldrop = new GDropDown();
                    controldrop.Caption  = f.caption;
                    controldrop.Location = new Point(left, top);
                    controldrop.Name     = "dropdown_" + f.fieldname;
                    controldrop.Width    = 200;
                    if (f.SearchForm != null)
                    {
                        controldrop.CustomerDropDownForm = f.SearchForm;
                    }
                    G.Controls.Base.Initialize.InitDropDown(controldrop, f.controldata, f.searchLogic, true);
                    if (!f.defaultvalue.IsNullOrEmpty())
                    {
                        controldrop.SetValue(f.defaultvalue);
                    }
                    this.tabPage1.Controls.Add(controldrop);
                    top      += controldrop.Height + 10;
                    f.control = controldrop.Name;
                    break;

                case "combox":
                    GCombo2 controlcombox = new GCombo2();
                    controlcombox.Caption  = f.caption;
                    controlcombox.Data     = f.controldata;
                    controlcombox.Name     = "combox_" + f.fieldname;
                    controlcombox.Location = new Point(left, top);
                    controlcombox.Width    = 200;
                    if (!f.defaultvalue.IsNullOrEmpty())
                    {
                        controlcombox.SetValue(f.defaultvalue);
                    }
                    this.tabPage1.Controls.Add(controlcombox);
                    top      += controlcombox.Height + 10;
                    f.control = controlcombox.Name;
                    break;

                case "checkbox":
                    GCheckBox controlcheckbox = new GCheckBox();
                    controlcheckbox.Caption  = f.caption;
                    controlcheckbox.Name     = "checkbox_" + f.fieldname;
                    controlcheckbox.Location = new Point(left, top);
                    controlcheckbox.Width    = 200;
                    if (!f.defaultvalue.IsNullOrEmpty())
                    {
                        controlcheckbox.SetValue(f.defaultvalue);
                    }
                    this.tabPage1.Controls.Add(controlcheckbox);
                    top      += controlcheckbox.Height + 10;
                    f.control = controlcheckbox.Name;
                    break;

                case "date":
                case "datetime":
                    GDate controldate = new GDate();
                    controldate.Caption = f.caption;
                    controldate.Name    = "date_" + f.fieldname;
                    DefaultDate(f);
                    controldate.Width    = 200;
                    controldate.Location = new Point(left, top);
                    if (!f.defaultvalue.IsNullOrEmpty())
                    {
                        controldate.SetValue(f.defaultvalue);
                    }

                    this.tabPage1.Controls.Add(controldate);
                    f.control = controldate.Name;
                    if (f.isdouble)
                    {
                        GDate controldate2 = new GDate();
                        controldate2.Caption  = "一一";
                        controldate2.Name     = "date2_" + f.fieldname;
                        controldate2.Location = new Point(left + controldate.Width + 20, top);
                        if (!f.defaultvalue2.IsNullOrEmpty())
                        {
                            controldate2.SetValue(f.defaultvalue2);
                        }

                        this.tabPage1.Controls.Add(controldate2);
                        f.control2 = controldate2.Name;
                    }
                    top += controldate.Height + 10;
                    break;

                default:
                    GText controltext = new GText();
                    controltext.Caption  = f.caption;
                    controltext.Name     = "text_" + f.fieldname;
                    controltext.Location = new Point(left, top);
                    controltext.Width    = 200;
                    if (!f.defaultvalue.IsNullOrEmpty())
                    {
                        controltext.SetValue(f.defaultvalue);
                    }
                    this.tabPage1.Controls.Add(controltext);
                    top      += controltext.Height + 10;
                    f.control = controltext.Name;
                    break;
                }
            }
        }
Exemplo n.º 13
0
        public Condition GetCondition()
        {
            Condition c = DefaultCondition;

            foreach (FilterInfo f in FilterInfos)
            {
                string v = "", v2 = "";
                switch (f.controltype)
                {
                case "dropdown":
                    GDropDown cd = this.tabPage1.Controls[f.control] as GDropDown;
                    v = G.Core.GConvert.ToString(cd.GetValue());
                    if (!v.IsNullOrEmpty())
                    {
                        if (f.islike)
                        {
                            c &= CK.K[f.fieldname].Like(v);
                        }
                        else
                        {
                            c &= CK.K[f.fieldname].Eq(v);
                        }
                    }
                    break;

                case "combox":
                    GCombo2 cc = this.tabPage1.Controls[f.control] as GCombo2;
                    v = G.Core.GConvert.ToString(cc.GetValue());
                    if (!v.IsNullOrEmpty())
                    {
                        if (f.islike)
                        {
                            c &= CK.K[f.fieldname].Like(v);
                        }
                        else
                        {
                            c &= CK.K[f.fieldname].Eq(v);
                        }
                    }
                    break;

                case "datetime":
                    GDate gdt  = this.tabPage1.Controls[f.control] as GDate;
                    GDate gdt2 = this.tabPage1.Controls[f.control2] as GDate;
                    v = gdt.GetValue().ToShortDateTime();
                    if (!v.IsNullOrEmpty())
                    {
                        if (f.islike)
                        {
                            c &= CK.K[f.fieldname].Like(v);
                        }
                        else if (f.isdouble)
                        {
                            v2 = "";
                            object obj2 = gdt2.GetValue();
                            if (!obj2.Equals(DBNull.Value))
                            {
                                v2 = obj2.ToDateTime().AddDays(1).ToShortDateString();
                            }
                            c &= CK.K[f.fieldname].Ge(v);
                            c &= CK.K[f.fieldname].Le(v2);
                        }
                        else
                        {
                            string v3 = gdt.GetValue().ToDateTime().AddDays(1).ToShortDateString();
                            c &= CK.K[f.fieldname].Ge(v);
                            c &= CK.K[f.fieldname].Le(v3);
                        }
                    }
                    break;

                case "date":
                    GDate gd = this.tabPage1.Controls[f.control] as GDate;

                    v = gd.GetValue().ToShortDateTime();
                    GDate gd2 = this.tabPage1.Controls[f.control2] as GDate;
                    v2 = gd2.GetValue().ToShortDateTime();
                    if (!v.IsNullOrEmpty())
                    {
                        if (f.islike)
                        {
                            c &= CK.K[f.fieldname].Like(v);
                        }
                        else if (f.isdouble)
                        {
                            c &= CK.K[f.fieldname].Ge(v);
                            c &= CK.K[f.fieldname].Le(v2);
                        }
                        else
                        {
                            c &= CK.K[f.fieldname].Eq(v);
                        }
                    }
                    break;

                case "checkbox":
                    GCheckBox ccb = this.tabPage1.Controls[f.control] as GCheckBox;
                    v = G.Core.GConvert.ToString(ccb.GetValue());
                    if (!v.IsNullOrEmpty())
                    {
                        c &= CK.K[f.fieldname].Eq(v);
                    }
                    break;

                default:
                    GText gt = this.tabPage1.Controls[f.control] as GText;
                    v = G.Core.GConvert.ToString(gt.GetValue());
                    if (!v.IsNullOrEmpty())
                    {
                        if (f.islike)
                        {
                            c &= CK.K[f.fieldname].Like(v);
                        }
                        else
                        {
                            c &= CK.K[f.fieldname].Eq(v);
                        }
                    }
                    break;
                }
            }
            if (c == null)
            {
                c = Condition.Empty;
            }
            return(c);
        }