Ejemplo n.º 1
0
        /// <summary>
        /// 获取K线静态数值
        /// </summary>
        /// <param name="div">K线层</param>
        private void SetCandleStaticValue(SandBoxCandleDiv div)
        {
            SecurityData data       = div.Data;
            SpinA        spinOpen   = GetSpin("txtOpen");
            SpinA        spinClose  = GetSpin("txtClose");
            SpinA        spinHigh   = GetSpin("txtHigh");
            SpinA        spinLow    = GetSpin("txtLow");
            SpinA        spinVolume = GetSpin("txtVolume");
            SpinA        spinAmount = GetSpin("txtAmount");
            LabelA       lblDate    = GetLabel("lblDate");

            data.m_open   = (float)spinOpen.Value;
            data.m_close  = (float)spinClose.Value;
            data.m_high   = (float)spinHigh.Value;
            data.m_low    = (float)spinLow.Value;
            data.m_volume = spinVolume.Value;
            data.m_amount = spinAmount.Value;
            String strDate = lblDate.Text;

            if (strDate != null && strDate.Length > 0)
            {
                data.m_date = m_chart.Chart.ConvertDateToNum(Convert.ToDateTime(strDate));
            }
            div.Data = data;
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            SecurityData sd = new SecurityData();

            sd.Ticker = "GOOG";
            Assert.Equal("GOOG", sd.Ticker);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Api for retriving Pay Later Amount - PayLater
        /// </summary>
        /// <param name="apipaymentpaylaterpostrequestcontent"></param>
        /// <returns>ApiPaymentPayLaterPostOKResponseContent</returns>
        public async Task <IHttpActionResult> Post(Models.ApiPaymentPayLaterPostRequestContent apipaymentpaylaterpostrequestcontent)
        {
            YourJourney         summaryPNRJourney = (YourJourney)_sessionStorage["summaryPNRJourney"];
            PassengerNameRecord actualPNR         = new PassengerNameRecord();
            var    securityData = new SecurityData();
            object securityObj;

            Request.Properties.TryGetValue("securityData", out securityObj);
            securityData = (SecurityData)securityObj;
            try
            {
                actualPNR = this._paymentTasks.PayLater(summaryPNRJourney, securityData);
                return(Ok());
            }

            //  //BookingResponseBuilder bookRes = new BookingResponseBuilder();
            //  //ApiBookingCreatePNRPostOKResponseContent response = bookRes.BuildResponse(actualPNR, requestContent);
            //return Ok(response);
            ////PaymentBuilder useVoucherBuilder = new PaymentBuilder();
            ////return Ok(useVoucherBuilder.BuildUseVoucherResponse(resultinPmtDetails));

            catch (RadixxVoucherException ex)
            {
                throw new Exception();
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var password     = "******";
            var securityData = SecurityData.CrearNuevo(password);


            var plainText = "Testing this thing out. Will it work? Will it not? More on this on the next episode. Stay tuned!";

            var iv = new byte[16];

            using (var rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(iv);
            }


            var newPassword = "******";

            var encryptedData = securityData.Encrypt(Encoding.UTF8.GetBytes(plainText), password, iv);

            Console.WriteLine("encryptedData: " + Convert.ToBase64String(encryptedData));
            securityData.PasswordChange(password, newPassword);

            var decryptedData = securityData.Decrypt(encryptedData, newPassword, iv);


            Console.WriteLine("decryptedData = " + Encoding.UTF8.GetString(decryptedData));
        }
Ejemplo n.º 5
0
        public int GetRemainingSessionDuration(SecurityData securityData)
        {
            var currentTime    = DateTime.Now;
            var tokenStartTime = GetSessionBeginTime(securityData);

            return(Convert.ToInt32(((Constants.SessionTimeoutDuration) * 60) - ((currentTime - tokenStartTime).TotalSeconds)));
        }
Ejemplo n.º 6
0
        public string Login(string login, string password)
        {
            if (string.IsNullOrWhiteSpace(login) && string.IsNullOrWhiteSpace(password))
            {
                return(@"Не заданы ""Логин"" и ""Пароль""");
            }

            if (string.IsNullOrWhiteSpace(login))
            {
                return(@"Не задан ""Логин""");
            }

            if (string.IsNullOrWhiteSpace(password))
            {
                return(@"Не задан ""Пароль""");
            }

            var securityData =
                new SecurityData
            {
                Login    = login,
                Password = password
            };

            var errorMessage = APIClientHelper <SecurityAPIClient> .Call(c => c.LogIn(securityData));

            if (string.IsNullOrEmpty(errorMessage))
            {
                _securityData = securityData;
            }

            return(errorMessage);
        }
        public async Task <IActionResult> migracionClaves([FromBody] string password)
        {
            //var currentUser = await _userManager.GetUserAsync(User);
            var currentUser = _context.Users.Include(u => u.Claves).First(u => u.UserName == User.Identity.Name);

            if (!await _userManager.CheckPasswordAsync(currentUser, password))
            {
                return(Ok(new Response(false)));
            }

            var securityData = new SecurityData(currentUser.DatosSeguridad);
            var rng          = System.Security.Cryptography.RandomNumberGenerator.Create();

            foreach (var clave in currentUser.Claves)
            {
                var iv = new byte[16];
                rng.GetBytes(iv);

                var encPrivKey = securityData.Encrypt(clave.PrivateKey_ByteArray, password, iv);

                clave.EncPrivKey = Convert.ToBase64String(encPrivKey) + "|" + Convert.ToBase64String(iv);
            }
            _context.SaveChanges();
            return(Ok(new Response(true)));
        }
Ejemplo n.º 8
0
        public void Lookup_SymbolTicker3_LookA()
        {
            test = new FinancialSecurityManager(idParser, lookupServices, combiner, false, false, cache);
            // lookup security data by security id
            // (securityId = "A", so it is a NYSE)
            SecurityData data = test.Lookup("A");

            CheckData_SymbolTicker1_LookA(data, "A");

            // first we check the number of elements in  the cache.
            Assert.AreEqual(3, cache.GetCache().Count, "The cache should only have 3 element.");

            // check the cache key : A
            Object record     = cache["A"];
            bool   isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");

            Assert.IsTrue(isLookedUp, "The IsLookedUp tag should be set well");
            SecurityData recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");

            CheckData_SymbolTicker1_LookA(recordData, "A");

            // check the cache key : B
            record     = cache["B"];
            isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");
            Assert.IsFalse(isLookedUp, "The IsLookedUp tag should be set well");
            recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");
            CheckData_SymbolTicker1_LookA(recordData, "B");

            // check the cache key : C
            record     = cache["C"];
            isLookedUp = (bool)AccuracyTestsTestHelper.getPropertyField(record, "IsLookedUp");
            Assert.IsFalse(isLookedUp, "The IsLookedUp tag should be set well");
            recordData = (SecurityData)AccuracyTestsTestHelper.getPropertyField(record, "SecurityData");
            CheckData_SymbolTicker1_LookA(recordData, "C");
        }
Ejemplo n.º 9
0
        private void PrepareObservables()
        {
            this.WhenAnyValue(e => e.Username, p => p.Password, (emailAddress, password) => (!string.IsNullOrEmpty(emailAddress)) && !string.IsNullOrEmpty(password) && password.Length > 5)
            .ToProperty(this, v => v.IsValid, out _isValid);

            var canExecuteLogin = this.WhenAnyValue(x => x.IsLoading, x => x.IsValid, (isLoading, IsValid) => !isLoading && IsValid);

            LoginCommand = ReactiveCommand.CreateFromTask(
                async execute =>
            {
                var accessDTO = new Ref <AccessDTO>();
                await RunSafe(ExecuteApi(LoginApi.GetToken(new UserInfoDTO {
                    AccessKey = Password, UserId = Username
                }), accessDTO));
                if (accessDTO.Value.Authenticated)
                {
                    await SecurityData.SaveUser(accessDTO.Value);
                    HostScreen.Router.Navigate.Execute(new IntentionsList()).Subscribe();
                }
            }, canExecuteLogin);


            this.WhenAnyObservable(x => x.LoginCommand.IsExecuting)
            .StartWith(false)
            .ToProperty(this, x => x.IsLoading, out _isLoading);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 执行秒表方法
 /// </summary>
 /// <param name="timerID">秒表ID</param>
 public void OnTimer(int timerID)
 {
     if (m_timerID == timerID)
     {
         INativeBase             native     = Native;
         ChartA                  chart      = m_chart.Chart;
         CTable                  dataSource = chart.DataSource;
         int                     divsSize   = m_divs.Count;
         bool                    painting   = false;
         int                     cx         = native.ClientX(m_window);
         int                     cy         = native.ClientY(m_window);
         List <SandBoxCandleDiv> removeDivs = new List <SandBoxCandleDiv>();
         for (int i = 0; i < divsSize; i++)
         {
             SandBoxCandleDiv div = m_divs[i];
             //判断是否需要重绘
             if (div.Moving)
             {
                 painting = true;
             }
             //执行秒表
             if (m_divs[i].OnTimer())
             {
                 SecurityData data     = div.Data;
                 int          rowIndex = dataSource.GetRowIndex(data.m_date);
                 int[]        fields   = new int[7];
                 fields[0] = KeyFields.CLOSE_INDEX;
                 fields[1] = KeyFields.HIGH_INDEX;
                 fields[2] = KeyFields.LOW_INDEX;
                 fields[3] = KeyFields.OPEN_INDEX;
                 fields[4] = KeyFields.VOL_INDEX;
                 fields[5] = KeyFields.AMOUNT_INDEX;
                 fields[6] = KeyFields.AVGPRICE_INDEX;
                 //插入数据
                 SecurityDataHelper.InsertLatestData(m_chart.Chart, dataSource, m_chart.Indicators, fields, data);
                 removeDivs.Add(div);
             }
         }
         //移除控件
         int removeDivsSize = removeDivs.Count;
         if (removeDivsSize > 0)
         {
             for (int i = 0; i < removeDivsSize; i++)
             {
                 SandBoxCandleDiv div = removeDivs[i];
                 m_native.RemoveControl(div);
                 m_divs.Remove(div);
                 div.Dispose();
             }
             removeDivs.Clear();
             m_chart.Chart.Update();
         }
         //重绘
         if (painting)
         {
             m_native.Invalidate();
         }
     }
 }
Ejemplo n.º 11
0
        public void Lookup_SymbolTicker3_LookAAndB()
        {
            test = new FinancialSecurityManager(idParser, lookupServices, combiner, false, false, cache);
            test.Lookup("A");
            SecurityData data = test.Lookup("B");

            CheckData_SymbolTicker1_LookA(data, "B");
        }
Ejemplo n.º 12
0
        public void Test3()
        {
            SecurityData sd = new SecurityData();

            Assert.Equal(sd.TradeVol, 0);
            sd.TradeVol = 100;
            Assert.Equal(100, sd.TradeVol);
        }
        private static SecurityData GetSecurityData(int securityId)
        {
            var security = new SecurityData();

            security.Id   = securityId;
            security.Name = string.Format("Security_{0}", securityId);
            return(security);
        }
Ejemplo n.º 14
0
        public DateTime GetSessionBeginTime(SecurityData securityData)
        {
            var exptime = 45;

            int.TryParse(ConfigurationManager.AppSettings["SabreSessionExpiryMinutes"],
                         out exptime);
            return(securityData.ExpiryDateTime.AddMinutes(exptime * -1));
        }
Ejemplo n.º 15
0
        public void Lookup_SymbolTicker2_IdDetails_True()
        {
            test = new FinancialSecurityManager(idParser, lookupServices, combiner, true, true, cache);
            test.Lookup("A");
            SecurityData data = test.Lookup(test.Parse("B"));

            CheckData_SymbolTicker1_LookAAndB(data, "B");
        }
Ejemplo n.º 16
0
        public void Lookup_SymbolTicker1_IdDetails()
        {
            test.Lookup("A");
            test.Lookup("B");
            SecurityData data = test.Lookup(test.Parse("A"));

            CheckData_SymbolTicker1_LookAAndB(data, "A");
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            SecurityData.AuthCookieTime();

            pph.AssignControls();
        }
Ejemplo n.º 18
0
 private void CreateSecurityData(DataPerSecurityReqMsg msg)
 {
     SecAttribData = new SecurityData()
     {
         Id   = msg.SecurityId,
         Name = string.Format("Security_{0}", msg.SecurityId),
         AttributionDataForDates = new Dictionary <DateTime, AttributionData>()
     };
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Создать <see cref="OrderWindow"/>.
        /// </summary>
        public OrderWindow()
        {
            InitializeComponent();

            TimeInForceCtrl.SetDataSource <OrderWindowTif>();

            Order       = new Order();
            DataContext = Data = new SecurityData();
        }
Ejemplo n.º 20
0
        internal static void UpdateDependencyScope(HttpRequestMessage request, SecurityData securityData)
        {
            var scope = request.GetDependencyScope() as StructureMapWebApiDependencyScope;

            scope?.CurrentNestedContainer
            .Configure(cfg => cfg.For <HttpRequestMessage>().Use(request));
            scope?.CurrentNestedContainer
            .Configure(cfg => cfg.For <SecurityData>().Use(securityData));
        }
Ejemplo n.º 21
0
        public async Task <ActionResult> ResetPassword(ResetPasswordInfo model)
        {
            model.ReconstructSettings();
            this.ViewData[ResetPasswordInfo.Key] = model;

            LoadPage(model.Settings.Uri);

            var settings = model.Settings;

            if (settings.UseValidateHuman)
            {
                bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue);
                if (!IsValidated)
                {
                    ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText);
                    model.ValidationValue = String.Empty;
                }
            }

            if (String.IsNullOrEmpty(settings.UserCode))
            {
                ModelState.AddModelError(String.Empty, "Reset code not provided.");
            }

            if (ModelState.IsValid)
            {
                string confirmView = settings.PostPartialName;
                if (!String.IsNullOrEmpty(settings.PostPartialName))
                {
                    confirmView = settings.PostPartialConfirmation;
                }

                var user = await securityHelper.UserManager.FindByEmailAsync(model.Email);

                if (user == null)
                {
                    return(PartialView(confirmView, model));
                }
                else
                {
                    SecurityData sd     = new SecurityData();
                    var          result = sd.ResetPassword(user, settings.UserCode, model.Password);
                    model.CreationResult = result;

                    if (result.Succeeded)
                    {
                        return(PartialView(confirmView, model));
                    }

                    AddErrors(result);
                }
            }

            Helper.HandleErrorDict(ModelState);

            return(PartialView(settings.PostPartialName, model));
        }
        public SecurityData GetSecurityData(string issuerTicker)
        {
            ReferenceDataResponse response =
                SessionWrapper.RequestDescriptions.Values.First(info => info.Tickers.Contains(issuerTicker)).Response;

            SecurityData securityData =
                response.Securities.Select(kvp => kvp.Value).First(data => data.Security.Equals(issuerTicker));

            return(securityData);
        }
Ejemplo n.º 23
0
        protected void GetUserList(string roleName)
        {
            List <MembershipUser> usrs = SecurityData.GetUsersInRole(roleName);

            GeneralUtilities.BindDataBoundControl(gvUsers, usrs);

            if (usrs.Count < 1)
            {
                btnRemove.Visible = false;
            }
        }
Ejemplo n.º 24
0
        private void ParseResponse()
        {
            foreach (var securityData in response.Securities)
            {
                try
                {
                    double   bid  = default(double);
                    double   ask  = default(double);
                    DateTime?time = null;

                    string       sec                      = securityData.Key;
                    SecurityData requestedData            = securityData.Value;
                    Dictionary <string, FieldData> fields = requestedData.Fields;

                    if (fields.ContainsKey(Settings.Default.Bloomberg_Field_Bid))
                    {
                        FieldData bidField = fields[Settings.Default.Bloomberg_Field_Bid];
                        if ((bidField != null) && (bidField.HasValue))
                        {
                            bid = bidField.GetValueAsDouble();
                        }
                    }

                    if (fields.ContainsKey(Settings.Default.Bloomberg_Field_Ask))
                    {
                        FieldData askField = fields[Settings.Default.Bloomberg_Field_Ask];
                        if ((askField != null) && (askField.HasValue))
                        {
                            ask = askField.GetValueAsDouble();
                        }
                    }

                    if (fields.ContainsKey(Settings.Default.Bloomberg_Field_Time))
                    {
                        FieldData timeField = fields[Settings.Default.Bloomberg_Field_Time];
                        if ((timeField != null) && (timeField.HasValue))
                        {
                            time = timeField.GetValueAsDateTime();
                        }
                    }
                    if (time == null)
                    {
                        time = new DateTime(1900, 1, 1);
                    }
                    tickerPriceCollection.Add(sec, new PriceInfo(bid, ask, time, time));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ParseResponse() " + ex);
                    HasError = true;
                }
            }
        }
Ejemplo n.º 25
0
        // GET api/SecurityData
        public SecurityData Get(string Id)
        {
            SecurityData data = new SecurityData();

            MicexISSClient client = new MicexISSClient(new WebApiClient());

            ISSResponse resp = client.GetSecurityInfo(Id).Result;

            data.SecurityInfo = resp.SecurityInfo.Single(i => i.Code == Id);
            data.MarketData   = resp.MarketData.Single(m => m.Code == Id);

            return(data);
        }
Ejemplo n.º 26
0
        public void AddSecurity(SecurityData security)
        {
            if (security == null)
            {
                throw new ArgumentNullException(nameof(security));
            }

            this.securityAdditions.Add(new OrderedGuid
            {
                Guid  = security.SecurityId,
                Order = this.orderIndex++,
            });
        }
Ejemplo n.º 27
0
        private Guid FindUser(Guid userId)
        {
            MembershipUser usr = SecurityData.GetUserByGuid(userId);

            if (usr == null)
            {
                return(SecurityData.CurrentUserGuid);
            }
            else
            {
                return(userId);
            }
        }
Ejemplo n.º 28
0
        public void SecurityData_Ctor1()
        {
            test = new SecurityData("2", "IBM");
            Assert.IsNotNull(test, "The ctor should work well.");

            // get the property to test the ctor.
            Assert.AreEqual("2", test.Id, "The Id property should be set to '2'.");
            Assert.AreEqual("IBM", test.CompanyName, "The CompanyName property should be set to 'IBM'.");

            string[] ids = test.ReferenceIds;
            // we check the length of the array first.
            Assert.IsNotNull(ids, "The ids array should be not null.");
        }
Ejemplo n.º 29
0
        public static void LogIn(this ISecurityService securityService, string login, string password)
        {
            CheckHelper.ArgumentNotNull(securityService, "securityService");

            var securityData =
                new SecurityData
            {
                Login    = login,
                Password = password
            };

            securityService.LogIn(securityData);
        }
Ejemplo n.º 30
0
        protected string GetUserName(Guid userId)
        {
            MembershipUser usr = SecurityData.GetUserByGuid(userId);

            if (usr != null)
            {
                return(usr.UserName);
            }
            else
            {
                return(" ");
            }
        }
Ejemplo n.º 31
0
		private Tuple<Order, bool, bool> GetOrderInfo(SecurityData securityData, OrderTypes? type, long transactionId, long? orderId, string orderStringId, Func<long, Order> createOrder, out bool isNew, bool newOrderRaised = false)
		{
			if (createOrder == null)
				throw new ArgumentNullException(nameof(createOrder));

			if (transactionId == 0 && orderId == null && orderStringId.IsEmpty())
				throw new ArgumentException(LocalizedStrings.Str719);

			var isNew2 = false;
			var orders = securityData.Orders;

			OrderInfo info;

			if (transactionId == 0)
			{
				info = orders.CachedValues.FirstOrDefault(i =>
				{
					var order = i.Order;

					if (orderId != null)
						return order.Id == orderId;
					else
						return order.StringId.CompareIgnoreCase(orderStringId);
				});

				if (info == null)
				{
					isNew = false;
					return null;
					//throw new InvalidOperationException(LocalizedStrings.Str1156Params.Put(orderId.To<string>() ?? orderStringId));
				}
			}
			else
			{
				var cancelKey = CreateOrderKey(type, transactionId, true);
				var registerKey = CreateOrderKey(type, transactionId, false);

				var cancelledOrder = (Order)orders.TryGetValue(cancelKey);

				// проверяем не отмененная ли заявка пришла
				if (cancelledOrder != null && (cancelledOrder.Id == orderId || (!cancelledOrder.StringId.IsEmpty() && cancelledOrder.StringId.CompareIgnoreCase(orderStringId))))
				{
					isNew = false;
					return Tuple.Create(cancelledOrder, true/*, (Order)orders.TryGetValue(registerKey) != null*/, false);
				}

				info = orders.SafeAdd(registerKey, key =>
				{
					isNew2 = true;

					var o = createOrder(transactionId);

					if (o == null)
						throw new InvalidOperationException(LocalizedStrings.Str720Params.Put(transactionId));

					if (o.ExtensionInfo == null)
						o.ExtensionInfo = new Dictionary<object, object>();

					AddOrder(o);

					// с таким же идентификатором транзакции может быть заявка по другому инструменту
					_allOrdersByTransactionId.TryAdd(Tuple.Create(transactionId, type == OrderTypes.Conditional), o);

					return new OrderInfo(o);
				});
			}

			var raiseNewOrder = info.RaiseNewOrder;

			if (raiseNewOrder && newOrderRaised)
				info.RaiseNewOrder = false;

			isNew = isNew2;
			return Tuple.Create((Order)info, false, raiseNewOrder);
		}
Ejemplo n.º 32
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OrderWindow"/>.
		/// </summary>
		public OrderWindow()
		{
			InitializeComponent();

			TimeInForceCtrl.SetDataSource<OrderWindowTif>();

			Order = new Order { Type = OrderTypes.Limit };
			DataContext = Data = new SecurityData();
		}
Ejemplo n.º 33
0
 public void AddSecurity(SecurityData security)
 {
 }
Ejemplo n.º 34
0
        public void AddSecurity(SecurityData security)
        {
            if (security == null)
            {
                throw new ArgumentNullException("security");
            }

            this.securityAdditions.Add(new OrderedGuid
            {
                Guid = security.SecurityId,
                Order = this.orderIndex++,
            });
        }