mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-11 23:06:58 +08:00
add test and mod doc
This commit is contained in:
@@ -150,3 +150,11 @@ Version 0.4.6
|
|||||||
- Some bugs are fixed
|
- Some bugs are fixed
|
||||||
- The default config in `Version 0.4.5` is not friendly to daily frequency data.
|
- The default config in `Version 0.4.5` is not friendly to daily frequency data.
|
||||||
- Backtest error in TopkWeightStrategy when `WithInteract=True`.
|
- Backtest error in TopkWeightStrategy when `WithInteract=True`.
|
||||||
|
|
||||||
|
|
||||||
|
Version 0.5.0
|
||||||
|
--------------------
|
||||||
|
- First opensource version
|
||||||
|
- Refine the docs, code
|
||||||
|
- Add baselines
|
||||||
|
- public data crawler
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ After conversion, users can find their Qlib format data in the directory `~/.qli
|
|||||||
|
|
||||||
.. note::
|
.. 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`
|
- `open`
|
||||||
The opening price
|
The opening price
|
||||||
@@ -80,6 +80,7 @@ After conversion, users can find their Qlib format data in the directory `~/.qli
|
|||||||
- `factor`
|
- `factor`
|
||||||
The Restoration 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
|
China-Stock Mode & US-Stock Mode
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ _default_client_config = {
|
|||||||
_default_region_config = {
|
_default_region_config = {
|
||||||
REG_CN: {
|
REG_CN: {
|
||||||
"trade_unit": 100,
|
"trade_unit": 100,
|
||||||
"limit_threshold": 0.1,
|
"limit_threshold": 0.099,
|
||||||
"deal_price": "vwap",
|
"deal_price": "vwap",
|
||||||
},
|
},
|
||||||
REG_US: {
|
REG_US: {
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class Exchange:
|
|||||||
self.quote = quote_df.to_dict("index")
|
self.quote = quote_df.to_dict("index")
|
||||||
|
|
||||||
def _update_limit(self, buy_limit, sell_limit):
|
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):
|
def check_stock_limit(self, stock_id, trade_date):
|
||||||
"""Parameter
|
"""Parameter
|
||||||
|
|||||||
2
tests/dataset_tests/README.md
Normal file
2
tests/dataset_tests/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# About dataset tests
|
||||||
|
This tests is for testing the prepared dataset from Yahoo
|
||||||
32
tests/dataset_tests/test_dataset.py
Normal file
32
tests/dataset_tests/test_dataset.py
Normal file
@@ -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()
|
||||||
|
|
||||||
Reference in New Issue
Block a user