class_docstr: Tests for methods for the vanilla pricing module.
class_docstr_tok: ["Tests","for","methods","for","the","vanilla","pricing","module","."]
docstr: Tests that the price is invariant under vol->k vol, T->T/k**2.
docstr_tok: ["Tests","that","the","price","is","invariant","under","vol-",">","k","vol",",","T-",">","T\/k","*","*","2","."]
code: def test_price_vol_and_expiry_scaling(self):
      """Tests that the price is invariant under vol->k vol, T->T/k**2."""
      np.random.seed(1234)
      n = 20
      forwards = np.exp(np.random.randn(n))
      volatilities = np.exp(np.random.randn(n) / 2)
      strikes = np.exp(np.random.randn(n))
      expiries = np.exp(np.random.randn(n))
      scaling = 5.0
      base_prices = self.evaluate(
          tff.black_scholes.option_price(
              volatilities=volatilities,
              strikes=strikes,
              expiries=expiries,
              forwards=forwards,
          )
      )
      scaled_prices = self.evaluate(
          tff.black_scholes.option_price(
              volatilities=volatilities * scaling,
              strikes=strikes,
              expiries=expiries / scaling / scaling,
              forwards=forwards,
          )
      )
      self.assertArrayNear(base_prices, scaled_prices, 1e-10)
  
imports: import functools
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 7 for calling the VanillaPrice obj's underlying member method code with example usage: obj.test_price_vol_and_expiry_scaling() without return types