请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  量化平台 帖子:3365791 新帖:0

jqdata获取资金净流入排名

Tango发表于:5 月 9 日 20:26回复(1)

按各种周期计算主力净流入资金额,并排名

#api-获取资金流信息## 导入常用librariesimport datetimeimport pandas as pdfrom jqdata import *#auth('jqdata帐号','jqdata帐号密码')pd.options.display.max_rows = 500pd.options.display.max_columns = 20date_now = datetime.datetime.now()oneDay = datetime.timedelta(days=1)yesterday = (date_now - oneDay).strftime("%Y-%m-%d")today_date = date_now.strftime("%Y-%m-%d")if datetime.datetime.now().hour > 16:sum_end_day = today_dateelse:sum_end_day = yesterdaytrade_day_list = get_trade_days(end_date= sum_end_day , count=100)#1天-昨天days_before_1 = trade_day_list[-1].strftime("%Y-%m-%d")#3天:days_before_3 = trade_day_list[-3].strftime("%Y-%m-%d")#5天:days_before_5 = trade_day_list[-5].strftime("%Y-%m-%d")#8天:days_before_8 = trade_day_list[-8].strftime("%Y-%m-%d")#10天:days_before_10 = trade_day_list[-10].strftime("%Y-%m-%d")#13天:days_before_13 = trade_day_list[-13].strftime("%Y-%m-%d")#20天:days_before_20 = trade_day_list[-20].strftime("%Y-%m-%d")#30天:days_before_30 = trade_day_list[-30].strftime("%Y-%m-%d")#50天:days_before_50 = trade_day_list[-50].strftime("%Y-%m-%d")#89天:days_before_89 = trade_day_list[-89].strftime("%Y-%m-%d")# # stocks = get_index_stocks('000300.XSHG')# # stocks = get_index_stocks('000001.XSHG')stocks = get_index_stocks('000300.XSHG')# # N天资金流#df_source = get_money_flow(stocks, end_date=sum_end_day, count= 100)# print(df_source)df1 = df_source[df_source['date'] >= days_before_1]df1_sum = df1.groupby('sec_code')["net_amount_main"].sum()df3 = df_source[df_source['date'] >= days_before_3]df3_sum = df3.groupby('sec_code')["net_amount_main"].sum()df5 = df_source[df_source['date'] >= days_before_5]df5_sum = df5.groupby('sec_code')["net_amount_main"].sum()df8 = df_source[df_source['date'] >= days_before_8]df8_sum = df8.groupby('sec_code')["net_amount_main"].sum()# df10 = df_source[df_source['date'] >= days_before_10]# df10_sum = df10.groupby('sec_code')["net_amount_main"].sum()df13 = df_source[df_source['date'] >= days_before_13]df13_sum = df13.groupby('sec_code')["net_amount_main"].sum()df20 = df_source[df_source['date'] >= days_before_20]df20_sum = df20.groupby('sec_code')["net_amount_main"].sum()df30 = df_source[df_source['date'] >= days_before_30]df30_sum = df30.groupby('sec_code')["net_amount_main"].sum()df50 = df_source[df_source['date'] >= days_before_50]df50_sum = df50.groupby('sec_code')["net_amount_main"].sum()df89 = df_source[df_source['date'] >= days_before_89]df89_sum = df89.groupby('sec_code')["net_amount_main"].sum()pd_all = pd.concat([df1_sum, df3_sum, df5_sum, df8_sum, df13_sum, df20_sum, df30_sum,df50_sum,df89_sum], axis=1)pd_all.columns = ['c1', 'c3', 'c5', 'c8', 'c13', 'c20', 'c30', 'c50', 'c89']df_sorted = pd_all.sort_values(by='c5', ascending=False)for index in df_sorted.index:sec = get_security_info(normalize_code(index))df_sorted.ix[index, 'security'] = sec.display_namemid = df_sorted['security']df_sorted.drop(labels=['security'], axis=1,inplace = True)df_sorted.insert(0, 'security', mid)df_sorted[:100]
/opt/conda/lib/python3.5/site-packages/ipykernel_launcher.py:90: DeprecationWarning: 
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing

See the documentation here:
http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated

.dataframe thead tr:only-child th {        text-align: right;    }    .dataframe thead th {        text-align: left;    }    .dataframe tbody tr th {        vertical-align: top;    }


