|
1 | | -QLibServer is the assorted server system for QLib, which utilizes QLib for basic calculations and provides extensive server system and cache mechanism. With QLibServer, the data provided for QLib can be managed in a centralized manner. |
| 1 | +`Qlib-Server` is the assorted server system for `Qlib`, which utilizes `Qlib` for basic calculations and provides extensive server system and cache mechanism. With `Qlib-Server`, the data provided for `Qlib` can be managed in a centralized manner. |
2 | 2 |
|
| 3 | +With `Qlib-Server`, you can use `Qlib` in `Online` mode. The `Online` mode is designed to solve the following problems: |
| 4 | + |
| 5 | +* Manage the data in a centralized way. You don't have to manage data of different versions. |
| 6 | +* Reduce the amount of cache to be generated. |
| 7 | +* Make the data can be accessed in a remote way. |
3 | 8 |
|
4 | 9 |
|
5 | 10 | - [Framework of qlib-erver](#framework-of-qlib-server) |
6 | 11 | - [Quick start](#quick-start) |
7 | | - - [Installation](#installation) |
| 12 | + - [Deployment](#deployment) |
| 13 | + - [One-click Deployment](#one-click-deployment) |
| 14 | + - [Step-by-Step Deployment](#step-by-step-deployment) |
8 | 15 | - [More About Qlib](#more-about-qlib) |
| 16 | +- [Contributing](#contributing) |
| 17 | + |
9 | 18 |
|
| 19 | +# Framework of Qlib-Server |
10 | 20 |
|
11 | | -# Framework of qlib-server |
| 21 | +<div style="align: center"> |
| 22 | +<img src="docs/_static/img/framework.png" /> |
| 23 | +</div> |
12 | 24 |
|
| 25 | +The `Client/Server` framework of `Qlib` is based on `WebSocket` considering its capability of **bidirectional communication** between client and server in **async** mode. |
| 26 | + |
| 27 | +`Qlib-Server` is based on [Flash](http://flask.pocoo.org/), which is a micro-framework for Python and here [Flask-SocketIO](https://flask-socketio.readthedocs.io) is used for websocket connection. |
13 | 28 |
|
14 | 29 | # Quick start |
15 | 30 |
|
16 | 31 |
|
17 | 32 | ## Installation |
18 | 33 |
|
| 34 | +### One-click Deployment |
| 35 | + |
| 36 | +One-click deployment of `Qlib-Server` is supported, you can choose either of the following two methods for one-click deployment: |
| 37 | + |
| 38 | +- Deployment with `docker-compose` |
| 39 | +- Deployment in `Azure` |
| 40 | + |
| 41 | +#### One-click Deployment with `docker-compose` |
| 42 | + |
| 43 | +Deploy `Qlib-Server` with `docker-compose` according to the following processes: |
| 44 | + |
| 45 | +* Install `docker`, please refer to [Docker Installation](https://docs.docker.com/engine/install). |
| 46 | +* Install `docker-compose`, please refer to [Docker-compose Installation](https://docs.docker.com/compose/install/). |
| 47 | +- Run the following command to deploy `Qlib-Server`: |
| 48 | + |
| 49 | + ```bash |
| 50 | + git clone https://github.com/microsoft/qlib-server |
| 51 | + cd qlib-server |
| 52 | + sudo docker-compose -f docker_support/docker-compose.yaml --env-file docker_support/docker-compose.env build |
| 53 | + sudo docker-compose -f docker_support/docker-compose.yaml --env-file docker_support/docker-compose.env up -d |
| 54 | + # Use the following command to track the log |
| 55 | + sudo docker-compose -f docker_support/docker-compose.yaml logs -f |
| 56 | + ``` |
| 57 | + |
| 58 | +One-click Deployment in `Azure` |
| 59 | +-------------------------------------------- |
| 60 | + |
| 61 | +Firstly, You need to have an `Azure` account to deploy `Qlib-Server` in `Azure`. Then you can deploy `Qlib-Server` in `Azure` according to the following processes: |
| 62 | + |
| 63 | +* Install `azure-cli`, please refer to [install-azure-cli](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest). |
| 64 | + |
| 65 | +* Add the `Azure` account to the configuration file `azure_conf.yaml` |
| 66 | + |
| 67 | + ```yaml |
| 68 | + sub_id: Your Subscription ID |
| 69 | + username: azure user name |
| 70 | + password: azure password |
| 71 | + # The resource group where the VM is located |
| 72 | + resource_group: Resource group name |
| 73 | + ``` |
| 74 | +* Execute the deployment script |
| 75 | + Run the following command: |
| 76 | + |
| 77 | + ```bash |
| 78 | +
|
| 79 | + git clone https://github.com/microsoft/qlib-server |
| 80 | + cd qlib-server/scripts |
| 81 | + python azure_manager.py create_qlib_cs_vm \ |
| 82 | + --qlib_server_name test_server01 \ |
| 83 | + --qlib_client_names test_client01 \ |
| 84 | + --admin_username test_user \ |
| 85 | + --ssh_key_value ~/.ssh/id_rsa.pub \ |
| 86 | + --size standard_NV6_Promo\ |
| 87 | + --conf_path azure_conf.yaml |
| 88 | + ``` |
| 89 | + |
| 90 | +To know more about one-click Deployment, please refer to [Qlib-Server One-click Deplyment](https://qlib-server.readthedocs.io/en/latest/build.html#one-click-deployment). |
| 91 | + |
| 92 | +### Step-by-step Deployment |
| 93 | + |
| 94 | +To know more about step-by-step Deployment, please refer to [Qlib-Server Step-by-step Deplyment]https://qlib-server.readthedocs.io/en/latest/build.html#step-by-step-deployment). |
| 95 | + |
| 96 | + |
| 97 | +## Using `Qlib` in `Online` Mode |
| 98 | + |
| 99 | +In the [Qlib Document](https://qlib.readthedocs.io/en/latest), the `Offline` mode has been introduced. |
| 100 | + |
| 101 | +With `Qlib-Server`, you can use `Qlib` in `Online` mode, please initialize `Qlib` with the following code: |
| 102 | + |
| 103 | +```python |
| 104 | +import qlib |
| 105 | +ONLINE_CONFIG = { |
| 106 | + # data provider config |
| 107 | + "calendar_provider": {"class": "LocalCalendarProvider", "kwargs": {"remote": True}}, |
| 108 | + "instrument_provider": "ClientInstrumentProvider", |
| 109 | + "feature_provider": {"class": "LocalFeatureProvider", "kwargs": {"remote": True}}, |
| 110 | + "expression_provider": "LocalExpressionProvider", |
| 111 | + "dataset_provider": "ClientDatasetProvider", |
| 112 | + "provider": "ClientProvider", |
| 113 | + # config it in user's own code |
| 114 | + "provider_uri": "127.0.0.1:/", |
| 115 | + # cache |
| 116 | + # Using parameter 'remote' to announce the client is using server_cache, and the writing access will be disabled. |
| 117 | + "expression_cache": None, |
| 118 | + "dataset_cache": None, |
| 119 | + "calendar_cache": None, |
| 120 | + "mount_path": "/data/stock_data/qlib_data", |
| 121 | + "auto_mount": True, # The nfs is already mounted on our server[auto_mount: False]. |
| 122 | + "flask_server": "127.0.0.1", |
| 123 | + "flask_port": 9710, |
| 124 | + "region": "cn", |
| 125 | +} |
| 126 | +
|
| 127 | +qlib.init(**client_config) |
| 128 | +ins = D.list_instruments(D.instrumetns("all"), as_list=True) |
| 129 | +
|
| 130 | +``` |
| 131 | + |
| 132 | +For more details, please refer to [Qlib-Server Client](https://qlib-server.readthedocs.io/en/latest/client.html). |
19 | 133 |
|
20 | | -# More About qlib-server |
| 134 | +# More About Qlib-Server |
21 | 135 |
|
22 | 136 |
|
23 | 137 | # Contributing |
|
0 commit comments