how to install ib ruby api?

P

Pen Ttt

in my console,
laptop:~$ svn checkout svn://rubyforge.org/var/svn/ib-ruby
A ib-ruby/trunk
A ib-ruby/trunk/datatypes.rb
A ib-ruby/trunk/LICENSE
require 'rubygems'
=> true
irb(main):003:0> require 'ib'
LoadError: no such file to load -- ib
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from (irb):3
from :0
what's wrong?
 
P

Priyank Shah

Pen said:
in my console,
laptop:~$ svn checkout svn://rubyforge.org/var/svn/ib-ruby
A ib-ruby/trunk
A ib-ruby/trunk/datatypes.rb
A ib-ruby/trunk/LICENSE
require 'rubygems'
=> true
irb(main):003:0> require 'ib'
LoadError: no such file to load -- ib
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from (irb):3
from :0
what's wrong?


Hi,

Don't Know but check this if it may help you for install ibruby gem,

http://rubyforge.org/projects/ibruby/

http://rubyforge.org/frs/?group_id=2573&release_id=14283
 
B

Brian Candler

Pen said:
in my console,
laptop:~$ svn checkout svn://rubyforge.org/var/svn/ib-ruby
A ib-ruby/trunk
A ib-ruby/trunk/datatypes.rb
A ib-ruby/trunk/LICENSE
require 'rubygems'
=> true
irb(main):003:0> require 'ib'
LoadError: no such file to load -- ib
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from (irb):3
from :0
what's wrong?

The library doesn't have a file called ib.rb, and/or the library's lib
directory is not in your $LOAD_PATH.

Try:

irb -I ib-ruby/trunk
require 'datatypes'

Or:
 
P

Pen Ttt

pt@pt-laptop:~$ irb -I ib-ruby/trunk
irb(main):001:0> require 'datatypes'
NameError: uninitialized constant IB::Logger
from ./ib-ruby/trunk/datatypes.rb:27
from (irb):1:in `require'
from (irb):1
from :0
irb(main):002:0> $:.unshift 'ib-ruby/trunk'
=> ["ib-ruby/trunk", "ib-ruby/trunk", "/usr/local/lib/site_ruby/1.8",
"/usr/local/lib/site_ruby/1.8/i486-linux",
"/usr/local/lib/site_ruby/1.8/i386-linux", "/usr/local/lib/site_ruby",
"/usr/lib/ruby/vendor_ruby/1.8",
"/usr/lib/ruby/vendor_ruby/1.8/i486-linux", "/usr/lib/ruby/vendor_ruby",
"/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/i486-linux",
"/usr/lib/ruby/1.8/i386-linux", "."]
irb(main):003:0> require 'datatypes'
NameError: uninitialized constant IB::Logger
from ./ib-ruby/trunk/datatypes.rb:27
from (irb):3:in `require'
from (irb):3
from :0
irb(main):004:0> require 'ib'
=> true
irb(main):005:0>

maybe it is ok,but i don't know why?
 
B

Brian Candler

Pen said:
pt@pt-laptop:~$ irb -I ib-ruby/trunk
irb(main):001:0> require 'datatypes'
NameError: uninitialized constant IB::Logger
from ./ib-ruby/trunk/datatypes.rb:27

Well, I only suggested require 'datatypes' because you showed
datatypes.rb as the only file checked out.

Looking on rubyforge, I see there are others. There is an examples/
directory. Use it. The examples say

require 'ib'

rather than

require 'datatypes'

(and I see that ib.rb in turn requires iblogger.rb)
 
P

Pen Ttt

hi,everyone,think for your help,it's ok now

