示例#1
0
def test_nearest_column_round_down(data_dod_greeks, value):
    # here we test for mid-point, values returned should round down.
    chain = op.OptionQuery(data_dod_greeks).nearest(value[0], value[1], 'rounddown').fetch()
    values = chain[value[0]].unique()

    assert len(values) == 1
    assert values[0] == value[2]
示例#2
0
    def update(self, date):
        # current quote date
        self.now = date

        # we will slice our spread_data by today's date
        latest_quote = op.OptionQuery(self.spread_data.loc[self.now])

        # run entry filters against our current quote prices if defined
        if self.filters is not None:
            self.filter_stack(self, latest_quote)
        else:
            # if no filters provided, use the logic in the overridden on_update function
            self.on_update(latest_quote)
示例#3
0
文件: conftest.py 项目: moue/optopsy
def vertical_strategies(request):
    data = op.option_strategy.Vertical(option_type=request.param[1],
                                       width=request.param[2])(
                                           request.param[0]())
    return op.OptionQuery(data)
示例#4
0
def test_lte(data_dod_greeks, value):
    chain = op.OptionQuery(data_dod_greeks).lte(value[0], value[1])
    values = chain.oc[value[0]].unique()
    assert all(v <= value[1] for v in values)
示例#5
0
def test_invalid_column_values(data_dod_greeks, value):
    with pytest.raises(ValueError):
        op.OptionQuery(data_dod_greeks)._check_inputs(value[0], value[1])
示例#6
0
def test_option_query_init():
    with pytest.raises(ValueError):
        op.OptionQuery(op.OptionStrategy())
示例#7
0
def test_without_underlying_price(data_dod_greeks):
    with pytest.raises(ValueError):
        op.OptionQuery(data_dod_greeks).underlying_price()
示例#8
0
def test_underlying_price(data_dod_underlying):
    chain = op.OptionQuery(data_dod_underlying).underlying_price()
    assert chain == 40.55
示例#9
0
def test_option_type(data_dod_greeks, option_type):
    chain = op.OptionQuery(data_dod_greeks).option_type(option_type).fetch().option_type.unique()
    assert len(chain) == 1
    assert chain[0] == option_type.value[0]
示例#10
0
def test_invalid_option_type(data_dod_greeks, option_type):
    with pytest.raises(ValueError):
        op.OptionQuery(data_dod_greeks).option_type(option_type)
示例#11
0
def test_between(data_dod_greeks, value):
    chain = op.OptionQuery(data_dod_greeks).between(value[0], value[1], value[2])
    values = chain.oc[value[0]].unique()
    assert all(value[1] <= v <= value[2] for v in values)
示例#12
0
def test_puts(data_dod_greeks):
    puts = op.OptionQuery(data_dod_greeks).puts().fetch().option_type.unique()
    assert len(puts) == 1
    assert puts[0] == 'p'
示例#13
0
def test_calls(data_dod_greeks):
    calls = op.OptionQuery(data_dod_greeks).calls().fetch().option_type.unique()
    assert len(calls) == 1
    assert calls[0] == 'c'