Giter Club home page Giter Club logo

ib-api's Introduction

ib-api

Ruby interface to Interactive Brokers' TWS API

Reimplementation of the basic functions of ib-ruby


Try the V10 branch (V 10.19)

  • Completed Zeitwerk integration.
  • Submitting of orders is still pending. (Aprl 2024)

Documentation: https://ib-ruby.github.io/ib-doc/ (work in progress)


ib-ruby offers a modular access to the TWS-API-Interface of Interactive Brokers.

ib-api provides a simple interface to low-level TWS API-calls.


Install in the usual way

$ gem install ib-api

In its plain vanilla usage, it just exchanges messages with the TWS. Any response is stored in the recieved-Array.

It needs just a few lines of code to place an order

require 'ib-api'
# connect with default parameters 
ib =  IB::Connection.new 

# define a contract to deal with
the_stock =  IB::Stock.new symbol: 'TAP'

# order 100 shares for 35 $ 
limit_order = IB::Order.new  limit_price: 35, order_type: 'LMT',  total_quantity: 100, action: :buy
ib.send_message :PlaceOrder,
        :order => limit_order,
        :contract => the_stock,
        :local_id => ib.next_local_id

# wait until the orderstate message returned
ib.wait_for :OrderStatus

# print the Orderstatus
puts ib.recieved[:OrderStatus].to_human

# => ["<OrderState: Submitted #17/1528367295 from 2000 filled 0.0/100.0 at 0.0/0.0 why_held >"]
User-specific Actions

Besides storing any TWS-response in an array, callbacks are implemented.

The user subscribes to a certain response and defines the actions in a typically ruby manner. These actions can be defined globaly

ib =  IB::Connection.new do |tws|
      # Subscribe to TWS alerts/errors and order-related messages
	tws.subscribe(:Alert, :OpenOrder, :OrderStatus, :OpenOrderEnd) { |msg| puts msg.to_human }
     end

or occationally

        # first define actions
	q =  Queue.new    # Initialize as Queue
	request_id = nil  # declare variable
	a = ib.subscribe(:Alert, :ContractData, :ContractDataEnd ) do |msg| 
		case msg
		when Messages::Incoming::Alert
			q.close if msg.code == 200   # No security found 
		when Messages::Incoming::ContractData  # security returned
			q.push msg.contract if msg.request_id == request_id
	        when Messages::Incoming::ContractDataEnd
		       q.close if msg.request_id == request_id
		end  # case
	end
        # perform request
        request_id = ib.send_message :RequestContractData, :contract => Stock.new(symbol: 'T')
        
	while contract = q.pop 
	  puts contract.as_table 
	end
┌───────┬────────┬──────────┬──────────┬────────┬────────────┬───────────────┬───────┬────────┬──────────┐
        symbol  con_id    exchange  expiry  multiplier  trading-class  right  strike  currency 
╞═══════╪════════╪══════════╪══════════╪════════╪════════════╪═══════════════╪═══════╪════════╪══════════╡
 Stock  T       37018770   SMART                              T                         USD    
└───────┴────────┴──────────┴──────────┴────────┴────────────┴───────────────┴───────┴────────┴──────────┘
  
        ib.unsubscribe a    # release subscriptions
         

Minimal TWS-Version

ib-api is tested via the stable IB-Gateway (Version 10.12) and should work with any current tws-installation.

Tests

are invoked by

bundle exec guard
# or
bundle exec rake spec

Integration tests on order-placements are not included. To run the test suite its thus safe to use a real Account. You have to edit spec/spec.yml and replace the :account-Setting with your own AccountID, even if you connect to a single account.

Contributing

Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Code of Conduct

Everyone interacting in the Core project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

ib-api's People

Contributors

dependabot[bot] avatar kvokka avatar metrix78 avatar moritzkork avatar topofocus avatar wizardofcrowds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ib-api's Issues

Question: Can i use ib-api to just monitor for new orders / fills?

Hi,

Sry if this isnt the proper place (i was looking for a place to ask a q and your doc says General support is provided through IB-Ruby Github-pages)

i am looking for a ruby implementation to monitor a financial advisor account (its sub accounts) for new orders / fills and want to store them in a rails model..

The use case would be:

  1. fire up a tws gateway on a server
  2. connect ib-api(?) to that gateway (read-only) and let it wait for new orders
  3. a user opens up the TWS somewhere and creates a new order
  4. ib-api realizes that new order and stores it in the db
  5. when the order gets filled / canceled, ib-api gets this message too and updates the order in the db

is ib-api the right tool for the job?

thanks so much!
Andreas

`ox` import raises an exception

This gem appears to depend on ox but for some reason it isn't being installed automatically. I recently installed the gem for a personal project, and upon installing it wrote a very simple bit of code literally just to connect to TWS and it raised an exception:

