Пример #1
0
    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;
    }
Пример #2
0
 public TWSContractDetailsEventArgs(TWSClient client) : base(client)
 {
 }
Пример #3
0
    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();
    }
Пример #4
0
 public TWSClientErrorEventArgs(TWSClient client) : base(client)
 {
 }
Пример #5
0
 public TWSClientEventArgs(TWSClient client)
 {
   Client = client;
 }
Пример #6
0
 public TWSScannerParametersEventArgs(TWSClient client) : base(client) { }
Пример #7
0
 public TWSRealtimeBarEventArgs(TWSClient client) : base(client) { }
Пример #8
0
 public TWSMarketDepthEventArgs(TWSClient client) : base(client)
 {
 }
Пример #9
0
 public TWSTickStringEventArgs(TWSClient client) : base(client)
 {
 }
Пример #10
0
 public TWSTickGenericEventArgs(TWSClient client) : base(client)
 {
 }
Пример #11
0
 public TWSTickSizeEventArgs(TWSClient client) : base(client)
 {
 }
Пример #12
0
 public TWSTickPriceEventArgs(TWSClient client) : base(client)
 {
 }
Пример #13
0
 public static void ReleaseSocket(TWSClient client)
 {
   lock (_refCount) {
     _refCount[client]--;
     if (_refCount[client] != 0) return;
     client.Disconnect();
     _refCount.Remove(client);
     _sockets.Remove(client.EndPoint);
   }
 }
Пример #14
0
 public TWSUpdatePortfolioEventArgs(TWSClient client) : base(client)
 {
 }
Пример #15
0
 public TWSTickEFPEventArgs(TWSClient client) : base(client)
 {
 }
Пример #16
0
 public TWSExecutionDetailsEventArgs(TWSClient client) : base(client)
 {
 }
Пример #17
0
 public TWSTickOptionComputationEventArgs(TWSClient client) : base(client)
 {
 }
Пример #18
0
 public TWSHistoricalDataEventArgs(TWSClient client) : base(client) { }
Пример #19
0
 public TWSCurrentTimeEventArgs(TWSClient client) : base(client)
 {
 }
Пример #20
0
 internal TWSScannerDataEventArgs(TWSClient client) : base(client) { }
Пример #21
0
 public TWSMarketDataEventArgs(TWSClient client) : base(client)
 {
 }
Пример #22
0
 internal TWSOrderChangedEventArgs(TWSClient client, OrderRecord or) : base(client)
 {
   OriginalOrder = or.Order;
   OriginalContract = or.Contract;
   OrderId = or.OrderId;
 }
Пример #23
0
 public TWSOrderStatusEventArgs(TWSClient client) : base(client)
 {
 }
Пример #24
0
 public TWSClientStatusEventArgs(TWSClient client, TWSClientStatus status) : base(client)
 {
   Status = status;
 }
Пример #25
0
 public TWSOpenOrderEventArgs(TWSClient client) : base(client)
 {
 }
Пример #26
0
 public TWSClientExceptionEventArgs(TWSClient client) : base(client)
 {
 }
Пример #27
0
    private void ConnectToPlayback(string fileName)
    {
      _client = _playback = new TWSPlaybackClient(fileName);
      _client.Settings = _settings;

      AddGenericClientEventHandlers();

      _symbolDataMap = new Dictionary<IBContract, InstrumentDataRecord>();
    }