Inheritance: TWSLib.IContract
Esempio n. 1
0
 public PositionMessage(string account, IBApi.Contract contract, double pos, double avgCost)
 {
     Account     = account;
     Contract    = contract;
     Position    = pos;
     AverageCost = avgCost;
 }
Esempio n. 2
0
 public OpenOrderMessage(int orderId, IBApi.Contract contract, IBApi.Order order, OrderState orderState)
 {
     OrderId    = orderId;
     Contract   = contract;
     Order      = order;
     OrderState = orderState;
 }
 public OrderStatusMessage(int orderId, Contract contract, IBApi.Order order, OrderState orderstate)
 {
     MessageType = MessageType.OrderStatus;
     OrderId = orderId;
     Contract = contract;
     Order = order;
     OrderState = orderstate;
 }
Esempio n. 4
0
 private MarketDepthSubscription CreateMarketDepthSubscription()
 {
     var contract = new Contract();
     var marketDepthSubscription = new MarketDepthSubscription(this.connectionHelper.Connection(),
         this.connectionHelper.Dispenser(),
         this.observerMock.Object, contract);
     return marketDepthSubscription;
 }
        public ExecutionMessage(int reqId, Contract contract, Execution execution)
        {
            MessageType = MessageType.ExecutionDetails;
            ReqId = reqId;
            Contract = contract;
            Execution = execution;

        }
Esempio n. 6
0
 public PositionMultiMessage(int reqId, string account, string modelCode, IBApi.Contract contract, double pos, double avgCost)
 {
     ReqId       = reqId;
     Account     = account;
     ModelCode   = modelCode;
     Contract    = contract;
     Position    = pos;
     AverageCost = avgCost;
 }
Esempio n. 7
0
 public UpdatePortfolioMessage(IBApi.Contract contract, double position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, string accountName)
 {
     Contract      = contract;
     Position      = position;
     MarketPrice   = marketPrice;
     MarketValue   = marketValue;
     AverageCost   = averageCost;
     UnrealizedPNL = unrealizedPNL;
     RealizedPNL   = realizedPNL;
     AccountName   = accountName;
 }
Esempio n. 8
0
        public Contract GetIBContract()
        {
            var c = new Contract();
            c.Symbol = InteractiveBrokersDetails.Symbol;
            c.Currency = InteractiveBrokersDetails.Currency;
            c.SecType = InteractiveBrokersDetails.SecType;
            c.Exchange = InteractiveBrokersDetails.Exchange;
            c.Expiry = InteractiveBrokersDetails.Expiry;

            return c;

        }
Esempio n. 9
0
        /// <summary>
        /// Place order.
        /// Order must have contract field.
        /// </summary>
        public void PlaceOrder(Order o)
        {
            if ((!o.IsValid) || (string.IsNullOrEmpty(o.FullSymbol)))
            {
                OnDebug("Order is not valid.");
                return;
            }

            IBApi.Order order = new IBApi.Order();

            order.AuxPrice = o.IsTrail ? (double)o.TrailPrice : (double)o.StopPrice;
            order.LmtPrice = (double)o.LimitPrice;

            // Only MKT, LMT, STP, and STP LMT, TRAIL, TRAIL LIMIT are supported
            order.OrderType = o.OrderType;

            order.TotalQuantity = o.UnsignedSize;
            order.Action        = o.OrderSide ? "BUY" : "SELL";  // SSHORT not supported here

            // order.Account = Account;
            order.Tif        = o.TIF.ToString();
            order.OutsideRth = true;
            //order.OrderId = (int)o.id;
            order.Transmit = true;
            if (string.IsNullOrEmpty(o.Account))
            {
                order.Account = Account;
            }
            else
            {
                order.Account = o.Account;
            }

            // Set up IB order Id
            if (o.Id == 0)
            {
                throw new ArgumentOutOfRangeException("Order id is missing.");
            }
            else // TODO: elimitate situation where strategy Order Id already exists
            {
                //order.OrderId = System.Threading.Interlocked.Increment(ref _nextValidIBID); // it returns the incremented id
                order.OrderId = (int)o.Id;
                _iborderIdToOrderInfo.Add(order.OrderId, new OrderInfo(o.Id, order.Account, false));
            }


            IBApi.Contract contract = SecurityFullNameToContract(o.FullSymbol);

            _ibSocket.placeOrder(order.OrderId, contract, order);
        }
Esempio n. 10
0
        public Contract(int id, string symbol, string type, string exchange, string currency, string primaryExchange,
                        int multiplier, string expiry, decimal strike, string right, string secIdType, string secId, string tradingClass, PositiveInteger lotSize)
        {
            IBContract = new IB.Contract();

            Id              = id;
            Symbol          = symbol;
            Type            = type;
            Exchange        = exchange;
            PrimaryExchange = primaryExchange;
            Currency        = currency;
            Multiplier      = multiplier;
            LastTradeDateOrContractMonth = expiry;

            Strike = (double)strike;
            Right  = right;

            SecIdType = secIdType;
            SecId     = secId;

            TradingClass = tradingClass;
        }
Esempio n. 11
0
 public ExecutionMessage(int reqId, IBApi.Contract contract, Execution execution)
 {
     ReqId     = reqId;
     Contract  = contract;
     Execution = execution;
 }
Esempio n. 12
0
 private QuoteSubscription CreateQuoteSubscription()
 {
     var contract = new Contract();
     var quoteSucription = new QuoteSubscription(this.connectionHelper.Connection(), this.connectionHelper.Dispenser(),
         this.observerMock.Object,
         contract);
     return quoteSucription;
 }
Esempio n. 13
0
 public CompletedOrderMessage(IBApi.Contract contract, IBApi.Order order, OrderState orderState)
 {
     Contract   = contract;
     Order      = order;
     OrderState = orderState;
 }