static void ConditionalOrders() { while (true) { Console.WriteLine("I)FDOCO trailing"); Console.WriteLine("L)imit IFDOCO"); Console.WriteLine("T)railing IFDOCO"); Console.WriteLine("E)xpire test"); Console.WriteLine("F)OK test"); Console.WriteLine("C)ancel last order"); Console.WriteLine("X) Close position"); Console.WriteLine(); Console.Write("Main/Conditional Orders>"); switch (GetCh()) { case 'I': switch (SelectSide()) { case BfTradeSide.Buy: PlaceOrder(BfxOrder.IFDOCO( BfxOrder.Limit(BfTradeSide.Buy, _market.BestBidPrice, _orderSize), BfxOrder.Trailing(BfTradeSide.Sell, TrailingOffset, _orderSize), BfxOrder.Stop(BfTradeSide.Sell, _market.BestAskPrice - PnLGap, _orderSize) )); break; case BfTradeSide.Sell: PlaceOrder(BfxOrder.IFDOCO( BfxOrder.Limit(BfTradeSide.Sell, _market.BestAskPrice, _orderSize), BfxOrder.Trailing(BfTradeSide.Buy, TrailingOffset, _orderSize), BfxOrder.Stop(BfTradeSide.Buy, _market.BestBidPrice + PnLGap, _orderSize) )); break; } break; case 'L': switch (SelectSide()) { case BfTradeSide.Buy: { var buyPrice = _market.BestBidPrice; PlaceOrder(BfxOrder.IFDOCO( BfxOrder.Limit(BfTradeSide.Buy, buyPrice, _orderSize), BfxOrder.StopLimit(BfTradeSide.Sell, buyPrice - PnLGap, buyPrice - PnLGap, _orderSize), BfxOrder.Limit(BfTradeSide.Sell, buyPrice + PnLGap * 2m, _orderSize) )); } break; case BfTradeSide.Sell: { var sellPrice = _market.BestAskPrice; PlaceOrder(BfxOrder.IFDOCO( BfxOrder.Limit(BfTradeSide.Sell, sellPrice, _orderSize), BfxOrder.StopLimit(BfTradeSide.Buy, sellPrice + PnLGap, sellPrice + PnLGap, _orderSize), BfxOrder.Limit(BfTradeSide.Buy, sellPrice - PnLGap * 2m, _orderSize) )); } break; } break; case 'T': switch (SelectSide()) { case BfTradeSide.Buy: { var buyPrice = _market.BestBidPrice; PlaceOrder(BfxOrder.IFDOCO( BfxOrder.Limit(BfTradeSide.Buy, buyPrice, _orderSize), BfxOrder.Trailing(BfTradeSide.Sell, PnLGap, _orderSize), BfxOrder.Limit(BfTradeSide.Sell, buyPrice + PnLGap * 2, _orderSize) )); } break; case BfTradeSide.Sell: { var sellPrice = _market.BestAskPrice; PlaceOrder(BfxOrder.IFDOCO( BfxOrder.Limit(BfTradeSide.Sell, sellPrice, _orderSize), BfxOrder.Trailing(BfTradeSide.Buy, PnLGap, _orderSize), BfxOrder.Limit(BfTradeSide.Buy, sellPrice - PnLGap * 2, _orderSize) )); } break; } break; case 'E': PlaceOrder(BfxOrder.OCO( BfxOrder.Limit(BfTradeSide.Sell, _market.BestAskPrice + UnexecutableGap, _orderSize), BfxOrder.Limit(BfTradeSide.Buy, _market.BestBidPrice - UnexecutableGap, _orderSize)), TimeSpan.FromMinutes(1), BfTimeInForce.NotSpecified ); break; case 'F': PlaceOrder(BfxOrder.OCO( BfxOrder.Limit(BfTradeSide.Sell, _market.BestAskPrice + UnexecutableGap, _orderSize), BfxOrder.Limit(BfTradeSide.Buy, _market.BestBidPrice - UnexecutableGap, _orderSize)), TimeSpan.Zero, BfTimeInForce.FOK ); break; case 'C': CancelOrder(); break; case 'X': ClosePositions(); break; case ESCAPE: return; } } }
static void SimpleOrders() { while (true) { Console.WriteLine("L)imit price order best ask/bid price"); Console.WriteLine("M)arket price order"); Console.WriteLine("T)railing"); Console.WriteLine("E)xpire test"); Console.WriteLine("F)OK"); Console.WriteLine("C)ancel last order"); Console.WriteLine("X) Close position"); Console.WriteLine(); Console.Write("Main/Simple Orders>"); switch (GetCh()) { case 'L': switch (SelectSide()) { case BfTradeSide.Buy: PlaceOrder(BfxOrder.Limit(BfTradeSide.Buy, _market.BestBidPrice, _orderSize)); break; case BfTradeSide.Sell: PlaceOrder(BfxOrder.Limit(BfTradeSide.Sell, _market.BestAskPrice, _orderSize)); break; } break; case 'M': switch (SelectSide()) { case BfTradeSide.Buy: PlaceOrder(BfxOrder.Market(BfTradeSide.Buy, _orderSize)); break; case BfTradeSide.Sell: PlaceOrder(BfxOrder.Market(BfTradeSide.Sell, _orderSize)); break; } break; case 'T': switch (SelectSide()) { case BfTradeSide.Buy: PlaceOrder(BfxOrder.Trailing(BfTradeSide.Buy, PnLGap * 2, _orderSize)); break; case BfTradeSide.Sell: PlaceOrder(BfxOrder.Trailing(BfTradeSide.Sell, PnLGap * 2, _orderSize)); break; } break; case 'E': PlaceOrder(BfxOrder.Limit(BfTradeSide.Buy, _market.BestBidPrice - UnexecutableGap, _orderSize), TimeSpan.FromMinutes(1), BfTimeInForce.NotSpecified); break; case 'F': PlaceOrder(BfxOrder.Limit(BfTradeSide.Buy, _market.BestBidPrice - UnexecutableGap, _orderSize), TimeSpan.Zero, BfTimeInForce.FOK); break; case 'C': CancelOrder(); break; case 'X': ClosePositions(); break; case ESCAPE: return; } } }