Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit 8a7e5b7

Browse files
authored
Merge pull request #1 from nickpellant/support-customisable-hosts-for-ibproxy-server
Suport customisable hosts for ibproxy server
2 parents 375eac3 + ca204d6 commit 8a7e5b7

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

bin/ibproxy

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,28 @@ default_command :server
1818
command :server do |c|
1919
c.syntax = 'ibproxy server [options]'
2020
c.summary = 'Start ibproxy server'
21-
c.option '--ib-port PORT', Integer, "Interactive brokers client port. #{IbRubyProxy::Server::IbProxyService::DEFAULT_IB_GATEWAY_PORT} by default (Gateway). Default for TWS is whatever"
21+
22+
c.option '--ib-host HOST', String, "Host for interactive brokers client. #{IbRubyProxy::Server::IbProxyService::DEFAULT_IB_HOST} by default"
23+
c.option '--ib-port PORT', Integer, "Port for interactive brokers client. #{IbRubyProxy::Server::IbProxyService::DEFAULT_IB_GATEWAY_PORT} by default (Gateway). Default for TWS is whatever"
24+
c.option '--drb-host HOST', String, "Host for the server drb endpoint. #{IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_HOST} by default"
2225
c.option '--drb-port PORT', Integer, "Port for the served drb endpoint. #{IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_PORT} by default"
26+
2327
c.action do |args, options|
24-
options.default ib_port: IbRubyProxy::Server::IbProxyService::DEFAULT_IB_GATEWAY_PORT,
25-
drb_port: IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_PORT
28+
options.default(
29+
ib_host: IbRubyProxy::Server::IbProxyService::DEFAULT_IB_HOST,
30+
ib_port: IbRubyProxy::Server::IbProxyService::DEFAULT_IB_GATEWAY_PORT,
31+
drb_host: IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_HOST,
32+
drb_port: IbRubyProxy::Server::IbProxyService::DEFAULT_DRB_PORT,
33+
)
34+
35+
ib_host = options.ib_host
2636
ib_port = options.ib_port
37+
drb_host = options.drb_host
2738
drb_port = options.drb_port
39+
2840
puts "Starting with ib port #{ib_port} and drb port #{drb_port}..."
29-
IbRubyProxy::Server::IbProxyService.new(ib_port: ib_port, drb_port: drb_port).start
41+
IbRubyProxy::Server::IbProxyService.new(
42+
ib_host: ib_host, ib_port: ib_port, drb_host: drb_host, drb_port: drb_port
43+
).start
3044
end
3145
end
32-

lib/ib_ruby_proxy/server/ib_proxy_service.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ module Server
2020
# * Starts an IB message-processing thread that will dispatch messages sent to IB client app (
2121
# gateway or TWS)
2222
class IbProxyService
23+
DEFAULT_IB_HOST = 'localhost'
2324
DEFAULT_IB_GATEWAY_PORT = 4002
25+
DEFAULT_DRB_HOST = 'localhost'
2426
DEFAULT_DRB_PORT = 1992
2527

2628
# @param [String] ib_host Hostname for the IB client app (gateway or TWS). Default +localhost+
2729
# @param [Integer] ib_port Port for hte IB client app (gateway or TWS). Default +4002+ (gateway)
2830
# @param [String] drb_host Hostname for the DRB process. Default +localhost+
2931
# @param [Integer] drb_port Port for the . Default +1992+
30-
def initialize(ib_host: 'localhost', ib_port: DEFAULT_IB_GATEWAY_PORT,
31-
drb_host: 'localhost', drb_port: DEFAULT_DRB_PORT)
32+
def initialize(ib_host: DEFAULT_IB_HOST, ib_port: DEFAULT_IB_GATEWAY_PORT,
33+
drb_host: DEFAULT_DRB_HOST, drb_port: DEFAULT_DRB_PORT)
3234
@ib_host = ib_host
3335
@ib_port = ib_port
3436
@drb_host = drb_host

0 commit comments

Comments
 (0)