public TrailingStopOrder TrailingStopOrder(Instrument instrument, Side side, double qty, double delta) { TrailingStopOrder trailingStopOrder = new TrailingStopOrder(instrument, side, qty, delta); base.Strategy.RegisterOrder(trailingStopOrder); return(trailingStopOrder); }
public TrailingStopOrder TrailingStopOrder(Side side, double qty, double delta) { TrailingStopOrder trailingStopOrder = new TrailingStopOrder(this.instrument, side, qty, delta); this.Strategy.EB2iXBUSFK((SingleOrder)trailingStopOrder); return(trailingStopOrder); }
// Submit a market order if quantity is not zero. public async Task <Guid> SubmitMarketOrder(int quantity, OrderSide side, string clientId = "", decimal stopDollars = 0) { //if (quantity == 0) if (quantity == 0) { return(Guid.Empty); } //Console.WriteLine($"Submitting {side} order for {quantity} shares."); try { IOrder order; if (clientId.Length > 0) { order = await client.PostOrderAsync(side.Market(symbol, quantity).WithClientOrderId(clientId)); } else { order = await client.PostOrderAsync(side.Market(symbol, quantity)); } lastTradeId = order.OrderId; if (stopDollars > 0) { // Submit a trailing stop order to sell / buy quantitu of symbol at market - stoploss // trailing stop of if (side == OrderSide.Buy) { order = await client.PostOrderAsync( TrailingStopOrder.Sell(symbol, quantity, TrailOffset.InDollars(stopDollars))); // stop price will be hwm - stopDollars$ (326.44 - 0.05 = 326.39) } else { order = await client.PostOrderAsync( TrailingStopOrder.Buy(symbol, quantity, TrailOffset.InDollars(stopDollars))); // stop price will be hwm + stopDollars$ } } } catch (Exception ex) { // jsruntime.alert(ex.Message); } if (clientId.Length > 0) { await GetOrders(clientId); } return(lastTradeId); }
private void OnPlaceOrder(object obj) { Order _workingorder = null; switch (_selectedordertype) { case 0: _workingorder = new MarketOrder(_fullsymbol, _selectedbuysell == 0 ? _size : -_size, _globalIdService.GetNextOrderId()); //_workingorder.StopPrice = 0; //_workingorder.LimitPrice = 0; break; case 1: _workingorder = new LimitOrder(_fullsymbol, _selectedbuysell == 0 ? _size : -_size, _price, _globalIdService.GetNextOrderId()); //_workingorder.StopPrice = 0; //_workingorder.LimitPrice = _price; break; case 2: _workingorder = new StopOrder(_fullsymbol, _selectedbuysell == 0 ? _size : -_size, _price, _globalIdService.GetNextOrderId()); //_workingorder.StopPrice = _price; //_workingorder.LimitPrice = 0; break; case 3: _workingorder = new StopLimitOrder(_fullsymbol, _selectedbuysell == 0 ? _size : -_size, _price, _auxprice, _globalIdService.GetNextOrderId()); break; case 4: _workingorder = new TrailingStopOrder(_fullsymbol, _selectedbuysell == 0 ? _size : -_size, _auxprice, _globalIdService.GetNextOrderId()); break; case 5: _workingorder = new TrailingStopLimitOrder(_fullsymbol, _selectedbuysell == 0 ? _size : -_size, _price, _auxprice, _globalIdService.GetNextOrderId()); break; } _workingorder.OrderStatus = OrderStatus.PendingSubmit; _eventaggregator.GetEvent <SendOrderEvent>().Publish(_workingorder); }