示例#1
0
        private void OpenPosition(LsTradeSubscriptionData opu)
        {
            var position = new PositionModel();

            var market = _tradingService.GetInstrument(opu.epic);

            position.Instrument = market;

            position.DealId   = opu.dealId;
            position.DealSize = Convert.ToDouble(opu.size);

            if (opu.direction != null)
            {
                position.Direction = (PositionModel.Directions)opu.direction;
            }

            position.OpenLevel  = Convert.ToDouble(opu.level);
            position.StopLevel  = string.IsNullOrEmpty(opu.stopLevel) ? null : (double?)Convert.ToDouble(opu.stopLevel);
            position.LimitLevel = string.IsNullOrEmpty(opu.limitLevel) ? null : (double?)Convert.ToDouble(opu.limitLevel);

            DateTime date;

            if (DateTime.TryParseExact(opu.timestamp, "yyyy-MM-ddTHH:mm:ss.fff", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
            {
                position.CreatedDate = date.ToLocalTime();
            }

            //if (DateTime.TryParseExact(opu.expiryTime, "yyyy/MM/dd HH:mm:ss:fff", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
            //    position.Expirity = date;

            position.GuaranteedStop = opu.guaranteedStop;

            _tradingService.AddPosition(position);
        }
示例#2
0
        private void OpenOrder(LsTradeSubscriptionData wou)
        {
            var order = new OrderModel();

            var market = _tradingService.GetInstrument(wou.epic);

            order.Model = market;

            order.DealId       = wou.dealId;
            order.OrderSize    = double.Parse(wou.size);
            order.Direction    = wou.direction.ToString();
            order.CreationDate = DateTime.Now.ToString();
            //order.GoodTillDate = wou.expiry;
            //order.OrderType = wou.;
            order.OrderLevel    = double.Parse(wou.level);
            order.StopDistance  = string.IsNullOrEmpty(wou.stopDistance) ? null : (double?)double.Parse(wou.stopLevel);
            order.LimitDistance = string.IsNullOrEmpty(wou.limitDistance) ? null : (double?)double.Parse(wou.limitLevel);
            //order.TimeInForce = order.workingOrderData.timeInForce;
            //order.StopLevel = string.IsNullOrEmpty(opu.stopLevel) ? null : (double?)double.Parse(opu.stopLevel);
            //order.LimitLevel = string.IsNullOrEmpty(opu.limitLevel) ? null : (double?)double.Parse(opu.limitLevel);
            //order.CreatedDate = DateTime.Now.ToShortDateString();
            //order.GuaranteedStop = opu.guaranteedStop;

            _tradingService.AddOrder(order);
        }
示例#3
0
        private void DeleteOrder(LsTradeSubscriptionData wou)
        {
            var order = _tradingService.Orders.FirstOrDefault(p => p.DealId == wou.dealId);

            if (order == null)
            {
                //TODO : error message

                return;
            }

            _tradingService.DeleteOrder(order);
        }
示例#4
0
        private void DeletePosition(LsTradeSubscriptionData opu)
        {
            var position = _tradingService.Positions.FirstOrDefault(p => p.DealId == opu.dealId);

            if (position == null)
            {
                //TODO : error message

                return;
            }

            _tradingService.DeletePosition(position);
        }
示例#5
0
        private void UpdatePosition(LsTradeSubscriptionData opu)
        {
            var position = _tradingService.Positions.FirstOrDefault(p => p.DealId == opu.dealId);

            if (position == null)
            {
                //TODO : error message

                return;
            }

            position.DealSize   = Convert.ToDouble(opu.size);
            position.StopLevel  = string.IsNullOrEmpty(opu.stopLevel) ? null : (double?)Convert.ToDouble(opu.stopLevel);
            position.LimitLevel = string.IsNullOrEmpty(opu.limitLevel) ? null : (double?)Convert.ToDouble(opu.limitLevel);
        }
示例#6
0
        private void UpdateOrder(LsTradeSubscriptionData wou)
        {
            var order = _tradingService.Orders.FirstOrDefault(p => p.DealId == wou.dealId);

            if (order == null)
            {
                //TODO : error message

                return;
            }

            order.OrderSize     = double.Parse(wou.size);
            order.OrderLevel    = double.Parse(wou.level);
            order.StopDistance  = string.IsNullOrEmpty(wou.stopDistance) ? null : (double?)double.Parse(wou.stopLevel);
            order.LimitDistance = string.IsNullOrEmpty(wou.limitDistance) ? null : (double?)double.Parse(wou.limitLevel);
        }