def reduce_strike(self, strike_list, expiry, is_put): current_date_str = lib.create_current_date_string() days_to_expiry = lib.calculate_days_difference(expiry, current_date_str) strike_list = sorted(strike_list) otm_rate = 0 itm_rate = 0 if self._price <= 25: otm_rate = 0.50 itm_rate = 0.20 elif self._price <= 50: otm_rate = 0.40 itm_rate = 0.15 elif self._price <= 100: otm_rate = 0.36 itm_rate = 0.10 elif self._price <= 150: otm_rate = 0.33 itm_rate = 0.10 elif self._price <= 200: otm_rate = 0.28 itm_rate = 0.10 else: otm_rate = 0.25 itm_rate = 0.10 if is_put: otm_strike = self._price * (1 - otm_rate) itm_strike = self._price * (1 + itm_rate) strike_list = [x for x in strike_list if (x >= otm_strike and x <= itm_strike and int(x) == x)] return strike_list else: otm_strike = self._price * (1 + otm_rate) itm_strike = self._price * (1 - itm_rate) strike_list = [x for x in strike_list if (x >= itm_strike and x <= otm_strike and int(x) == x)] return strike_list
def reduce_strike(self, strike_list, expiry, is_put): current_date_str = lib.create_current_date_string() days_to_expiry = lib.calculate_days_difference(expiry, current_date_str) strike_list = sorted(strike_list) otm_rate = 0 itm_rate = 0 if self._price <= 25: otm_rate = 0.50 itm_rate = 0.20 elif self._price <= 50: otm_rate = 0.40 itm_rate = 0.15 elif self._price <= 100: otm_rate = 0.36 itm_rate = 0.10 elif self._price <= 150: otm_rate = 0.33 itm_rate = 0.10 elif self._price <= 200: otm_rate = 0.28 itm_rate = 0.10 else: otm_rate = 0.25 itm_rate = 0.10 if is_put: otm_strike = self._price * (1 - otm_rate) itm_strike = self._price * (1 + itm_rate) strike_list = [ x for x in strike_list if (x >= otm_strike and x <= itm_strike and int(x) == x) ] return strike_list else: otm_strike = self._price * (1 + otm_rate) itm_strike = self._price * (1 - itm_rate) strike_list = [ x for x in strike_list if (x >= itm_strike and x <= otm_strike and int(x) == x) ] return strike_list
import sys import lib from option_chain import OptionChain from data import option_chain_data if __name__ == '__main__': if len(sys.argv) not in [2, 3]: print sys.argv[0], " ticker ", "[expiry]" exit else: underline_ticker = sys.argv[1].upper() expiry = sys.argv[2] if len(sys.argv) == 3 else lib.CURRENT_EXPIRY current_date_str = lib.create_current_date_string() days_to_expiry = lib.calculate_days_difference(expiry, current_date_str) option_chain_data_all = {} if lib.DEBUG: option_chain_data_all['P'] = option_chain_data.put_data option_chain_data_all['C'] = option_chain_data.call_data lib.find_iron_condor(underline_ticker, option_chain_data_all, days_to_expiry) else: option_chain = OptionChain(underline_ticker) option_chain.download([expiry]) option_chain_data_all['P'] = option_chain._option_chain_sorted_dict['P'] option_chain_data_all['C'] = option_chain._option_chain_sorted_dict['C'] lib.find_iron_condor(underline_ticker, option_chain_data_all, days_to_expiry)
import sys import lib from option_chain import OptionChain from data import option_chain_data if __name__ == '__main__': if len(sys.argv) not in [2, 3]: print sys.argv[0], " ticker ", "[expiry]" exit else: underline_ticker = sys.argv[1].upper() expiry = sys.argv[2] if len(sys.argv) == 3 else lib.CURRENT_EXPIRY current_date_str = lib.create_current_date_string() days_to_expiry = lib.calculate_days_difference(expiry, current_date_str) if lib.DEBUG: put_option_chains = option_chain_data.put_data lib.find_vertical_spread_long(underline_ticker, put_option_chains, days_to_expiry, True) call_option_chains = option_chain_data.call_data lib.find_vertical_spread_long(underline_ticker, call_option_chains, days_to_expiry, False) else: option_chain = OptionChain(underline_ticker) option_chain.download([expiry]) put_option_chains = option_chain._option_chain_sorted_dict['P'] lib.find_vertical_spread_long(underline_ticker, put_option_chains, days_to_expiry, True) call_option_chains = option_chain._option_chain_sorted_dict['C'] lib.find_vertical_spread_long(underline_ticker, call_option_chains, days_to_expiry, False)