def get_option_chain(self, symbol):
        """
        This returns the option chain id and an array of the expiration dates
        """

        md = StockMarketdata.quote_by_symbol(self.client, symbol)
        stock_id = md['instrument'].split('/')[-2]
        option_chain = OptionChain.fetch(self.client, stock_id, symbol)
        option_chain_id = option_chain["id"]
        expiration_dates = option_chain['expiration_dates']

        return option_chain_id, np.array(
            expiration_dates)  #.reshape(len(expiration_dates),-1)
Example #2
0
#
with open("fast_arrow_auth.json") as f:
    auth_data = json.loads(f.read())


#
# initialize client with auth_data
#
client = Client(auth_data)


#
# fetch the stock info for TLT
#
symbol = "TLT"
md = StockMarketdata.quote_by_symbol(client, symbol)


#
# get the TLT option chain info
#
stock_id = md["instrument"].split("/")[-2]
option_chain = OptionChain.fetch(client, stock_id, symbol)
option_chain_id = option_chain["id"]
expiration_dates = option_chain['expiration_dates']


#
# reduce the number of expiration dates we're interested in
#
next_3_expiration_dates = expiration_dates[0:3]
Example #3
0
 def get_quote(self, symbol):
     return StockMarketdata.quote_by_symbol(self.client, symbol)
Example #4
0
def retrieve_current_price(client, ticker):
    from fast_arrow import StockMarketdata
    stock = StockMarketdata.quote_by_symbol(client, ticker)
    stock_price = round(
        (float(stock['ask_price']) + float(stock['bid_price'])) / 2, 2)
    return stock_price