Skip to content
This repository was archived by the owner on Aug 10, 2021. It is now read-only.

add config_ib.rb as config file for most example ruby scripts. - #138

Open
laroche wants to merge 1 commit into
ib-ruby:masterfrom
laroche:lrdevel
Open

add config_ib.rb as config file for most example ruby scripts.#138
laroche wants to merge 1 commit into
ib-ruby:masterfrom
laroche:lrdevel

Conversation

@laroche

@laroche laroche commented Apr 21, 2019

Copy link
Copy Markdown
Contributor

add config_ib.rb as config file for most example ruby scripts.
try to improve example scripts, but mostly coding whitespace.

Would be nice to have this merged to have example scripts evolve
and hope further people jump in as well.
Let me know if specific items look all wrong, I am just starting with ruby.

best regards,

Florian La Roche

try to improve example scripts, but mostly coding whitespace.
@topofocus

Copy link
Copy Markdown
Member

Appreciate your work.
but disagree with your efforts to simplify the examples (at least in that way).
Off cause, you can delegate the definition of port and host to a config file.
Question is: why do you delegate only the definition of $port and $host (btw. the use of global variables in ruby is not recommended) and not the setting of client_id? Or – to put it further, why not concentrate

 IB::Connection.new  client_id:  1110, 
                       port:  7496, # TWS
                       host : 'localhost' 

in the config file and refer to it in the scripts via

 ib = IB::Connection.current  || IB::Connection.new( ....)

That simplifies and unifies the examples without breaking the code, ie. you can decide wether to setup config_ib.rb or to use just the single example file.

@laroche

laroche commented Apr 22, 2019

Copy link
Copy Markdown
Contributor Author

client_id should be different for all scripts to be able to run them at the same time. I've again hardcoded
client_id, the other possibility would be to remove this completely and rely on the builtin random numbers
to seldom be the same for concurrent executions. (Which would also allow for the same script to
run in parallel.)

Not sure Connection.new should be put into the config file. As "connect: true" is default, there is
then an actual network connection atempt each time?

The global vars are not nice, but they make sure the configuration only needs to be done
once instead for within each example script. Maybe using a small function to return the config
settings instead of global vars would be better. As example scripts I still like everything to stay
short.

best regards,

Florian La Roche

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants