Example #1
0
hod_struct = (
    ("underlying_symbol", 0),
    ("underlying_price", 1),
    ("option_type", 5),
    ("expiration", 6),
    ("quote_date", 7),
    ("strike", 8),
    ("bid", 10),
    ("ask", 11),
    ("delta", 15),
    ("gamma", 16),
    ("theta", 17),
    ("vega", 18),
)

DATA = get(TEST_FILE_PATH_FULL, hod_struct, prompt=False)


def test_start_date(options_data):
    start = datetime(1990, 1, 1)
    df = start_date(options_data, start, 0)
    assert not df.empty
    assert all(v >= start for v in df["expiration"])


def test_start_date_ouf_of_bound(options_data):
    start = datetime(1990, 1, 21)
    df = start_date(options_data, start, 0)
    assert df.empty

Example #2
0
HOD_STRUCT = (
    ("underlying_symbol", 0),
    ("underlying_price", 1),
    ("option_type", 5),
    ("expiration", 6),
    ("quote_date", 7),
    ("strike", 8),
    ("bid", 10),
    ("ask", 11),
    ("delta", 15),
    ("gamma", 16),
    ("theta", 17),
    ("vega", 18),
)

DATA = get(TEST_FILE_PATH_FULL, HOD_STRUCT, prompt=False)


def test_avg_profit_long_singles():
    filters = {
        "start_date": datetime(2018, 1, 1),
        "end_date": datetime(2018, 2, 28),
        "entry_dte": 7,
        "leg1_delta": 0.50,
        "contract_size": 1,
        "expr_type": "SPXW",
    }
    spread = long_call(DATA, filters)
    result = spread.avg_profit()
    print(spread)
    assert result == 0