Exemplo n.º 1
0
        private static void SendInternal(FinType fin, OpcodeType opcode, byte[] data)
        {
            byte   secondByte   = 0;
            UInt32 lengthLength = 0;

            if (data.Length > 0xFFFF)
            {
                secondByte   = 127;
                lengthLength = 8;
            }
            else if (data.Length >= 126 && data.Length <= 0xFFFF)
            {
                secondByte   = 126;
                lengthLength = 2;
            }
            else
            {
                secondByte = (byte)data.Length;
            }

            byte[] headersBuffer = new byte[lengthLength + 2];
            headersBuffer[0] = (byte)((byte)fin | (byte)opcode);
            headersBuffer[1] = secondByte;
            CopyLengthBytes(data.Length, headersBuffer, 2);

            networkStream.Write(headersBuffer, 0, headersBuffer.Length);
            networkStream.Write(data, 0, data.Length);
        }
 public PortfolioPosition(string ident,
                          FinType finType,
                          decimal amount = 0.0m)
 {
     _ident   = ident;
     _finType = finType;
     _amount  = amount;
 }
        public void TestInsertFinType()
        {
            var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, DataBaseLink.ConnectionType.Npgsql);

            DataBaseLink.DbLink dbLink   = new DbLink(tempConnection);
            fin_type            fin_type = new fin_type("FX_RATE", "Валютный курс");

            if (FinType.FindId(dbLink, fin_type.ident) == null)
            {
                FinType.Insert(dbLink, fin_type);
            }
        }
        public List <PortfolioPosition> GetAllPositions(FinType finType)
        {
            List <PortfolioPosition> positions = new List <PortfolioPosition>();

            foreach (var x in _markets)
            {
                positions.AddRange(x.GetAllPositions(finType));
            }

            var t = positions.Distinct(new PortfolioPositionCompare()).ToList();

            return(t);
        }
        public List <PortfolioPosition> GetAllPositions()
        {
            string query =
                @"select fi.ident as ident, ft.ident as finType from fin_instrument fi
                    join fin_type ft on fi.ft_id = ft.ft_id";

            var result = _dbLink.GetConnection().Query <finInstrument>(query);
            List <PortfolioPosition> positions = new List <PortfolioPosition>(result.Count());

            foreach (var x in result)
            {
                FinType         finType  = (FinType)_mapping.Get <FinType>(x.finType, FinType.Default);
                BalancePosition position = new BalancePosition(x.ident, finType);
                positions.Add(position);
            }
            return(positions);

            throw new NotImplementedException();
        }
        public void TestRemoveFinType()
        {
            var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, DataBaseLink.ConnectionType.Npgsql);

            DataBaseLink.DbLink dbLink   = new DbLink(tempConnection);
            fin_type            fin_type = new fin_type("BUSHEUV", "BUSHUEV");

            if (FinType.FindId(dbLink, fin_type.ident) == null)
            {
                FinType.Insert(dbLink, fin_type);
                var t = FinType.FindId(dbLink, fin_type.ident);
                Console.WriteLine(t.ft_id);
                FinType.Remove(dbLink, t.ft_id);
            }
            else
            {
                var t = FinType.FindId(dbLink, fin_type.ident);
                Console.WriteLine(t.ft_id);
                FinType.Remove(dbLink, t.ft_id);
            }
        }
Exemplo n.º 7
0
 public EmailInfoProvider(FinType finType, int id)
 {
     this.m_finType = finType;
     this.m_id = id;
 }
Exemplo n.º 8
0
 // Suggested opcode: OpcodeType.Text
 public static void Send(FinType fin, OpcodeType opcode, string message)
 {
     SendInternal(fin, opcode, Encoding.UTF8.GetBytes(message));
 }
        public List <PortfolioPosition> GetAllPositions(FinType finType)
        {
            var result = GetAllPositions();

            return(result.Where(z => z.FinType == finType).ToList());
        }
Exemplo n.º 10
0
 public List <PortfolioPosition> GetAllPositions(FinType finType)
 {
     return(_dataProvider.GetAllPositions(finType));
 }
 public BalancePosition(string ident,
                        FinType finType,
                        decimal amount = decimal.Zero)
     : base(ident, finType, amount)
 {
 }