Ejemplo n.º 1
0
#
# for a Put Credit spread, set limit price at 1.0 less the full margin
#
my_bid_price = (vertical["margin"] * 100.0) - 1.00
my_bid_price_rounded = (math.floor(my_bid_price * 100.0)) / 100.0
x = my_bid_price_rounded / 100.0
my_bid_price_formatted = str(x)
price = my_bid_price_formatted

quantity = 1
time_in_force = "gfd"
trigger = "immediate"
order_type = "limit"

print("Selling a {} {}/{} {} spread for {} (notation value = ${})".format(
    symbol, vertical["strike_price"].values[0],
    vertical["strike_price_shifted"].values[0], spread_type, price,
    my_bid_price_rounded))

oo = OptionOrder.submit(client, direction, legs, price, quantity,
                        time_in_force, trigger, order_type)

print("Order submitted ... ref_id = {}".format(oo["ref_id"]))

#
# cancel the order
#
print("Canceling order = {}".format(oo["ref_id"]))
result = OptionOrder.cancel(client, oo['cancel_url'])
print("Order canceled result = {}".format(result))
Ejemplo n.º 2
0
order_type = "limit"

print("Selling a {} {}/{} Put Spread for {} (notional value = ${})".format(
    symbol, vertical["strike_price"].values[0],
    vertical["strike_price_shifted"].values[0], price, my_bid_price_rounded))

oo = OptionOrder.submit(client, direction, legs, price, quantity,
                        time_in_force, trigger, order_type)

print("Order submitted ... ref_id = {}".format(oo["ref_id"]))

my_bid_price = (vertical["margin"] * 100.0) - 1.00 - 1.00
my_bid_price_rounded = (math.floor(my_bid_price * 100.0)) / 100.0
x = my_bid_price_rounded / 100.0
my_bid_price_formatted = str(x)
new_price = my_bid_price_formatted

print("Replacing order ...")
print("... old price = {}".format(price))
print("... new price = {}".format(new_price))
oo_replaced = OptionOrder.replace(client, oo, new_price)

print("Order has been replaced ... ref_id = {}".format(oo_replaced["ref_id"]))

#
# cancel the order
#
print("Canceling replaced order = {}".format(oo_replaced["ref_id"]))
result = OptionOrder.cancel(client, oo_replaced['cancel_url'])
print("Order canceled result = {}".format(result))