Class: IbRubyProxy::Server::IbProxyService
- Inherits:
-
Object
- Object
- IbRubyProxy::Server::IbProxyService
- Defined in:
- lib/ib_ruby_proxy/server/ib_proxy_service.rb
Overview
Proxy service for invoking IB api through DRb
The proxy does essentially 2 things:
-
Starts a DRb process you can connect to invoke the IB api. This will expose an IbClientAdapter object to its clients
-
Starts an IB message-processing thread that will dispatch messages sent to IB client app ( gateway or TWS)
Constant Summary collapse
- DEFAULT_IB_GATEWAY_PORT =
4002
- DEFAULT_DRB_PORT =
1992
Instance Method Summary collapse
-
#initialize(ib_host: 'localhost', ib_port: DEFAULT_IB_GATEWAY_PORT, drb_host: 'localhost', drb_port: DEFAULT_DRB_PORT) ⇒ IbProxyService
constructor
A new instance of IbProxyService.
-
#start ⇒ void
Connects to IB and starts the DRb process.
Constructor Details
#initialize(ib_host: 'localhost', ib_port: DEFAULT_IB_GATEWAY_PORT, drb_host: 'localhost', drb_port: DEFAULT_DRB_PORT) ⇒ IbProxyService
Returns a new instance of IbProxyService.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ib_ruby_proxy/server/ib_proxy_service.rb', line 30 def initialize(ib_host: 'localhost', ib_port: DEFAULT_IB_GATEWAY_PORT, drb_host: 'localhost', drb_port: DEFAULT_DRB_PORT) @ib_host = ib_host @ib_port = ib_port @drb_host = drb_host @drb_port = drb_port @wrapper = IbRubyProxy::Server::IbWrapperAdapter.new @client = wrapper.client @signal = wrapper.signal connect end |
Instance Method Details
#start ⇒ void
This method returns an undefined value.
Connects to IB and starts the DRb process
Clients of the DRb service will get an IbRubyProxy::Server::IbClientAdapter object to interact with the IB api
48 49 50 51 52 53 54 |
# File 'lib/ib_ruby_proxy/server/ib_proxy_service.rb', line 48 def start DRb.start_service("druby://#{drb_host}:#{drb_port}", ib_client_adapter, verbose: true) puts "Ib proxy server started at druby://#{drb_host}:#{drb_port}. Connected to IB at"\ " #{ib_host}:#{ib_port}" DRb.thread.join end |