Class: MyTradeWizard::FutureTradingSystem

Inherits:
TradingSystem show all
Defined in:
lib/mytradewizard/future_trading_system.rb

Constant Summary

Constants included from DateTime

DateTime::HR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TradingSystem

#email, #output, #place_market_order, #positions, #production?, #test?

Methods included from TechnicalIndicator

#SMA

Methods included from DateTime

#at, #friday, #idle

Constructor Details

#initializeFutureTradingSystem

Returns a new instance of FutureTradingSystem.



8
9
10
11
12
# File 'lib/mytradewizard/future_trading_system.rb', line 8

def initialize
  super
  @quantity = 0
  @action = nil
end

Instance Attribute Details

#quantity=(value) ⇒ Object (writeonly)

Sets the attribute quantity

Parameters:

  • value

    the value to set the attribute quantity to.



6
7
8
# File 'lib/mytradewizard/future_trading_system.rb', line 6

def quantity=(value)
  @quantity = value
end

Instance Method Details

#actionObject



27
28
29
# File 'lib/mytradewizard/future_trading_system.rb', line 27

def action
  @action
end

#actionize(signal) ⇒ Object



23
24
25
# File 'lib/mytradewizard/future_trading_system.rb', line 23

def actionize(signal)
  @action = MyTradeWizard::Action.new(signal)
end

#hours(hourly_range) ⇒ Object



19
20
21
# File 'lib/mytradewizard/future_trading_system.rb', line 19

def hours(hourly_range)
  @ib.hourly_bars(@contract, hourly_range, @live)
end

#place_orders(open_time, close_time) ⇒ Object



31
32
33
34
35
# File 'lib/mytradewizard/future_trading_system.rb', line 31

def place_orders(open_time, close_time)
  unless @action.nil?
    @ib.place_market_orders(@account, @action, @quantity, @contract, open_time, close_time)
  end
end

#symbol=(s) ⇒ Object



14
15
16
17
# File 'lib/mytradewizard/future_trading_system.rb', line 14

def symbol=(s)
  @contract = @ib.front_month(s)
  puts @contract
end