irb -I ib-ruby/trunk
irb(main):001:0> $:.unshift 'ib-ruby/trunk'
irb(main):002:0> require 'ib'
=> true
irb(main):005:0> ib = IB::IB.new()
=> #<IB::IB:0xb7638e10
@listeners={IB::IncomingMessages::NextValidID=>[#<Proc:0xb76c30c4@./ib-ruby/trunk/ib.rb:119>]},
@server={:remote_connect_time=>"20100914 08:07:10 EST", :client_id=> ,
:socket=>#<IB::IBSocket: >, :reader_thread=>#<Thread:0xb7638820 sleep>,
:local_connect_time=>Tue Sep 14 20:07:13 -0400 2010, :version=>49},
@next_order_id=nil, @options={:ip=>"127.0.0.1", :port=>"7496"},
@connected=true>
irb(main):006:0>
i have read :http://ib-ruby.rubyforge.org/
still don't know how to use it
for example, if i want to get the stock yhoo(yahoo) qoute from 2010-1-1
till 2010-9-1
date,open,high,low,close,vol
would you mind to tell me to do it?
any advice appreciated.
 
P

Pen Ttt

it's ok now,

pt@pt-laptop:~$ irb
irb(main):001:0> $:.unshift 'ib-ruby/trunk'
=> ["ib-ruby/trunk", "/usr/local/lib/site_ruby/1.8",
"/usr/local/lib/site_ruby/1.8/i486-linux",
"/usr/local/lib/site_ruby/1.8/i386-linux", "/usr/local/lib/site_ruby",
"/usr/lib/ruby/vendor_ruby/1.8",
"/usr/lib/ruby/vendor_ruby/1.8/i486-linux", "/usr/lib/ruby/vendor_ruby",
"/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/i486-linux",
"/usr/lib/ruby/1.8/i386-linux", "."]
irb(main):002:0> require 'ib'
=> true
irb(main):003:0> require 'datatypes'
=> true
irb(main):004:0>

when i close my irb,re-open it
irb(main):005:0> quit
pt@pt-laptop:~$ irb
irb(main):001:0> require 'ib'
LoadError: no such file to load -- ib
from (irb):1:in `require'
from (irb):1
from :0
irb(main):002:0>
i don't want to input $:.unshift 'ib-ruby/trunk' everytime when i
want to use it,how to solve it ?
 
P

Pen Ttt

there is file in "/home/pt/ib-ruby/trunk/ib.rb"
pt@pt-laptop:~$ irb
irb(main):001:0> require "/home/pt/ib-ruby/trunk/ib.rb"
LoadError: no such file to load -- messages
from /home/pt/ib-ruby/trunk/ib.rb:26:in `require'
from /home/pt/ib-ruby/trunk/ib.rb:26
from (irb):1:in `require'
from (irb):1
from :0
irb(main):002:0>
why i can't require it ?
 
R

Ryan Davis

there is file in "/home/pt/ib-ruby/trunk/ib.rb"
pt@pt-laptop:~$ irb
irb(main):001:0> require "/home/pt/ib-ruby/trunk/ib.rb"
LoadError: no such file to load -- messages
from /home/pt/ib-ruby/trunk/ib.rb:26:in `require'
from /home/pt/ib-ruby/trunk/ib.rb:26
from (irb):1:in `require'
from (irb):1
from :0
irb(main):002:0>
why i can't require it ?

Did you read the error message?
 
B

Brian Candler

Pen said:
i don't want to input $:.unshift 'ib-ruby/trunk' everytime when i
want to use it,how to solve it ?

option 1: start your session with

irb -Iib-ruby/trunk

option 2: put the $:.unshift 'ib-ruby/trunk' into a file called boot.rb,
then you just do require 'boot' before require 'ib'

option 3: install the ib gem (and then require 'rubygems'; require 'ib')

option 4: put the session setup into ~/.irbrc [not recommended, you
don't want all your sessions to have this]

option 5: copy all the ib code into the current directory [messy]

If you are building an application, I would be inclined to make a
vendor/ subdirectory and install ib under that, and have a boot.rb which
adds it to $:. Your app just needs require 'boot' at the top.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top