Ejemplo n.º 1
0
        public static IBSocket SendDeltaNeutral(this IBSocket socket, IBOrderCondition condition)
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

            var volatility = condition.Volatility;

            if (socket.ServerVersion < ServerVersions.V28)
            {
                return(socket.Send(volatility.OrderType == OrderTypes.Market));
            }
            else
            {
                socket.SendOrderType(volatility.OrderType, volatility.ExtendedOrderType);
                socket.Send(volatility.StopPrice);

                if (volatility.ExtendedOrderType != IBOrderCondition.ExtendedOrderTypes.Empty)
                {
                    if (socket.ServerVersion >= ServerVersions.V58)
                    {
                        socket
                        .Send(volatility.ConId)
                        .Send(volatility.SettlingFirm)
                        .SendPortfolio(volatility.ClearingPortfolio)
                        .Send(volatility.ClearingIntent);
                    }

                    if (socket.ServerVersion >= ServerVersions.V66)
                    {
                        socket
                        .Send(volatility.ShortSale.IsOpenOrClose)
                        .Send(volatility.IsShortSale)
                        .SendShortSale(volatility.ShortSale);
                    }
                }

                return(socket);
            }
        }