def test_get_price2():
    df = get_price("502000.XSHG", start_date='2016-04-01',
                   end_date='2016-04-21', frequency='daily', fields=None)
    # 所有cell都应该不是nan
    assert np.array_equal(df.isnull().values, np.full(df.shape, False))
    df = get_price("161207.XSHE", start_date='2016-04-01',
                   end_date='2016-04-21', frequency='daily', fields=None)
    # 所有cell都应该是nan
    assert np.array_equal(df.isnull().values, np.full(df.shape, True))

    df = get_price('000001.XSHG', start_date='2000-01-01', end_date='2018-01-01')
    assert len(df.index) == len(get_trade_days(end_date="2018-01-01", count=10000))

    assert get_price('000001.XSHE', start_date='2000-01-01', end_date='2015-12-31', skip_paused=True, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,6.59,6.52,6.59,6.46,1760832.0,11465603.0
2015-12-30,12.09,12.1,12.11,11.95,53266704.0,641277248.0
2015-12-31,12.1,11.99,12.13,11.98,49125892.0,591643584.0
"""

    assert get_price('000001.XSHE', start_date='2000-01-01', end_date='2015-12-31', skip_paused=True, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,6.59,6.52,6.59,6.46,1760832.0,11465603.0
2015-12-30,12.09,12.1,12.11,11.95,53266704.0,641277248.0
2015-12-31,12.1,11.99,12.13,11.98,49125892.0,591643584.0
"""

    assert get_price('000001.XSHE', start_date='2000-01-01', end_date='2015-12-31', skip_paused=True, fq='post').iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,179.52,177.62,179.52,175.98,64637.0,11465603.0
2015-12-30,1132.34,1133.27,1134.21,1119.23,568730.0,641277248.0
2015-12-31,1133.27,1122.97,1136.08,1122.03,524519.0,591643584.0
"""

    # 2015-12-18停牌了
    assert get_price('000002.XSHE', start_date='2000-01-01', end_date='2015-12-31', skip_paused=True, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,5.22,5.27,5.31,5.17,10353811.0,54514225.0
2015-12-17,20.38,22.21,22.21,20.35,258339264.0,5616476672.0
2015-12-18,22.4,24.43,24.43,21.66,223898400.0,5288950784.0
"""

    assert get_price('000002.XSHE', start_date='2000-01-01', end_date='2015-12-31', skip_paused=False, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,5.22,5.27,5.31,5.17,10353811.0,54514225.0
2015-12-30,24.43,24.43,24.43,24.43,0.0,0.0
2015-12-31,24.43,24.43,24.43,24.43,0.0,0.0
"""

    # 2015-11-02退市了
    assert get_price('000033.XSHE', start_date='2000-01-01', end_date='2015-12-31', skip_paused=True, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,3.68,3.71,3.74,3.63,221902.0,815076.0
2015-04-28,9.89,9.89,9.89,9.89,837617.0,8284032.0
2015-04-29,10.38,10.38,10.38,10.38,8184168.0,84951664.0
"""

    assert get_price('000033.XSHE', start_date='2000-01-01', end_date='2015-11-3', skip_paused=False, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,3.68,3.71,3.74,3.63,221902.0,815076.0
2015-11-02,10.38,10.38,10.38,10.38,0.0,0.0
2015-11-03,10.38,10.38,10.38,10.38,0.0,0.0
"""

    #       display_name    name    start_date  end_date    type
    # 600472.XSHG 包头铝业    BTLY    2005-05-09  2007-12-26  stock
    assert get_price('600472.XSHG', start_date='2000-01-01', end_date='2007-12-27', skip_paused=False, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,,,,,,
2007-12-26,51.82,51.82,51.82,51.82,0.0,0.0
2007-12-27,,,,,,
"""

    print(get_price('000002.XSHE', end_date='2016-12-31', skip_paused=False)[-2:])
assert get_price('000001.XSHE', start_date='2000-01-01', end_date='2015-12-31', skip_paused=True, fq=None).iloc[[0, -2, -1]].to_csv().replace('\r', '') == """\
,open,close,high,low,volume,money
2005-01-04,6.59,6.52,6.59,6.46,1760832.0,11465603.0
2015-12-30,12.09,12.1,12.11,11.95,53266704.0,641277248.0
2015-12-31,12.1,11.99,12.13,11.98,49125892.0,591643584.0
tests/test_api.py