Traceback (most recent call last):
	24: from ./bin/tt:4:in `<main>'
	23: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	22: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	21: from /Users/myuser/Documents/Work/Personal/Trading/trade_tools/lib/main.rb:1:in `<top (required)>'
	20: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:34:in `require'
	19: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
	18: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:130:in `require'
	17: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/ib-api-972.5/lib/ib-api.rb:7:in `<top (required)>'
	16: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	15: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	14: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/ib-api-972.5/lib/requires.rb:8:in `<top (required)>'
	13: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	12: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	11: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/ib-api-972.5/lib/ib/connection.rb:6:in `<top (required)>'
	10: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	 9: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	 8: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/ib-api-972.5/lib/ib/messages.rb:13:in `<top (required)>'
	 7: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	 6: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	 5: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/ib-api-972.5/lib/ib/messages/incoming.rb:1:in `<top (required)>'
	 4: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	 3: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
	 2: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/ib-api-972.5/lib/ib/messages/incoming/abstract_message.rb:3:in `<top (required)>'
	 1: from /Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:117:in `require'
/Users/myuser/.asdf/installs/ruby/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:117:in `require': cannot load such file -- ox (LoadError)

Adding ox to my own Gemfile, or even just installing it with gem install ox makes it work, but shouldn't this get pulled in automatically?

Clarification on status of project. Abandoned?

IB's API is now 10.19 (stable; with 'latest' 10.28).
This project doesn't show recent development.
A last commit for VERSION file is "Update to Version 972.5.2" (aka v9.72).

As a person looking at the project there are different possibilities:

  1. there are no significant changes that IB has made (doubtful with in a major version bump?) and this project still works fine unchanged (but there is no such note which would be reassuring); or
  2. whatever was added to v10 is simply not supported by this project but previous stuff still works fine (again, no note though);
  3. nobody is really using it and nobody really knows if there are issues with v10;

What I was hoping to see wouldn't be much more than a single sentence with a reasonably recent date.
That would be somebody (a contributor, developer ideally) saying something like:

"i'm still using this project; i'm using it with latest API v10.19; there do not seem to be any outstanding issues (although X, Y, and Z that IB changed/added are not supported); but of course disclaimer you are using at your own risk as with any such software"

So, I'm simply asking for a heartbeat/read on things if I might.

Subscribing to market data with the latest TWS return error "Please use 'Key=Value' format for Misc options"

error:

2022-06-29 23:10:14.483 [TW] INFO [JTS-EServerSocket-180] - Failed to parse Key=Value for input='XYZ'
2022-06-29 23:10:14.483 [TW] INFO [JTS-EServerSocket-180] - [9442:137:137:1:0:0:0:ERR] Please use 'Key=Value' format for Misc Options

Code to reproduce:

  #!/usr/bin/env ruby                                                                                                                                                                         
  # frozen_string_literal: true                                                                                                                                                               
                                                                                                                                                                                              
  require 'rubygems'                                                                                                                                                                          
  require 'bundler/setup'                                                                                                                                                                     
  require 'ib-api'                                                                                                                                                                            
                                                                                                                                                                                              
  BROKER = IB::Connection.new host: 'metrix-desktop.localdomain', port: '7496'                                                                                                                
                                                                                                                                                                                              
  ## Subcribe to forseable events before the connection is completed                                                                                                                          
  ## Subscribe to TWS alerts/errors                                                                                                                                                           
  BROKER.subscribe(:Alert) { |msg| puts "ALERT: #{msg.to_human}" }                                                                                                                            
  BROKER.logger.level = Logger::DEBUG                                                                                                                                                         
                                                                                                                                                                                              
  BROKER.send_message :RequestMarketDataType, market_data_type: :delayed                                                                                                                      
  BROKER.send_message :RequestMarketData, id: 123, contract: IB::Stock.new(symbol: 'AMD')                                                                                                     
                                                                                                                                                                                              
ℹ                                                                                                                                                                                             
  sleep 60 

Specs don't run

I don't know if I'm missing something, but when I try and run the specs it says it cannot:

require "core"

And then the core spec does not run because it fails on:

RSpec.describe Core do

Is this "core" library another dependency which I don't have?

Apply rubocop

Project contain tons of hassle which makes reading the code harder, rubocop should heal it

problem with JPY futures options

i run this code to get contract data for a specific JPY futures option:

`ib = IB::Connection.new(:port => 7497) do |gw|
gw.subscribe(:Alert) {|msg| puts msg.to_human}
gw.subscribe(:ContractData) {|msg| puts msg.to_human}
end
ib.send_message(:RequestMarketDataType, :market_data_type => :real_time)

c = IB::FutureOption.new(symbol: "JPY", exchange: "GLOBEX", trading_class: "JPU", expiry: "20210305", strike: 0.01, right: "C")
ib.send_message(:RequestContractData, contract: c)
sleep 999999`

