Example #1
0
def ParseBeancountOptionSymbol(string):
    match = re.match(r'[A-Z]+', string)
    if not match:
        raise ValueError("Invalid Beancount option symbol: {}".format(
            repr(string)))
    symbol = match.group(0)
    rest = string[len(symbol):]
    expiration = datetime.datetime.strptime(rest[:6], "%y%m%d").date()
    side = rest[6]
    strike = Decimal(rest[7:])
    return options.Option(symbol, expiration, strike, side)
Example #2
0
def _O(symbol, ymd, strike_str, side):
    return options.Option(symbol, datetime.date(*ymd), Decimal(strike_str), side)