9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/schwab_rb/orders/vertical_roll_order.rb', line 9
def build(
close_short_leg_symbol:,
close_long_leg_symbol:,
open_short_leg_symbol:,
open_long_leg_symbol:,
price:,
stop_price: nil,
order_type: nil,
duration: SchwabRb::Orders::Duration::DAY,
credit_debit: :credit,
quantity: 1
)
schwab_order_builder.new.tap do |builder|
builder.set_order_strategy_type(SchwabRb::Order::OrderStrategyTypes::SINGLE)
builder.set_session(SchwabRb::Orders::Session::NORMAL)
builder.set_duration(duration)
builder.set_order_type(order_type || determine_order_type(credit_debit))
builder.set_complex_order_strategy_type(SchwabRb::Order::ComplexOrderStrategyTypes::VERTICAL_ROLL)
builder.set_quantity(quantity)
builder.set_price(price)
builder.set_stop_price(stop_price) if stop_price && order_type == SchwabRb::Order::Types::STOP_LIMIT
builder.add_option_leg(
SchwabRb::Orders::OptionInstructions::BUY_TO_CLOSE,
close_short_leg_symbol,
quantity
)
builder.add_option_leg(
SchwabRb::Orders::OptionInstructions::SELL_TO_CLOSE,
close_long_leg_symbol,
quantity
)
builder.add_option_leg(
SchwabRb::Orders::OptionInstructions::SELL_TO_OPEN,
open_short_leg_symbol,
quantity
)
builder.add_option_leg(
SchwabRb::Orders::OptionInstructions::BUY_TO_OPEN,
open_long_leg_symbol,
quantity
)
end
end
|