コード例 #1
0
def filter_liquidity(spread, quote_date, spy_value):
	current_options = live_yahoo.main()


	print "filtering options based on what prices are available"
	print "number of spreads found that pass model", len(spread)
	try:
		maturity = next(opt for opt in current_options if opt.expiration_date() == spread[0][1].expiration_date)
	except:
		print "cannot find optiosn for {0} among list of {1}".format(spread[0][1].expiration_date, str([x.expiration_date() for x in current_options]))
		return []


	print maturity
	results = []
	for s in spread:
		try:
			print s[1].body_spread, s[1].wingspan
			ic = IronCondor.make_short_iron_condor(maturity, spy_value, float(s[1].body_spread) / 100.0, s[1].wingspan)
		except Exception as e:
			print e
			print type(e)
			print "Unable to make short iron condor with {0} body spread and {1} wingspan at maturity {2} and value {3}".format(s[1].body_spread, s[1].wingspan, maturity.expiration_date(), spy_value)
			continue
		print "model expects {0} but option worth {1}".format(s[0], 1.0 + ic.max_return())
		if 1.0 + ic.max_return() > s[0]:
			results.append(s)


	print "number of spreads found that pass premium requirement", len(results)

	return results
コード例 #2
0
def gen_spreads2(expiries=None):

	gen = SpreadGen()
#	expiration_date = datetime.datetime(2013,10,11)

	spy = live_yahoo.get_symbol_price("SPY")
	available_dates = [x.expiration_date() for x in live_yahoo.main()]
	available_spreads = reduce(operator.add, [spread_for_today(gen, expiry, datetime.datetime.today(), spy) for expiry in available_dates])
	gen.print_spread(available_spreads)
コード例 #3
0
def gen_spreads2(expiries=None):

    gen = SpreadGen()
    #	expiration_date = datetime.datetime(2013,10,11)

    spy = live_yahoo.get_symbol_price("SPY")
    available_dates = [x.expiration_date() for x in live_yahoo.main()]
    available_spreads = reduce(operator.add, [
        spread_for_today(gen, expiry, datetime.datetime.today(), spy)
        for expiry in available_dates
    ])
    gen.print_spread(available_spreads)
コード例 #4
0
def filter_liquidity(spread, quote_date, spy_value):
    current_options = live_yahoo.main()

    print "filtering options based on what prices are available"
    print "number of spreads found that pass model", len(spread)
    try:
        maturity = next(
            opt for opt in current_options
            if opt.expiration_date() == spread[0][1].expiration_date)
    except:
        print "cannot find optiosn for {0} among list of {1}".format(
            spread[0][1].expiration_date,
            str([x.expiration_date() for x in current_options]))
        return []

    print maturity
    results = []
    for s in spread:
        try:
            print s[1].body_spread, s[1].wingspan
            ic = IronCondor.make_short_iron_condor(
                maturity, spy_value,
                float(s[1].body_spread) / 100.0, s[1].wingspan)
        except Exception as e:
            print e
            print type(e)
            print "Unable to make short iron condor with {0} body spread and {1} wingspan at maturity {2} and value {3}".format(
                s[1].body_spread, s[1].wingspan, maturity.expiration_date(),
                spy_value)
            continue
        print "model expects {0} but option worth {1}".format(
            s[0], 1.0 + ic.max_return())
        if 1.0 + ic.max_return() > s[0]:
            results.append(s)

    print "number of spreads found that pass premium requirement", len(results)

    return results