class_docstr: Represents a batch of American Equity Options.
  
  An American equity option is a contract that gives the holder an opportunity
  to buy (call) or sell (put) an equity for a predefined value (strike) at
  any date before the expiry.
  
  The AmericanOption class can be used to create and price multiple options
  simultaneously.
  
  #### Example:
  The following example illustrates the construction of a batch of American
  options and pricing them.
  
  ```None
  american_option_proto = american_option_pb2.AmericanEquityOption(
      short_position=True,
      expiry_date=date_pb2.Date(year=2022, month=5, day=21),
      contract_amount=decimal_pb2.Decimal(units=10000),
      strike=decimal_pb2.Decimal(units=1500),
      equity="GOOG",
      currency=Currency.USD(),
      business_day_convention=BusinessDayConvention.MODIFIED_FOLLOWING(),
      is_call_option=False)
  
  market = market_data.MarketDataDict(...)
  am_option_portfolio = AmericanOption.from_protos([american_option_proto])
  am_option_portfolio[0].price(market)
  ```
class_docstr_tok: ["Represents","a","batch","of","American","Equity","Options",".","An","American","equity","option","is","a","contract","that","gives","the","holder","an","opportunity","to","buy","(","call",")","or","sell","(","put",")","an","equity","for","a","predefined","value","(","strike",")","at","any","date","before","the","expiry",".","The","AmericanOption","class","can","be","used","to","create","and","price","multiple","options","simultaneously",".","#","#","#","#","Example",":","The","following","example","illustrates","the","construction","of","a","batch","of","American","options","and","pricing","them",".","``","`","None","american_option_proto","=","american_option_pb2.AmericanEquityOption","(","short_position=True",",","expiry_date=date_pb2.Date","(","year=2022",",","month=5",",","day=21",")",",","contract_amount=decimal_pb2.Decimal","(","units=10000",")",",","strike=decimal_pb2.Decimal","(","units=1500",")",",","equity=","''","GOOG","''",",","currency=Currency.USD","(",")",",","business_day_convention=BusinessDayConvention.MODIFIED_FOLLOWING","(",")",",","is_call_option=False",")","market","=","market_data.MarketDataDict","(","...",")","am_option_portfolio","=","AmericanOption.from_protos","(","[","american_option_proto","]",")","am_option_portfolio","[","0","]",".price","(","market",")","``","`"]
docstr: Returns the present value of the American options.
  
  Args:
    market: An instance of `ProcessedMarketData`.
    name: Python str. The name to give to the ops created by this function.
      Default value: `None` which maps to 'price'.
  
  Returns:
    A `Tensor` of shape `batch_shape`  containing the modeled price of each
    American option contract based on the input market data.
docstr_tok: ["Returns","the","present","value","of","the","American","options",".","Args",":","market",":","An","instance","of","`","ProcessedMarketData","`",".","name",":","Python","str",".","The","name","to","give","to","the","ops","created","by","this","function",".","Default","value",":","`","None","`","which","maps","to","'price","'",".","Returns",":","A","`","Tensor","`","of","shape","`","batch_shape","`","containing","the","modeled","price","of","each","American","option","contract","based","on","the","input","market","data","."]
code: def price(
      self, market: pmd.ProcessedMarketData, name: Optional[str] = None
  ) -> types.FloatTensor:
      """Returns the present value of the American options.
  
      Args:
        market: An instance of `ProcessedMarketData`.
        name: Python str. The name to give to the ops created by this function.
          Default value: `None` which maps to 'price'.
  
      Returns:
        A `Tensor` of shape `batch_shape`  containing the modeled price of each
        American option contract based on the input market data.
      """
      name = name or (self._name + "_price")
      with tf.name_scope(name):
          discount_curve = cashflow_streams.get_discount_curve(
              self._discount_curve_type,
              market,
              self._discount_curve_mask,
          )
          currencies = [
              cur.currency.value for cur in self._discount_curve_type
          ]
          vol_surface = equity_utils.get_vol_surface(
              currencies, self._equity, market, self._equity_mask
          )
          spots = tf.stack(
              market.spot(currencies, self._equity), axis=0
          )
          discount_factors = discount_curve.discount_factor(
              self._expiry_date.expand_dims(axis=-1)
          )
          daycount_convention = discount_curve.daycount_convention
          day_count_fn = market_data_utils.get_daycount_fn(
              daycount_convention
          )
          if spots.shape.rank > 0:
              spots = tf.gather(spots, self._equity_mask)
          if self._model == "BS-LSM":
              # TODO(b/168798725): volatility should be time-dependent
              vols = vol_surface.volatility(
                  expiry_dates=self._expiry_date.expand_dims(axis=-1),
                  strike=tf.expand_dims(self._strike, axis=-1),
              )
              prices = utils.bs_lsm_price(
                  spots=spots,
                  expiry_times=day_count_fn(
                      start_date=market.date,
                      end_date=self._expiry_date,
                      dtype=self._dtype,
                  ),
                  strikes=self._strike,
                  volatility=tf.squeeze(vols, axis=-1),
                  discount_factors=tf.squeeze(discount_factors),
                  is_call_option=self._is_call_option,
                  num_samples=self._num_samples,
                  num_exercise_times=self._num_exercise_times,
                  num_calibration_samples=self._num_calibration_samples,
                  seed=self._seed,
              )
              return (
                  self._short_position * self._contract_amount * prices
              )
          else:
              raise ValueError(
                  "Only BS-LSM model is supported. "
                  "Supplied {}".format(self._model)
              )
  
imports: from typing import Any, Optional, List, Dict, Union, Tuple
  import dataclasses
  import tensorflow.compat.v2
  from tf_quant_finance import datetime
  from tf_quant_finance.experimental.pricing_platform.framework.core import curve_types
  from tf_quant_finance.experimental.pricing_platform.framework.core import instrument
  from tf_quant_finance.experimental.pricing_platform.framework.core import processed_market_data
  from tf_quant_finance.experimental.pricing_platform.framework.core import types
  from tf_quant_finance.experimental.pricing_platform.framework.equity_instruments import utils
  from tf_quant_finance.experimental.pricing_platform.framework.equity_instruments.american_option import proto_utils
  from tf_quant_finance.experimental.pricing_platform.framework.equity_instruments.american_option import utils
  from tf_quant_finance.experimental.pricing_platform.framework.market_data import utils
  from tf_quant_finance.experimental.pricing_platform.framework.rate_instruments import cashflow_streams
  from tf_quant_finance.experimental.pricing_platform.instrument_protos import american_equity_option_pb2
label_desc: Use image node_id 5 for calling the AmericanOption obj's underlying member method code with example usage: obj.price(market, name) and returns: unknown