Inheritance: TWSLib.IContract
示例#1
0
 public PositionMessage(string account, IBApi.Contract contract, double pos, double avgCost)
 {
     Account     = account;
     Contract    = contract;
     Position    = pos;
     AverageCost = avgCost;
 }
示例#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;
 }
示例#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;

        }
示例#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;
 }
示例#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;
 }
示例#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;

        }
示例#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);
        }
示例#10
0
文件: Contract.cs 项目: uaqeel/ZeusXL
        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;
        }
示例#11
0
 public ExecutionMessage(int reqId, IBApi.Contract contract, Execution execution)
 {
     ReqId     = reqId;
     Contract  = contract;
     Execution = execution;
 }
示例#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;
 }
示例#13
0
 public CompletedOrderMessage(IBApi.Contract contract, IBApi.Order order, OrderState orderState)
 {
     Contract   = contract;
     Order      = order;
     OrderState = orderState;
 }