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); }
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); }
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); }
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); }
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); }
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); }