Пример #1
0
def test_ensure_valid_data():
    trimmed = {'ADBE': 203616, 'AXP': 276428, 'BAX': 1842960, 'CPB': 692790, 'STZ': 281435,
               'DHR': 320703, 'DWDP': 516360, 'FPAC': 158337, 'IQV': 189357,
               'MRK': 212038, 'PYPL': 338462, 'CRM': 160940,
               'BID': 264732, 'V': 197910, 'WP': 201011}
    expected_weights = bt.value_to_weight(trimmed)
    weights = bt.ensure_valid_data('000108514619000438', '2019-02-11', None, "0001040273", 15)
    assert weights == expected_weights
Пример #2
0
def test_find_valid_tickers():
    holdings = {'ADBE': 203616, 'AXP': 276428, 'BAX': 1842960, 'CPB': 692790, 'CI': 109204, 'STZ': 281435,
                'DHR': 320703, 'DOV': 43634, 'DWDP': 516360, 'FPAC': 158337, 'FPACU': 40360, 'IQV': 189357, 'SHY': 3336,
                'KDMN': 19568, 'MRK': 212038, 'PYPL': 338462, 'SPGI': 135952, 'CRM': 160940, 'SHPG': 299247,
                'BID': 264732, 'V': 197910, 'WP': 201011}
    weights, failed = bt.find_valid_tickers(holdings, 50, [], '2019-02-11')
    del holdings['FPACU']
    del holdings['SHPG']
    expected_weights = bt.value_to_weight(holdings)
    assert weights == approx(expected_weights, abs=1e-15)
    assert failed == ['SHPG', 'FPACU']
Пример #3
0
def test_value_to_weight_simple():
    holdings = {"AAPL": 30, "WMT": 20, "BA": 22, "AIG": 28}
    weights = {"AAPL": 0.30, "WMT": 0.20, "BA": 0.22, "AIG": 0.28}
    assert bt.value_to_weight(holdings) == approx(weights, abs=1e-15)
Пример #4
0
def test_value_to_weight():
    holdings = {"AAPL": 50.30, "WMT": 20.08, "BA": 22.82, "AIG": 14.17}
    weights = {"AAPL": 50.30 / 107.37, "WMT": 20.08 / 107.37, "BA": 22.82 / 107.37, "AIG": 14.17 / 107.37}
    assert bt.value_to_weight(holdings) == approx(weights, abs=1e-15)