diff --git a/CHANGES.rst b/CHANGES.rst index a340b19e1..505c9f8e4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -150,3 +150,11 @@ Version 0.4.6 - Some bugs are fixed - The default config in `Version 0.4.5` is not friendly to daily frequency data. - Backtest error in TopkWeightStrategy when `WithInteract=True`. + + +Version 0.5.0 +-------------------- +- First opensource version + - Refine the docs, code + - Add baselines + - public data crawler diff --git a/docs/component/data.rst b/docs/component/data.rst index 6ebd94700..e23ee1414 100644 --- a/docs/component/data.rst +++ b/docs/component/data.rst @@ -65,7 +65,7 @@ After conversion, users can find their Qlib format data in the directory `~/.qli .. note:: - The arguments of `--include_fields` should correspond with the columns names of CSV files. The columns names of dataset provided by ``Qlib`` includes open,close,high,low,volume,factor. + The arguments of `--include_fields` should correspond with the columns names of CSV files. The columns names of dataset provided by ``Qlib`` should include open, close, high, low, volume and factor at least. - `open` The opening price @@ -80,6 +80,7 @@ After conversion, users can find their Qlib format data in the directory `~/.qli - `factor` The Restoration factor + In the convention of `Qlib` data processing, `open, close, high, low, volume, money and factor` will be set to NaN if the stock is suspended. China-Stock Mode & US-Stock Mode -------------------------------- diff --git a/qlib/config.py b/qlib/config.py index 687945c54..c599ced79 100644 --- a/qlib/config.py +++ b/qlib/config.py @@ -120,7 +120,7 @@ _default_client_config = { _default_region_config = { REG_CN: { "trade_unit": 100, - "limit_threshold": 0.1, + "limit_threshold": 0.099, "deal_price": "vwap", }, REG_US: { diff --git a/qlib/contrib/backtest/exchange.py b/qlib/contrib/backtest/exchange.py index 68a506718..ae64dec50 100644 --- a/qlib/contrib/backtest/exchange.py +++ b/qlib/contrib/backtest/exchange.py @@ -149,7 +149,7 @@ class Exchange: self.quote = quote_df.to_dict("index") def _update_limit(self, buy_limit, sell_limit): - self.quote["limit"] = ~self.quote["$change"].between(-sell_limit, buy_limit) + self.quote["limit"] = ~self.quote["$change"].between(-sell_limit, buy_limit, inclusive=False) def check_stock_limit(self, stock_id, trade_date): """Parameter diff --git a/tests/dataset_tests/README.md b/tests/dataset_tests/README.md new file mode 100644 index 000000000..4ba5dc3c6 --- /dev/null +++ b/tests/dataset_tests/README.md @@ -0,0 +1,2 @@ +# About dataset tests +This tests is for testing the prepared dataset from Yahoo diff --git a/tests/dataset_tests/test_dataset.py b/tests/dataset_tests/test_dataset.py new file mode 100644 index 000000000..4a62ba79d --- /dev/null +++ b/tests/dataset_tests/test_dataset.py @@ -0,0 +1,32 @@ + +import qlib +from qlib.data import D +from qlib.config import REG_CN +import unittest +import numpy as np + + +class TestDataset(unittest.TestCase): + + def setUp(self): + provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir + qlib.init(provider_uri=provider_uri, region=REG_CN) + + def testCSI300(self): + close_p = D.features(D.instruments('csi300'), ['$close']) + size = close_p.groupby('datetime').size() + cnt = close_p.groupby('datetime').count() + + print(size.describe(percentiles=np.arange(0.1, 0.9, 0.1))) + print(cnt.describe(percentiles=np.arange(0.1, 0.9, 0.1))) + # TODO: assert + + def testClose(self): + close_p = D.features(D.instruments('csi300'), ['Ref($close, 1)/$close - 1']) + print(close_p.describe(percentiles=np.arange(0.1, 0.9, 0.1))) + # TODO: assert + + +if __name__ == '__main__': + unittest.main() +