コード例 #1
0
ファイル: option_sigma_calc.py プロジェクト: conor10/algos
                days_to_expiry = dt_expiry - run_date

                delta = days_to_expiry.days / days_in_year

                for strike in puts.index:
                    last_price_str = puts.ix[strike]['LAST_PRICE']
                    if last_price_str == '-':
                        continue
                    last_price = float(last_price_str)
                    price = option.calc_option_price(OptionType.PUT,
                                                     strike,
                                                     underlying_price,
                                                     sigma,
                                                     delta,
                                                     risk_free_rate=0.01)
                    implied_volatility = option.implied_volatility(
                        OptionType.PUT, strike, underlying_price, last_price,
                        delta)
                    print('Strike: {}, calc price: {}, actual {}'.format(
                        strike, price, last_price))
                    print('Sigma: {}, implied sigma: {}'.format(
                        sigma, implied_volatility))


def calc_sigma(returns, start_date, expiry_date):
    pass


if __name__ == '__main__':
    init_logger.setup()
    main()
コード例 #2
0
ファイル: main.py プロジェクト: afsheenb/examples
import logging

import init_logger


def log_an_error():
    log = logging.getLogger(__name__)
    log.error("Uh oh, something's not right")


if __name__ == '__main__':
    init_logger.setup()
    logging.info("Wow, that was simple...")
    log_an_error()