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

Combo routing parameters and algo parameters support #28

Merged
merged 4 commits into from Jun 13, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 3 additions & 14 deletions Gemfile
@@ -1,22 +1,11 @@
source :gemcutter

gemspec

# Gems used in bin scripts
gem 'getopt'

# Dependencies
gem 'bundler', '>= 1.1.3'
gem 'activerecord', '>= 3.2.0'
# Platform-specific dependencies
gem 'sqlite3', '> 1.3.3', :platforms => [:ruby_18, :ruby_19] #:ruby
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.2.2', :platforms => :jruby
gem 'jdbc-sqlite3', '>= 3.7.2', :platforms => :jruby
gem 'xml-simple' , '>= 1.1.1'

#gem.add_dependency 'pg', '>= 0.12.1'

group :development do
gem 'standalone_migrations'
gem 'database_cleaner', '>= 0.7.2'
gem 'rspec', '>= 2.10.0'
gem 'my_scripts'
end
#gemspec
15 changes: 11 additions & 4 deletions Gemfile.lock
@@ -1,3 +1,12 @@
PATH
remote: .
specs:
ib-ruby (0.8.1)
activerecord (>= 3.2.0)
bundler (>= 1.1.3)
standalone_migrations
xml-simple (>= 1.1.1)

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -45,14 +54,12 @@ PLATFORMS
java

DEPENDENCIES
activerecord (>= 3.2.0)
activerecord-jdbcsqlite3-adapter (>= 1.2.2)
bundler (>= 1.1.3)
database_cleaner (>= 0.7.2)
getopt
ib-ruby!
jdbc-sqlite3 (>= 3.7.2)
my_scripts
rspec (>= 2.9.0)
rspec (>= 2.10.0)
sqlite3 (> 1.3.3)
standalone_migrations
xml-simple (>= 1.1.1)
4 changes: 4 additions & 0 deletions HISTORY
Expand Up @@ -189,3 +189,7 @@
== 0.8.0 / 2012-06-07

* TWS 926 support

== 0.8.1 / 2012-06-13

* Combo routing parameters and algo parameters supported
2 changes: 2 additions & 0 deletions TODO
@@ -1,5 +1,7 @@
Plan:

0. Full Rails compatibility as a Rails engine.

1. IB#send_message method should accept block, thus compressing subscribe/send_message
pair into a single call - to simplify DSL.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.8.0
0.8.1
6 changes: 3 additions & 3 deletions db/migrate/131_add_orders.rb
Expand Up @@ -83,9 +83,9 @@ def change
t.float :basis_points_type # double: EFP orders only
t.string :algo_strategy

# t.string :algo_params # public Vector<TagValue> m_algoParams; ?!
# t.string :leg_prices # Vector<OrderComboLeg> m_orderComboLegs
# t.string :combo_params # not used yet
t.text :leg_prices # Vector<OrderComboLeg> m_orderComboLegs
t.text :algo_params # public Vector<TagValue> m_algoParams; ?!
t.text :combo_params # not used yet

t.integer :scale_init_level_size # int: Size of the first (initial) order component.
t.integer :scale_subs_level_size # int: Order size of the subsequent scale order
Expand Down
4 changes: 4 additions & 0 deletions db/schema.rb
@@ -1,3 +1,4 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand Down Expand Up @@ -214,6 +215,9 @@
t.float "basis_points"
t.float "basis_points_type"
t.string "algo_strategy"
t.text "leg_prices"
t.text "algo_params"
t.text "combo_params"
t.integer "scale_init_level_size"
t.integer "scale_subs_level_size"
t.float "scale_price_increment"
Expand Down
7 changes: 4 additions & 3 deletions ib-ruby.gemspec
Expand Up @@ -15,21 +15,22 @@ Gem::Specification.new do |gem|
versioned = `git ls-files -z`.split("\0")
gem.files = Dir['{bin,lib,man,spec,features,tasks}/**/*', 'db/migrate/**/*',
'Rakefile', 'README*', 'LICENSE*',
'VERSION*', 'HISTORY*', 'TODO*', '.gitignore'] & versioned
'VERSION*', 'HISTORY*', '.gitignore'] & versioned
gem.executables = (Dir['bin/**/*'] & versioned).map { |file| File.basename(file) }
gem.test_files = Dir['spec/**/*'] & versioned
gem.require_paths = ['lib']

# Dependencies
gem.add_dependency 'bundler', '>= 1.1.3'
gem.add_dependency 'activerecord', '>= 0.0.1'
gem.add_dependency 'activerecord', '>= 3.2.0'
#gem.add_dependency 'activerecord-jdbcsqlite3-adapter', '>= 1.2.2'
#gem.add_dependency 'jdbc-sqlite3', '>= 3.7.2'
gem.add_dependency 'xml-simple', '>= 1.1.1'
gem.add_dependency 'standalone_migrations'
#gem.add_dependency 'pg', '>= 0.12.1'

gem.add_development_dependency 'database_cleaner', '>= 2.8.0'
gem.add_development_dependency 'database_cleaner', '>= 0.7.2'
gem.add_development_dependency 'rspec', '>= 2.10.0'
gem.add_development_dependency 'standalone_migrations'
gem.add_development_dependency 'my_scripts'
end
1 change: 1 addition & 0 deletions lib/ib-ruby/models/model.rb
Expand Up @@ -49,6 +49,7 @@ def [] key
end

def []= key, val
# p key, val
attributes[key.to_sym] = val
end

Expand Down
17 changes: 5 additions & 12 deletions lib/ib-ruby/models/order.rb
Expand Up @@ -222,9 +222,9 @@ class Order < Model.for(:order)
alias order_combo_legs leg_prices
alias smart_combo_routing_params combo_params

#serialize :leg_prices
#serialize :algo_params
#serialize :combo_params
serialize :leg_prices
serialize :algo_params, Hash
serialize :combo_params

# Order is always placed for a contract. Here, we explicitly set this link.
belongs_to :contract
Expand Down Expand Up @@ -306,22 +306,15 @@ def default_attributes
:transmit => true,
:what_if => false,
:leg_prices => [],
:algo_params => [],
:combo_params => [],
:algo_params => HashWithIndifferentAccess.new, #{},
:combo_params => HashWithIndifferentAccess.new, #{},
:order_state => IB::OrderState.new(:status => 'New',
:filled => 0,
:remaining => 0,
:price => 0,
:average_price => 0)
end

#after_initialize do #opts = {}
# #self.leg_prices = []
# #self.algo_params = {}
# #self.combo_params = {}
# #self.order_state ||= IB::OrderState.new :status => 'New'
#end

def serialize_algo
if algo_strategy.nil? || algo_strategy.empty?
''
Expand Down
2 changes: 1 addition & 1 deletion spec/ib-ruby/connection_spec.rb
Expand Up @@ -103,7 +103,7 @@ def create_connection opts={}

before(:all) do
@ib.send_message :RequestAccountData
@ib.wait_for :AccountDownloadEnd
@ib.wait_for :AccountDownloadEnd, 3
end

after(:all) { @ib.send_message :RequestAccountData, :subscribe => false }
Expand Down