and this is the output:

<Contract <Option: JPY 20210305 call 0.0119 GLOBEX USD> <ContractDetails Japanese yen, --> JPU, Underlying:JYH1FUT, md_size_multiplier:1, min_tick:0.0000005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>
<Contract <Option: JPY 20210305 call 0.0113 GLOBEX USD> <ContractDetails Japanese yen, --> JPU, Underlying:JYH1FUT, md_size_multiplier:1, min_tick:0.0000005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>
<Contract <Option: JPY 20210305 call 0.0114 GLOBEX USD> <ContractDetails Japanese yen, --> JPU, Underlying:JYH1FUT, md_size_multiplier:1, min_tick:0.0000005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>
<Contract <Option: JPY 20210305 call 0.0115 GLOBEX USD> <ContractDetails Japanese yen, --> JPU, Underlying:JYH1FUT, md_size_multiplier:1, min_tick:0.0000005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>
<Contract <Option: JPY 20210305 call 0.0116 GLOBEX USD> <ContractDetails Japanese yen, --> JPU, Underlying:JYH1FUT, md_size_multiplier:1, min_tick:0.0000005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>
<Contract <Option: JPY 20210305 call 0.01025 GLOBEX USD> <ContractDetails Japanese yen, --> JPU, Underlying:JYH1FUT, md_size_multiplier:1, min_tick:0.0000005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>
<Contract <Option: JPY 20210305 call 0.01035 GLOBEX USD> <ContractDetails Japanese yen, --> JPU, Underlying:JYH1FUT, md_size_multiplier:1, min_tick:0.0000005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>

seems like i get all the strikes although i created a FutureOption with a specific strike.
the problem occurred with live/demo accounts on tws/gateway

when i run the same code for EUR futures option i get correct output:

<Contract <Option: EUR 20210305 call 1.22 GLOBEX USD> <ContractDetails European Monetary Union Euro, --> EUU, Underlying:ECH1FUT, md_size_multiplier:1, min_tick:0.00005, price_magnifier:1, valid exchanges: GLOBEX; order types: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,IOC,LIT,LMT,LTH,MIT,MKT,MKTPROT,MTL,NGCOMB,NONALGO,OCA,RFQ,SCALE,SCALERST,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF >>
No subscribers for message IB::Messages::Incoming::ContractDataEnd!

if you can look into it and figure out the problem that is great.
if you want me to contact you so we can test it on my system with my subscription that is great as well.

`require 'ib-api'` exits irb immediately

I'm trying to test a bit of code to see if everything works, but when I attempt to run the code in irb I have it exit immediately

> irb
irb(main):001:0> require 'ib-api'
=> true
irb(main):002:0>

This is the only output I get, nothing else at all!
I'm currently running the master branch of the codebase.

Sorry I can't provide much more info than this, I'm not getting any feedback whatsoever. If it helps, my setup is as follows:

OS: OS X 11.5
Ruby: 2.5.3p105

red specs while connecting to paper account

I changed my configuration in spec.yml as described in the readme and furthermore I changed the port to 7964 (TWS).
Running specs against my paper account returns several errors (e.g. spec/ib/integration/account_info_spec.rb)
Running spec/ib/integration/account_info_spec.rb with my real account success.

Is that a known problem or do I am something wrong?

problem with grains options prices

`#!/usr/bin/env ruby

require "ib-api"
require "pry-nav"

ib = IB::Connection.new(:port => 7497, :client_id => 1) do |gw|
gw.subscribe(:Alert) {|msg| puts msg.to_human}
gw.subscribe(:MarketDataType, :TickRequestParameters, :TickPrice, :TickSize, :TickString, :TickGeneric, :TickOption) do |msg|
puts "#{msg.created_at}\t#{msg.data[:ticker_id]}\t#{msg.data}" if msg.data[:tick_type] == 1 || msg.data[:tick_type] == 2
end
gw.subscribe(:TickSnapshotEnd) {}
end

contracts = Array.new
(500..580).step(5).each do |strike|
contracts.push IB::Option.new(sec_type: "FOP", symbol: "ZC", exchange: "ECBOT", trading_class: "OZC", expiry: "20210219", strike: strike, right: "C")
contracts.push IB::Option.new(sec_type: "FOP", symbol: "ZC", exchange: "ECBOT", trading_class: "OZC", expiry: "20210326", strike: strike, right: "C")
end
loop do
contracts.each {|contract| ib.send_message(:RequestMarketData, contract: contract, snapshot: 1)}
sleep 5
end`

