public async Task <IActionResult> Post([FromBody] OrderModel orderModel) { if (string.IsNullOrEmpty(orderModel?.ExchangeName) || string.IsNullOrEmpty(orderModel.Instrument) || orderModel.Volume == 0) { return(BadRequest("Bad model")); } if (!(_exchangeCache.Get(orderModel.ExchangeName)?.AcceptOrder ?? true)) { return(BadRequest($"AcceptOrder is false for {orderModel.ExchangeName}")); } var quote = _quoteService.Get(orderModel.ExchangeName, orderModel.Instrument); var result = await _tradingService.CreateOrder( orderModel.ExchangeName, orderModel.Instrument, orderModel.TradeType, orderModel.Price ?? (orderModel.TradeType == TradeType.Buy ? quote?.Ask : quote?.Bid) ?? 0, orderModel.Volume); if (result == null) { return(BadRequest("No such exchange in config")); } return(Ok(result)); }
public async Task <IActionResult> Index([FromQuery, Required] string exchangeName) { return(Ok(_exchangeCache.Get(exchangeName)?.Positions.Select(x => new PositionModel { Symbol = x.Symbol, PositionVolume = x.PositionVolume }))); }
public async Task <IActionResult> GetTradeBalance([FromQuery] string exchangeName) { return(Ok(_exchangeCache.Get(exchangeName)?.Accounts.Select(x => new TradeBalanceModel { AccountCurrency = x.Asset, Totalbalance = x.Balance, MarginUsed = 0, MaringAvailable = 100000, UnrealisedPnL = 0 }))); }
public IActionResult Index(string exchangeName) { var result = _exchangeCache.Get(exchangeName); if (result == null) { return(BadRequest($"Invalid {nameof(exchangeName)}")); } return(Ok(new ExchangeInformationModel { Instruments = result.Instruments, Name = result.Name, State = ExchangeState.Connected, StreamingSupport = result.StreamingSupport })); }
public bool?GetAcceptOrder(string exchangeName) { return(_exchangeCache.Get(exchangeName)?.AcceptOrder); }