197a7f917dfc540b59f6f1b5c397c89c05436eb9,tests/test_backtest.py,,test_Results_helper_functions_fi,#,164

Before Change


    // algo to set the weights
    //  it will only run when runMonthlyAlgo returns true
    //  which only happens on the first of every month
    weights = pd.Series([0.6, 0.4], index=rdf.columns)
    weighSpecifiedAlgo = bt.algos.WeighSpecified(**weights)

    // algo to rebalance the current weights to weights set by weighSpecified
    //  will only run when weighSpecifiedAlgo returns true

After Change


        progress_bar=False,
        additional_data = {"mydata":pdf}
    )
    bidoffer = 1.
    backtest2 = bt.Backtest(
        strat,
        pdf,
        initial_capital = 0,
        integer_positions=False,
        progress_bar=False,
        additional_data = {"mydata":pdf, 
                           "bidoffer": pd.DataFrame( bidoffer, pdf.index, pdf.columns )}
    )
    random.seed(1234)
    res = bt.run(backtest)
    random.seed(1234)
    res2 = bt.run(backtest2)

    assert(type(res.get_security_weights()) is pd.DataFrame)

    assert (type(res.get_transactions()) is pd.DataFrame)
    assert len(res.get_transactions()) > 0

    assert (type(res.get_weights()) is pd.DataFrame)

    // Make sure the insertion of the first row applies to additional data as well
    assert backtest.data.index.equals( backtest.additional_data["mydata"].index )

    // Check that bid/offer is accounted for
    transactions = res.get_transactions()        
    transactions["price"] = transactions["price"] + 0.5 * bidoffer
    assert (res2.get_transactions().price - res2.get_transactions().price).abs().sum() == 0
        
        
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 4

Instances


Project Name: pmorissette/bt
Commit Name: 197a7f917dfc540b59f6f1b5c397c89c05436eb9
Time: 2020-11-05
Author: pascal.i.tomecek@jpmorgan.com
File Name: tests/test_backtest.py
Class Name:
Method Name: test_Results_helper_functions_fi


Project Name: openml/openml-python
Commit Name: c4920ea11ef69a5597b83af961685034c8330e99
Time: 2019-06-11
Author: neeratyoy@gmail.com
File Name: openml/flows/flow.py
Class Name: OpenMLFlow
Method Name: __str__


Project Name: okfn-brasil/serenata-de-amor
Commit Name: cecf397e2bc8a22e0fe20fcad26151e9666e2bb3
Time: 2016-11-25
Author: filipelinhares@outlook.com
File Name: src/fetch_yelp_info.py
Class Name:
Method Name:


Project Name: etal/cnvkit
Commit Name: fff30b5d161bc5ad17af26af65704a03e1b4611d
Time: 2019-04-09
Author: etalevich@dnanexus.com
File Name: cnvlib/smoothing.py
Class Name:
Method Name: convolve_weighted