this code requests some ZC options prices every 5 seconds and prints the api messages.
it works well. output example:

2021-01-29 08:21:15 -0500 7658 {:version=>6, :ticker_id=>7658, :tick_type=>1, :price=>6.25, :size=>1, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 7658 {:version=>6, :ticker_id=>7658, :tick_type=>2, :price=>6.625, :size=>384, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 9260 {:version=>6, :ticker_id=>9260, :tick_type=>1, :price=>52.125, :size=>171, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 9260 {:version=>6, :ticker_id=>9260, :tick_type=>2, :price=>53.25, :size=>171, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 6721 {:version=>6, :ticker_id=>6721, :tick_type=>1, :price=>48.75, :size=>171, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 6721 {:version=>6, :ticker_id=>6721, :tick_type=>2, :price=>50.0, :size=>171, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 9771 {:version=>6, :ticker_id=>9771, :tick_type=>1, :price=>45.5, :size=>191, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 9771 {:version=>6, :ticker_id=>9771, :tick_type=>2, :price=>46.5, :size=>1, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 4158 {:version=>6, :ticker_id=>4158, :tick_type=>1, :price=>42.625, :size=>204, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 4158 {:version=>6, :ticker_id=>4158, :tick_type=>2, :price=>43.5, :size=>235, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 4268 {:version=>6, :ticker_id=>4268, :tick_type=>1, :price=>39.75, :size=>188, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 4268 {:version=>6, :ticker_id=>4268, :tick_type=>2, :price=>40.5, :size=>1, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 805 {:version=>6, :ticker_id=>805, :tick_type=>1, :price=>37.0, :size=>195, :can_auto_execute=>1}
2021-01-29 08:21:15 -0500 805 {:version=>6, :ticker_id=>805, :tick_type=>2, :price=>37.75, :size=>1, :can_auto_execute=>1}

however, when i increase the time interval between api requests there is a problem with the rounding and the output is wrong and unusable.
i changed the sleep interval from 5 to 30 seconds and the output was like:

2021-01-29 08:26:31 -0500 2872 {:version=>6, :ticker_id=>2872, :tick_type=>2, :price=>25.0, :size=>223, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 1824 {:version=>6, :ticker_id=>1824, :tick_type=>1, :price=>50.0, :size=>90, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 1824 {:version=>6, :ticker_id=>1824, :tick_type=>2, :price=>50.0, :size=>1, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 7159 {:version=>6, :ticker_id=>7159, :tick_type=>1, :price=>37.5, :size=>205, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 7159 {:version=>6, :ticker_id=>7159, :tick_type=>2, :price=>50.0, :size=>156, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 3167 {:version=>6, :ticker_id=>3167, :tick_type=>1, :price=>37.5, :size=>139, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 3167 {:version=>6, :ticker_id=>3167, :tick_type=>2, :price=>37.5, :size=>264, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 3485 {:version=>6, :ticker_id=>3485, :tick_type=>1, :price=>37.5, :size=>191, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 3485 {:version=>6, :ticker_id=>3485, :tick_type=>2, :price=>37.5, :size=>100, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 9547 {:version=>6, :ticker_id=>9547, :tick_type=>1, :price=>37.5, :size=>209, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 9547 {:version=>6, :ticker_id=>9547, :tick_type=>2, :price=>37.5, :size=>288, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 3196 {:version=>6, :ticker_id=>3196, :tick_type=>1, :price=>25.0, :size=>101, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 3196 {:version=>6, :ticker_id=>3196, :tick_type=>2, :price=>25.0, :size=>101, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 8482 {:version=>6, :ticker_id=>8482, :tick_type=>1, :price=>25.0, :size=>232, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 8482 {:version=>6, :ticker_id=>8482, :tick_type=>2, :price=>25.0, :size=>191, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 5105 {:version=>6, :ticker_id=>5105, :tick_type=>1, :price=>25.0, :size=>231, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 5105 {:version=>6, :ticker_id=>5105, :tick_type=>2, :price=>25.0, :size=>151, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 9929 {:version=>6, :ticker_id=>9929, :tick_type=>1, :price=>25.0, :size=>201, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 9929 {:version=>6, :ticker_id=>9929, :tick_type=>2, :price=>25.0, :size=>269, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 1042 {:version=>6, :ticker_id=>1042, :tick_type=>1, :price=>25.0, :size=>193, :can_auto_execute=>1}
2021-01-29 08:26:31 -0500 1042 {:version=>6, :ticker_id=>1042, :tick_type=>2, :price=>25.0, :size=>51, :can_auto_execute=>1}

this problem seems to occur only with grains options. i tested stocks options and currencies futures options and it was good.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.