示例#1
0
 public TWSClientErrorEventArgs(TWSClient client, int tickerId, IBContract contract, TWSError error)
     : base(client)
 {
     RequestId = tickerId;
     Error = error;
     Contract = contract;
 }
示例#2
0
 public TWSTickStringEventArgs(TWSClient client, int requestId, IBTickType tickType, string value)
     : base(client)
 {
     RequestId = requestId;
     TickType = tickType;
     Value = value;
 }
示例#3
0
 public TWSTickSizeEventArgs(TWSClient client, int requestId, IBTickType sizeTickType, int size)
     : base(client)
 {
     RequestId = requestId;
     TickType = sizeTickType;
     Size = size;
 }
示例#4
0
 public TWSTickPriceEventArgs(TWSClient client, int requestId, IBTickType tickType, 
     double price, int size, int canAutoExecute)
     : base(client)
 {
     RequestId = requestId;
     TickType = tickType;
     Price = price;
     Size = size;
     CanAutoExecute = canAutoExecute;
 }
示例#5
0
 public TWSTickOptionComputationEventArgs(TWSClient client, int reqId, IBTickType tickType,
     double impliedVol, double delta, double modelPrice, double pvDividend)
     : base(client)
 {
     RequestId = reqId;
     TickType = tickType;
     ImpliedVol = impliedVol;
     Delta = delta;
     ModelPrice = modelPrice;
     PVDividend = pvDividend;
 }
示例#6
0
 public TWSTickGenericEventArgs(TWSClient client, int requestId, IBTickType tickType, double value)
     : base(client)
 {
     RequestId = requestId;
     TickType = tickType;
     Value = value;
 }
示例#7
0
 public TWSContractDetailsEventArgs(TWSClient client, IBContractDetails contractDetails)
     : base(client)
 {
     ContractDetails = contractDetails;
 }
示例#8
0
 public static void ReleaseSocket(TWSClient client)
 {
     lock (_refCount) {
         _refCount[client]--;
         if (_refCount[client] == 0) {
             client.Disconnect();
             _refCount.Remove(client);
             _sockets.Remove(client.EndPoint);
         }
     }
 }
示例#9
0
 public TWSOrderStatusEventArgs(TWSClient client, int orderID, string status, int filled, int remaining, double avgFillPrice, 
     int permID, int parentID, double lastFillPrice, int clientID, string whyHeld)
     : base(client)
 {
     OrderID = orderID;
     Status = status;
     Filled = filled;
     Remaining = remaining;
     AvgFillPrice = avgFillPrice;
     PermID = permID;
     ParentID = parentID;
     LastFillPrice = lastFillPrice;
     ClientID = clientID;
     WhyHeld = whyHeld;
 }
示例#10
0
 public TWSOpenOrderEventArgs(TWSClient client, int orderId, IBOrder order, IBContract contract)
     : base(client)
 {
     OrderId = orderId;
     Order = order;
     Contract = contract;
 }
示例#11
0
 public TWSMarketDepthEventArgs(TWSClient client, int requestId, int position, 
     string marketMaker, IBOperation operation,
     IBSide side, double price, int size)
     : base(client)
 {
     RequestId = requestId;
     Position = position;
     MarketMaker = marketMaker;
     Operation = operation;
     Side = side;
     Price = price;
     Size = size;
 }
示例#12
0
 public TWSMarketDataEventArgs(TWSClient client, 
     TWSMarketDataSnapshot snapshot, IBTickType tickType)
     : base(client)
 {
     TickType = tickType;
     Snapshot = snapshot;
 }
示例#13
0
 public TWSHistoricalDataEventArgs(TWSClient client, int tickerId, 
     TWSHistoricState state, DateTime date,
     double open, double high, double low, double close,
     int volume, double wap, bool hasGaps)
     : base(client)
 {
     TickerId = tickerId;
     State = state;
     Date = date;
     Open = open;
     High = high;
     Low = low;
     Close = close;
     Volume = volume;
     WAP = wap;
     HasGaps = hasGaps;
 }
示例#14
0
 public TWSExecDetailsEventArgs(TWSClient client, int orderId, IBContract contract, IBExecution execution)
     : base(client)
 {
     OrderId = orderId;
     Contract = contract;
     Execution = execution;
 }
示例#15
0
 public TWSCurrentTimeEventArgs(TWSClient client, long time)
     : base(client)
 {
     Time = DateTime.FromFileTimeUtc(time);
 }
示例#16
0
 public TWSUpdatePortfolioEventArgs(TWSClient client, IBContract contract, int position,
     double marketPrice, double marketValue, double averageCost,
     double unrealizedPNL, double realizedPNL, string accountName)
     : base(client)
 {
     Contract = contract;
     Position = position;
     MarketPrice = marketPrice;
     MarketValue = marketValue;
     AverageCost = averageCost;
     UnrealizedPnL = unrealizedPNL;
     RealizedPnL = realizedPNL;
     AccountName = accountName;
 }
示例#17
0
 public TWSClientEventArgs(TWSClient client)
 {
     Client = client;
 }
示例#18
0
 public TWSTickEFPEventArgs(TWSClient client, int requestId, IBTickType tickType, double basisPoints, 
     string formattedBasisPoints, double impliedFuturesPrice, int holdDays,
     string futureExpiry, double dividendImpact, double dividendsToExpiry)
     : base(client)
 {
     RequestId = requestId;
     TickType = tickType;
     BasisPoints = basisPoints;
     FormattedBasisPoints = formattedBasisPoints;
     ImpliedFuturesPrice = impliedFuturesPrice;
     HoldDays = holdDays;
     FutureExpiry = futureExpiry;
     DividendImpact = dividendImpact;
     DividendsToExpiry = dividendsToExpiry;
 }
示例#19
0
        public static TWSClient GetSocket(string host, int port)
        {
            IPAddress address = IPAddress.Loopback;
            IPAddress localAddress = IPAddress.Loopback;
            foreach (var a in Dns.GetHostEntry(host).AddressList)
            {
                if (a.AddressFamily == AddressFamily.InterNetwork)
                    address = a;
                else
                    continue;

                if (a == IPAddress.Loopback)
                    break;

            }

            IPEndPoint endPoint = new IPEndPoint(address, port);
            TWSClient socket;

            lock (_refCount) {
                if (!_sockets.TryGetValue(endPoint, out socket)) {
                    _sockets.Add(endPoint, socket = new TWSClient(endPoint));
                    _refCount.Add(socket, 0);
                }

                _refCount[socket]++;
            }
            return socket;
        }
示例#20
0
 public TWSClientStatusEventArgs(TWSClient client, TWSClientStatus status)
     : base(client)
 {
     Status = status;
 }