public static TWSClient GetSocket(string host, int port) { var address = IPAddress.Loopback; var localAddress = IPAddress.Loopback; foreach (IPAddress a in Dns.GetHostEntry(host).AddressList) { if (a.AddressFamily == AddressFamily.InterNetwork) address = a; else continue; if (a == IPAddress.Loopback) break; } var 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; }
public TWSContractDetailsEventArgs(TWSClient client) : base(client) { }
private void ConnectToTWS(string host, int port) { _client = TWSSocketFactory.GetSocket(host, port); _client.RecordForPlayback = (bool) (recordMarketDataButton.Tag ?? false); _client.Settings = _settings; AddGenericClientEventHandlers(); _symbolDataMap = new Dictionary<IBContract, InstrumentDataRecord>(); _client.Connect(); }
public TWSClientErrorEventArgs(TWSClient client) : base(client) { }
public TWSClientEventArgs(TWSClient client) { Client = client; }
public TWSScannerParametersEventArgs(TWSClient client) : base(client) { }
public TWSRealtimeBarEventArgs(TWSClient client) : base(client) { }
public TWSMarketDepthEventArgs(TWSClient client) : base(client) { }
public TWSTickStringEventArgs(TWSClient client) : base(client) { }
public TWSTickGenericEventArgs(TWSClient client) : base(client) { }
public TWSTickSizeEventArgs(TWSClient client) : base(client) { }
public TWSTickPriceEventArgs(TWSClient client) : base(client) { }
public static void ReleaseSocket(TWSClient client) { lock (_refCount) { _refCount[client]--; if (_refCount[client] != 0) return; client.Disconnect(); _refCount.Remove(client); _sockets.Remove(client.EndPoint); } }
public TWSUpdatePortfolioEventArgs(TWSClient client) : base(client) { }
public TWSTickEFPEventArgs(TWSClient client) : base(client) { }
public TWSExecutionDetailsEventArgs(TWSClient client) : base(client) { }
public TWSTickOptionComputationEventArgs(TWSClient client) : base(client) { }
public TWSHistoricalDataEventArgs(TWSClient client) : base(client) { }
public TWSCurrentTimeEventArgs(TWSClient client) : base(client) { }
internal TWSScannerDataEventArgs(TWSClient client) : base(client) { }
public TWSMarketDataEventArgs(TWSClient client) : base(client) { }
internal TWSOrderChangedEventArgs(TWSClient client, OrderRecord or) : base(client) { OriginalOrder = or.Order; OriginalContract = or.Contract; OrderId = or.OrderId; }
public TWSOrderStatusEventArgs(TWSClient client) : base(client) { }
public TWSClientStatusEventArgs(TWSClient client, TWSClientStatus status) : base(client) { Status = status; }
public TWSOpenOrderEventArgs(TWSClient client) : base(client) { }
public TWSClientExceptionEventArgs(TWSClient client) : base(client) { }
private void ConnectToPlayback(string fileName) { _client = _playback = new TWSPlaybackClient(fileName); _client.Settings = _settings; AddGenericClientEventHandlers(); _symbolDataMap = new Dictionary<IBContract, InstrumentDataRecord>(); }