oc = OptionChain.fetch(client, stock["id"], symbol) ed = oc['expiration_dates'][0] ops = Option.in_chain(client, oc["id"], expiration_dates=[ed]) # # enrich options with market data # ops = Option.mergein_marketdata_list(client, ops) # # genrate vertical spread table # width = 1 spread_type = "put" spread_kind = "sell" df = Vertical.gen_df(ops, width, spread_type, spread_kind) # # select the 4th row (should be a deep OTM put, credit spread) # index = int(len(ops) / 4) vertical = df.iloc[[index]] # # create the order # direction = "credit" legs = [{ "side": spread_kind, "option": vertical["instrument"].values[0],
stock = Stock.mergein_marketdata_list(client, [stock])[0] oc = OptionChain.fetch(client, stock["id"], symbol) ed = oc['expiration_dates'][3] ops = Option.in_chain(client, oc["id"], expiration_dates=[ed]) # # enrich options with market data # ops = Option.mergein_marketdata_list(client, ops) # # genrate vertical spread table # width = 1 df = Vertical.gen_df(ops, width, "put", "sell") # # select the 4th row (should be a deep OTM put, credit spread) # vertical = df.iloc[[4]] # # create the order # direction = "credit" legs = [{ "side": "sell", "option": vertical["instrument"].values[0], "position_effect": "open",