@Channelchan
2018-03-17T14:51:19.000000Z
字数 4878
阅读 911
jaqs
在jaqs.data中添加了fxdayu_dv.py文件,新的类FxdayuDataView继承DataView,添加了从服务查询字段并更新相应默认字段的操作,目前会从服务器查询factor的fields,在输入的config中添加:
prepare_fields=True
将会在init时执行此操作。执行该操作后在fields中添加factor的fields可以获取到factor的数据。
已经上传了新的分支:fxdayu_dv, 未合并。
https://github.com/xingetouzi/JAQS/tree/fxdayu_dv
from jaqs.data import RemoteDataService
from jaqs.data.fxdayu_dv import FxdayuDataView
data_config = {
"remote.data.address": "tcp://192.168.0.102:23000",
# "remote.data.address": "tcp://data.tushare.org:8910",
"remote.data.username": "xxx",
"remote.data.password": "xxx",
}
props = {
'start_date': 20170227, 'end_date': 20170327, 'universe': '000016.SH',
'fields': 'CMRA,DDNBT,PE,PB', # 这些都是factor的字段
"prepare_fields": True, # 这里设为True才能获取factor的数据
'freq': 1
}
def trial():
ds = RemoteDataService()
ds.init_from_config(data_config)
dv = FxdayuDataView()
dv.init_from_config(props, ds)
dv.prepare_data()
print(dv.get_ts("CMRA")) # 验证数据
dv.save_dataview('.') # 保存到当前目录
if __name__ == '__main__':
trial()
Begin: DataApi login 18566262672@tcp://192.168.0.102:23000
login success
Initialize config success.
Query data...
Query data - query...
NOTE: price adjust method is [post adjust]
Query data - daily fields prepared.
Query instrument info...
Query adj_factor...
Query benchmark...
Query benchmar member info...
Data has been successfully
symbol 600000.SH 600016.SH 600028.SH 600029.SH 600030.SH 600036.SH \
trade_date
20170227 0.3235 0.2579 0.6747 0.8154 0.9888 0.2950
20170228 0.2846 0.2846 0.6967 0.8121 0.9701 0.2965
20170301 0.2245 0.2310 0.6358 0.7953 0.9283 0.2776
20170302 0.2875 0.2286 0.6288 0.6648 0.9283 0.2516
20170303 0.2568 0.2298 0.6428 0.5959 0.9283 0.2821
20170306 0.2406 0.2506 0.5825 0.6405 0.9242 0.2966
20170307 0.2937 0.2443 0.5825 0.6779 0.9361 0.3076
20170308 0.2887 0.2752 0.6327 0.6892 0.9340 0.3521
20170309 0.2378 0.2533 0.6154 0.7141 0.9253 0.3378
20170310 0.2339 0.2671 0.6041 0.7920 0.9273 0.3203
20170313 0.2007 0.2652 0.5990 0.7310 0.9144 0.3125
20170314 0.1987 0.2652 0.5990 0.7029 0.9282 0.3125
20170315 0.1866 0.2218 0.5840 0.7494 0.9251 0.2854
20170316 0.1895 0.2605 0.5231 0.7928 0.8863 0.2556
20170317 0.2078 0.2550 0.5353 0.7890 0.9325 0.2568
20170320 0.2479 0.2054 0.5077 0.7839 0.8922 0.2739
20170321 0.2971 0.2377 0.5091 0.8031 0.9229 0.2744
20170322 0.2845 0.2460 0.5361 0.8145 0.9782 0.2564
20170323 0.2929 0.2328 0.5361 0.9095 0.9936 0.2675
20170324 0.3921 0.2943 0.5542 0.9582 0.9442 0.2714
20170327 0.3235 0.2579 0.6747 0.8154 0.9888 0.2950
symbol 600048.SH 600050.SH 600100.SH 600104.SH ... 601766.SH \
trade_date ...
20170227 0.5942 0.9536 0.9503 0.5194 ... 1.3442
20170228 0.5397 1.0072 0.9250 0.4901 ... 1.2651
20170301 0.6279 0.9132 1.0691 0.4745 ... 1.2659
20170302 0.6279 0.9132 1.0443 0.4745 ... 1.2637
20170303 0.6279 0.9132 1.0214 0.4745 ... 1.2637
20170306 0.5356 0.8569 0.9705 0.4455 ... 1.1956
20170307 0.5808 0.8492 0.9592 0.4402 ... 1.1956
20170308 0.5596 0.9521 0.9472 0.4451 ... 1.2866
20170309 0.5311 0.9677 0.9887 0.4203 ... 1.1901
20170310 0.5226 0.9321 1.0155 0.4213 ... 1.1878
20170313 0.5597 0.9319 1.0047 0.4194 ... 1.1811
20170314 0.5173 0.9267 0.9694 0.3946 ... 1.1789
20170315 0.4744 0.8710 0.9371 0.3862 ... 1.1813
20170316 0.5025 0.7994 0.9179 0.4418 ... 1.2767
20170317 0.5345 0.8362 0.9032 0.4574 ... 1.3720
20170320 0.5106 0.7900 0.7178 0.4547 ... 1.3591
20170321 0.5217 0.8186 0.7317 0.5061 ... 1.2536
20170322 0.5295 0.8567 0.7202 0.5082 ... 1.2016
20170323 0.5412 0.8541 0.6722 0.5262 ... 1.2238
20170324 0.5417 0.8659 0.7014 0.5684 ... 1.3370
20170327 0.5942 0.9536 0.9503 0.5194 ... 1.3442
symbol 601788.SH 601800.SH 601818.SH 601857.SH 601901.SH 601985.SH \
trade_date
20170227 0.8245 0.8004 0.4704 0.7188 0.9040 1.4147
20170228 0.8241 0.7853 0.5184 0.6898 0.8920 1.4147
20170301 0.7829 0.7229 0.4842 0.6178 0.8656 1.3684
20170302 0.7829 0.7229 0.4919 0.6178 0.8656 1.2632
20170303 0.7829 0.7229 0.4711 0.6178 0.8656 1.1578
20170306 0.7596 0.6790 0.5273 0.5890 0.8435 1.1761
20170307 0.7596 0.6790 0.5273 0.6304 0.8442 1.1879
20170308 0.8308 0.6442 0.6005 0.6133 0.8495 1.1879
20170309 0.7920 0.6020 0.5799 0.6047 0.8645 1.1924
20170310 0.8090 0.5901 0.5473 0.5992 0.8639 1.2831
20170313 0.8193 0.6505 0.5751 0.5893 0.8520 1.2839
20170314 0.8130 0.6807 0.5751 0.5893 0.9248 1.2574
20170315 0.8517 0.6932 0.5505 0.6329 0.9430 1.2574
20170316 0.7633 0.6642 0.5148 0.6254 0.8766 1.2574
20170317 0.7746 0.7488 0.5367 0.6198 0.9160 1.2413
20170320 0.7276 0.7964 0.4177 0.6442 0.8491 1.2180
20170321 0.7456 0.7266 0.4270 0.6286 0.8665 1.2790
20170322 0.8095 0.7176 0.4399 0.6369 0.8817 1.2566
20170323 0.8847 0.7054 0.4279 0.6433 0.9047 1.2790
20170324 0.8339 0.7593 0.4562 0.6531 0.8501 1.2388
20170327 0.8245 0.8004 0.4704 0.7188 0.9040 1.4147
symbol 601988.SH 601989.SH 601998.SH
trade_date
20170227 0.4233 1.1522 0.4055
20170228 0.4740 1.0668 0.4177
20170301 0.4232 1.1437 0.3812
20170302 0.4483 1.1080 0.3788
20170303 0.4232 1.0742 0.3677
20170306 0.4324 1.1019 0.4043
20170307 0.5277 1.1019 0.5000
20170308 0.5641 1.1207 0.5324
20170309 0.5659 1.1835 0.5730
20170310 0.5534 1.1188 0.5720
20170313 0.4937 1.0820 0.5127
20170314 0.4976 1.0820 0.5931
20170315 0.5398 1.0820 0.6402
20170316 0.4820 1.0721 0.5750
20170317 0.4674 1.0837 0.5741
20170320 0.4716 1.0953 0.5905
20170321 0.4560 1.0953 0.5443
20170322 0.4419 1.0953 0.5263
20170323 0.4458 1.0870 0.5327
20170324 0.4609 1.1021 0.5193
20170327 0.4233 1.1522 0.4055
[21 rows x 50 columns]
Store data...
Dataview has been successfully saved to:
D:\JAQS\fxdayu_test
You can load it with load_dataview('D:\JAQS\fxdayu_test')