securityc1c3c5c8c13c20c30c50c89
600104.XSHG上汽集团16191.449232024.211242797.351642967.802543703.697933123.4308-11753.9730-22144.1577-76830.9696
000063.XSHE中兴通讯-16635.624328984.033338094.4368-30160.4499-71346.2225-242061.4209-332182.8261-267943.7836-669440.7635
601988.XSHG中国银行5745.577721531.984627384.606023331.958623827.748923548.859926215.8985-44026.7702-69248.8973
601288.XSHG农业银行6372.988522265.000825324.271225692.677522609.03868844.33886526.8865-87678.4521-92799.4431
000661.XSHE长春高新-390.79678301.252013687.94254482.5739-10582.7920-16393.9239-19732.0714-16095.0461-101764.3641
600887.XSHG伊利股份1122.90128163.548910673.1864-5461.6967-7922.0408-30388.7109-41811.0785-142288.7980-268159.7100
002714.XSHE牧原股份851.86904725.65578090.06658614.50511175.9622-39.21902912.0647-9580.3176-21856.9502
601398.XSHG工商银行5752.764524573.51527665.7231-4682.7232-6495.1058-6707.9006-10902.5748-90424.7205-90018.2170
601989.XSHG中国重工271.22777565.64117390.34735149.6108-55.7033-796.2810-3982.6964-8682.7867-33379.2360
600498.XSHG烽火通信-3705.34758230.22616190.0671-526.9157-10680.1108-43214.7556-45273.4441-44291.1238-75759.6904
002411.XSHE延安必康1570.40003833.21065738.91753334.43727732.09534715.82624445.28824445.28822899.0154
600352.XSHG浙江龙盛4680.06135038.71385072.0321-437.52173747.13714610.0865-8158.2732-22750.1605-83594.6070
600028.XSHG中国石化1629.00585770.57724862.8532-15055.1205-24684.8747-45033.5015-51250.9547-154449.4300-309938.9337
002493.XSHE荣盛石化233.19651246.98503910.67794508.79516884.45967263.785811915.646730717.587524796.0614
300144.XSHE宋城演艺3359.50334187.79663812.1815782.4143-8618.1442-3908.1999-10028.1735-17797.2270-35511.1621
002475.XSHE立讯精密4231.79038570.17603457.5309-7267.2629-36802.5409-37837.8192-37501.3934-117843.7210-184575.3626
600900.XSHG长江电力-1797.8086113.78423090.27592336.395815663.09177934.20366251.4362-45422.0460-43524.2179
002044.XSHE美年健康2165.54733272.17143030.7025944.9058707.76082318.0840-4245.5797-14363.0225525.0215
600271.XSHG航天信息-1126.75401300.16192663.0949-2493.6434-1883.4507-38332.1268-42545.2257-29958.0022-103762.5173
600977.XSHG中国电影501.82721010.23272653.46461424.50864046.48403052.28012181.41865827.61432871.4944
601328.XSHG交通银行3931.78207540.62072533.40461561.6582-1672.8254-15321.0513-17976.3120-39553.1056-124332.2024
600741.XSHG华域汽车163.88461279.33032311.09652256.37753230.86451592.4548-7041.6905-4049.0620-6094.8370
601238.XSHG广汽集团-35.2425438.92562108.84562406.82611466.57962766.59482900.38848960.010618871.1307
603858.XSHG步长制药935.97772601.81632065.22861742.2805-152.6247-8078.8545-8226.5271-13026.3439-34354.6182
600346.XSHG恒力股份425.6293238.40112048.90052969.39872785.18151970.6005-10209.9696-17224.4115-12121.8708
002624.XSHE完美世界671.2224218.26642027.8593-261.3439-610.83294167.14072422.89389501.18879758.8810
300433.XSHE蓝思科技758.80161843.17152021.9581252.5687-2140.4209-4664.1198-10130.3645-12496.0739-36238.4344
000963.XSHE华东医药539.62061662.48261893.4132-8107.9526-47196.3278-83104.7158-109494.8657-124204.7576-187690.2685
601012.XSHG隆基股份664.10155004.64781865.0439-4237.9045-8239.5889-7822.4366-15699.9302-10801.7963-45739.2391
000703.XSHE恒逸石化748.80871880.01331787.2625-1138.62693145.1397-1064.4285-18746.5037-47932.4869-70042.0097
601899.XSHG紫金矿业-1633.2013-1755.36531680.7481719.7950-7682.0072-13300.3294-25319.2437-44098.5678-66378.6662
600674.XSHG川投能源-479.9238-575.18691630.76653178.91933914.91332891.47552137.8183-6690.2200-8700.9181
600570.XSHG恒生电子-90.08911480.30961561.2829-4402.2877-9845.1954-8728.3212-19021.093113141.9365-43162.2814
000839.XSHE中信国安504.77872218.05181530.4369-396.0378-2833.1910-21806.7211-13683.7043-13594.3623-41400.4646
002311.XSHE海大集团245.6821780.57361517.8363-559.16562896.05274285.27174658.51419052.96679421.7686
600016.XSHG民生银行-2073.30652729.59561456.0277-3347.1385-9454.5094-14386.8566-29440.9824-63278.6992-128055.1638
000100.XSHETCL集团736.67332940.92521420.36952290.5887-10205.2529-6609.1565-16941.1184-27803.7154-54749.4701
600690.XSHG青岛海尔271.5446860.59781362.6832509.72817116.6351-5124.2825-6066.0251-28242.1663-79771.0909
601985.XSHG中国核电-264.8352796.69511355.5098-159.24931056.9990-1307.7144-5999.9798-15440.3285-20102.7321
600025.XSHG华能水电-186.9840-519.23131255.93483123.07766872.90717549.367910683.343118419.84579432.1559
002925.XSHE盈趣科技1015.3075996.17531182.0073-1924.8051-4298.1748-3834.31471661.46377677.6273-7455.4270
600795.XSHG国电电力1554.99111184.81251157.2818-1342.6068-1679.5822-1195.4658-200.6750-9227.2637-30307.5514
601006.XSHG大秦铁路852.26251365.46181076.0924-8525.9997-10223.5747-3627.6182-3671.2881-22019.2181-67178.1566
601021.XSHG春秋航空-93.0709819.3845837.50101806.49593164.07573264.95473791.41535403.26657593.7711
600566.XSHG济川药业-130.9910459.6421796.0558365.3589-5039.4158-10024.4694-13987.7735-22745.4855-31086.4029
600362.XSHG江西铜业907.03401555.7032774.9346333.12033306.6467235.4900-3030.8678-14422.2582-37128.3352
600739.XSHG辽宁成大163.8171795.5485759.5436-872.0776-1945.1543-6517.0259-4784.8490-13436.6794-14001.4103
000625.XSHE长安汽车-44.4628525.6423721.6911-830.6117-385.9886-413.3481-3002.3364-1007.5609-16449.7519
002773.XSHE康弘药业368.7806416.4825703.1594223.8053-1107.0805-3273.7134-7773.2938-6489.9689-15855.5575
600703.XSHG三安光电1135.2842689.4053666.1611-9383.0798-11219.5848-19338.6275-17454.5273-4692.1829-95971.4559
600066.XSHG宇通客车324.5311619.5242615.8763-28.1364-1864.0164-565.2664-993.8171-3726.5336-15324.6594
300142.XSHE沃森生物1140.3785391.6792575.0778-6499.4752-15526.0091-17912.2262-20363.1121-45368.8096-76780.7298
601333.XSHG广深铁路647.4998720.9552497.9676-334.0909-1660.9890-641.5474-1672.2793-16701.9428-30961.6318
600027.XSHG华电国际75.5103372.0741479.9062-2532.5438-9025.1318-12289.3099-14856.6878-17793.7644-11885.6911
002007.XSHE华兰生物1536.27663844.6789452.3690-23475.0811-64258.3923-91456.1945-113516.7386-132464.1429-164155.2306
601555.XSHG东吴证券101.5044-355.8762450.558345.8689-826.8473-4528.1337-9681.4950-5097.2968-6786.9236
601212.XSHG白银有色153.2551-41.1925418.389487.4640-185.6917-1003.7875-2148.3161-4210.0489-2808.9092
000959.XSHE首钢股份128.6566318.5694368.2099268.3798-272.7926-326.2663-1838.0275-2172.5617-6423.7936
601998.XSHG中信银行403.2316638.3817333.9113-1001.063973.9916-1274.0442-2674.0457-14512.9240-24294.3373
600660.XSHG福耀玻璃532.70371546.6219302.0304-1904.0143-4534.6652-1317.4617-3870.9772-21569.6000-29090.3766
600398.XSHG海澜之家7.6975308.2805249.2253-577.9529579.4309-139.1934-233.7491-2569.3654-6951.5942
002241.XSHE歌尔股份-991.9838864.9762199.0377-1867.4091-5840.6659-7950.6558-19601.9454-22842.7113-44409.3878
603260.XSHG合盛硅业-20.0489310.2321190.0024-597.9085-947.8826-1730.2260-4468.4441-7235.9380-22966.3181
000876.XSHE新希望-432.7066-282.3179136.0416-2130.3516-3117.0741-2002.3894-2529.4786-3181.1741-10404.9931
002468.XSHE申通快递394.7698227.0067113.6196-640.9097-2259.0118-888.2200-3275.9971-15788.2823-28159.5603
600023.XSHG浙能电力-171.752959.7772102.1044-48.9345-772.0675-226.43131960.17735261.1769-3227.9723
600372.XSHG中航电子-284.9743803.152329.7845-651.0786-2537.0221-4064.7950581.13601799.172383.1377
600339.XSHG中油工程-188.1167-54.142610.7872-370.3829-596.4624-3115.0708-5526.8562-8937.1013-15999.9102
600704.XSHG物产中大-77.9582103.7455-0.2548-1525.3879-2840.5605-6158.8710-7818.6371-9682.4934-13484.2278
300408.XSHE三环集团-54.5591349.2169-9.1022-2897.2326-6505.2587-10689.0208-9414.2532-11861.6557-40116.0665
603833.XSHG欧派家居178.7394-239.9731-69.6015226.1482476.15851792.489993.1504-1379.2444-484.4850
600018.XSHG上港集团33.3752-42.6606-78.8253-121.9989-3333.0925-4534.8966-4579.3986-7518.6928-16497.4613
001965.XSHE招商公路23.984555.2262-110.6513-161.5481-86.8018-622.3499-1167.3830-1346.2261-1917.5864
603156.XSHG养元饮品-35.8866-60.8426-119.0094-615.0433-494.2545-1098.8469-3015.0717-5548.8075-4939.1614
600415.XSHG小商品城-296.4618-519.8583-170.65825.2102-168.5785-886.8648-658.9261-746.5096-5517.7495
601828.XSHG美凯龙-218.7755-171.5280-237.1820-664.3051-1049.2609-395.2487-1818.7333-5345.3300-13989.4775
600489.XSHG中金黄金1984.27211715.2816-286.7389-630.16332352.59134819.86645234.5027-22066.0775-5113.7277
600547.XSHG山东黄金3687.28372087.9342-291.0889-6103.9941-12128.7378-1506.3745-7179.8321-37067.1250-36730.4480
000671.XSHE阳光城-160.7359245.3444-335.0261-2921.1471-4775.9366-12810.9792-11681.8342-9397.9132-24826.4428
600208.XSHG新湖中宝-225.7239-159.5958-385.8728-1314.6450939.4151-449.5593-2966.0522-6182.7573-2436.6203
601808.XSHG中海油服28.3594-144.3404-388.0542-1009.6346-978.2053-1488.8926-3083.4808-3188.7227-4569.9995
600998.XSHG九州通-22.7758-278.4558-405.1069-430.7037-1707.9726-1642.0114-1484.97444850.77046156.6322
601198.XSHG东兴证券-341.7854-893.0128-427.1448-1600.4632-2354.6958-7720.3740-14645.8770-11573.5535-21668.6852
601228.XSHG广州港65.1745-336.4853-429.2087-1306.2641-910.7124-1120.6847-1519.4447-4635.3198-8369.7006
601727.XSHG上海电气-300.9596-552.8033-491.5798-897.8973-1247.2543-2410.3260-2793.9193-6153.7481-11265.3138
600535.XSHG天士力329.4093-286.2403-496.5609-550.3852-3242.4545-7506.1087-11614.8861-13902.7342-24914.2354
600011.XSHG华能国际151.7953375.1587-500.9565-2832.5001-2868.4577-2488.6660-5622.9546-14639.1428-16120.8358
000553.XSHE沙隆达A-26.9899-285.4564-503.0486-749.9661-851.1647-1009.8493-2858.4708-3244.1731-9789.0811
601618.XSHG中国中冶45.6222-195.7330-563.1239-1488.6412-5650.9321-9910.4243-18556.8705-31066.5970-38888.6840
000538.XSHE云南白药143.41452435.9439-566.4649-8730.9297-12500.9189-4778.3525-24412.1447-24412.1447-63575.1666
000069.XSHE华侨城A660.8406368.3054-570.7189-5120.8208-6002.3411-12576.1043-3783.0197-277.9132-17298.5266
002736.XSHE国信证券-126.8319-639.8240-582.1383-969.2735-3159.5585-6699.6400-11070.7033-12877.3707-16552.4348
000826.XSHE启迪桑德157.1565-661.2150-586.1403-2928.7305-4156.4166-7879.2338-15462.5327-12236.1329-33994.8812
600688.XSHG上海石化-138.1162-103.0960-600.3186-2716.9360-4327.4311-4954.1012-8128.8808-8891.5496-27276.4189
601901.XSHG方正证券249.7795-545.5215-609.6246-1550.7847-4660.7871-6749.2455-10709.9990-17393.9807-28323.0760
600233.XSHG圆通速递-26.9032-336.9975-619.6470-760.2409-858.4171-1076.3486-846.0837-5076.0641-8068.8590
601607.XSHG上海医药158.9771-52.6397-623.8633-2003.0683-10356.0965-22002.0275-28641.3847-31547.3981-53630.8944
601633.XSHG长城汽车-239.7527132.6035-728.1327-2484.8054-3160.1477-6112.8297-1785.4626-1465.6881-5064.7870
000627.XSHE天茂集团40.2576-106.4531-740.5718-859.2829-1919.1312-1394.2259-4798.5167-704.7813-5936.3511
000338.XSHE潍柴动力1306.2194-1684.3779-766.65232877.43987889.37848292.1469902.4994-31100.8093-64456.6081
 
 

全部回复

0/140

达人推荐

量化课程

    移动端课程