<s> def price_options ( S = <NUM_LIT> , K = <NUM_LIT> , sigma = <NUM_LIT> , r = <NUM_LIT> , days = <NUM_LIT> , paths = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> import numpy as np <EOL> from math import exp , sqrt <EOL> h = <NUM_LIT:1.0> / days <EOL> const1 = exp ( ( r - <NUM_LIT:0.5> * sigma ** <NUM_LIT:2> ) * h ) <EOL> const2 = sigma * sqrt ( h ) <EOL> stock_price = S * np . ones ( paths , dtype = '<STR_LIT>' ) <EOL> stock_price_sum = np . zeros ( paths , dtype = '<STR_LIT>' ) <EOL> for j in range ( days ) : <EOL> growth_factor = const1 * np . exp ( const2 * np . random . standard_normal ( paths ) ) <EOL> stock_price = stock_price * growth_factor <EOL> stock_price_sum = stock_price_sum + stock_price <EOL> stock_price_avg = stock_price_sum / days <EOL> zeros = np . zeros ( paths , dtype = '<STR_LIT>' ) <EOL> r_factor = exp ( - r * h * days ) <EOL> euro_put = r_factor * np . mean ( np . maximum ( zeros , K - stock_price ) ) <EOL> asian_put = r_factor * np . mean ( np . maximum ( zeros , K - stock_price_avg ) ) <EOL> euro_call = r_factor * np . mean ( np . maximum ( zeros , stock_price - K ) ) <EOL> asian_call = r_factor * np . mean ( np . maximum ( zeros , stock_price_avg - K ) ) <EOL> return ( euro_call , euro_put , asian_call , asian_put ) </s>
