1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-06-06 05:51:17 +08:00

add test and mod doc

This commit is contained in:
Young
2020-09-25 10:25:33 +00:00
parent 9f5e18fc3e
commit 0e8a4a3eb5
6 changed files with 46 additions and 3 deletions

View File

@@ -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

View File

@@ -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
--------------------------------

View File

@@ -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: {

View File

@@ -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

View File

@@ -0,0 +1,2 @@
# About dataset tests
This tests is for testing the prepared dataset from Yahoo

View 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()