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

量化交易吧 /  量化平台 帖子:3364737 新帖:1

r融资融券和股价的关系

不做外汇索罗斯发表于:6 月 28 日 20:00回复(1)
import jqdata as jq
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
 
a=get_mtss('002038.XSHE', '2018-01-01', '2018-07-20')
b=get_price('002038.XSHE', '2018-01-01', '2018-07-20',fields='close')
print(a)
print(b)
          date     sec_code   fin_value  fin_buy_value  fin_refund_value  \
0   2018-01-02  002038.XSHE  1559566392       30328094          49738674   
1   2018-01-03  002038.XSHE  1559620601       31038894          30984685   
2   2018-01-04  002038.XSHE  1585682984       75697116          49634733   
3   2018-01-05  002038.XSHE  1578678663       38560939          45565260   
4   2018-01-08  002038.XSHE  1592058672       47760445          34380436   
5   2018-01-09  002038.XSHE  1601788086       97766494          88037080   
6   2018-01-10  002038.XSHE  1589709383       40082697          52161400   
7   2018-01-11  002038.XSHE  1583798462       49965199          55876120   
8   2018-01-12  002038.XSHE  1566256850       38479590          56021202   
9   2018-01-15  002038.XSHE  1556586822       49567895          59237923   
10  2018-01-16  002038.XSHE  1546763663       24329493          34152652   
11  2018-01-17  002038.XSHE  1528637974       29670602          47796291   
12  2018-01-18  002038.XSHE  1527269852       17995137          19363259   
13  2018-01-19  002038.XSHE  1525596418       28211725          29885159   
14  2018-01-22  002038.XSHE  1527480191       30301773          28418000   
15  2018-01-23  002038.XSHE  1523805999       22458398          26132590   
16  2018-01-24  002038.XSHE  1543038942       70029417          50796474   
17  2018-01-25  002038.XSHE  1544001411       39168696          38206227   
18  2018-01-26  002038.XSHE  1530819646       67917098          81098863   
19  2018-01-29  002038.XSHE  1521313142       39531731          49038235   
20  2018-01-30  002038.XSHE  1523177214       24225125          22361053   
21  2018-01-31  002038.XSHE  1554239809       61737543          30674948   
22  2018-02-01  002038.XSHE  1556167612       41029888          39102085   
23  2018-02-02  002038.XSHE  1542354869       27388484          41201227   
24  2018-02-05  002038.XSHE  1538888067       36957677          40424479   
25  2018-02-06  002038.XSHE  1522051855       54331798          71168010   
26  2018-02-07  002038.XSHE  1505524226       26519539          43047168   
27  2018-02-08  002038.XSHE  1503469615       26079872          28134483   
28  2018-02-09  002038.XSHE  1502155249       26907937          28222303   
29  2018-02-12  002038.XSHE  1495091087       21872521          28936683   
..         ...          ...         ...            ...               ...   
103 2018-06-07  002038.XSHE  1959118043       78331052          59479515   
104 2018-06-08  002038.XSHE  1933181121       49491640          75428562   
105 2018-06-11  002038.XSHE  1789909108       68247188         211519201   
106 2018-06-12  002038.XSHE  1795195018      112791892         107505982   
107 2018-06-13  002038.XSHE  1779591983       67246868          82849903   
108 2018-06-14  002038.XSHE  1787752654      112632633         104471962   
109 2018-06-15  002038.XSHE  1796606761      100476095          91621988   
110 2018-06-19  002038.XSHE  1813128510      188831237         172309488   
111 2018-06-20  002038.XSHE  1779546420      113531294         147113384   
112 2018-06-21  002038.XSHE  1750789845      273199349         301955924   
113 2018-06-22  002038.XSHE  1807228675      217587293         161148463   
114 2018-06-25  002038.XSHE  1842782436      149608132         114054371   
115 2018-06-26  002038.XSHE  1819965324       55153138          77970250   
116 2018-06-27  002038.XSHE  1823433227       99475360          96007457   
117 2018-06-28  002038.XSHE  1807676837       43973715          59730105   
118 2018-06-29  002038.XSHE  1792770306       75944962          90851493   
119 2018-07-02  002038.XSHE  1816469856      109364510          85664960   
120 2018-07-03  002038.XSHE  1822914432      100982945          94538369   
121 2018-07-04  002038.XSHE  1829623546       49268582          42559468   
122 2018-07-05  002038.XSHE  1822052743       57252031          64822834   
123 2018-07-06  002038.XSHE  1824018730       59371951          57405964   
124 2018-07-09  002038.XSHE  1790620668       48294942          81693004   
125 2018-07-10  002038.XSHE  1786260094       50179673          54540247   
126 2018-07-11  002038.XSHE  1782788439       48383839          51855494   
127 2018-07-12  002038.XSHE  1683531236       71932205         171189408   
128 2018-07-13  002038.XSHE  1652043245       93921863         125409854   
129 2018-07-16  002038.XSHE  1653772534       55282543          53553254   
130 2018-07-17  002038.XSHE  1694272734       81465054          40964854   
131 2018-07-18  002038.XSHE  1694497464       48220407          47995677   
132 2018-07-19  002038.XSHE  1733864102      125636687          86270049   

     sec_value  sec_sell_value  sec_refund_value  fin_sec_value  
0        20500           12000             16100     1560206197  
1        20200            3900              4200     1560257911  
2        24600            8300              3900     1586468954  
3        23600            4000              5000     1579421591  
4         5800            2900             20700     1592239168  
5        41400           39000              3400     1603115370  
6         4200            1800             39000     1589842901  
7         6100            2500               600     1583995126  
8         3000               0              3100     1566355220  
9         4100            1200               100     1556718022  
10       12300            9400              1200     1547162306  
11       13700            1400                 0     1529075689  
12       13700               0                 0     1527705786  
13       13000            1200              1900     1526003968  
14        2400               0             10600     1527557351  
15        2400               0                 0     1523883279  
16        2900             600               100     1543135077  
17        3700            1400               600     1544123326  
18        8300            6000              1400     1531097530  
19        5000            2700              6000     1521477842  
20        6000            2000              1000     1523376534  
21        5000            1000              2000     1554400209  
22       13900            8900                 0     1556607547  
23        6700               0              7200     1542563105  
24       15300           11000              2400     1539347832  
25        4100               0             11200     1522163580  
26        4600            3200              2700     1505651002  
27        4300               0               300     1503588897  
28        5800            2700              1200     1502311849  
29        4800            1200              2200     1495225295  
..         ...             ...               ...            ...  
103      53560            3000             11400     1961616617  
104      54560           11300             10300     1935694700  
105      56560           14400             12400     1792469014  
106      61960           15600             10200     1798118910  
107      61960           12400             12400     1782477460  
108      57888           12800             16872     1790372086  
109      54407           13619             17100     1799098602  
110      48507           17900             23800     1815250691  
111      48907           16700             16300     1781756038  
112      38107           10400             21200     1752339276  
113      54607           31500             15000     1809328314  
114      46807           12700             20500     1844495572  
115      47007           18900             18700     1821730437  
116      44107           24800             27700     1825021520  
117      51607           21900             14400     1809540366  
118      40379           11272             22500     1794304304  
119      47079           16400              9700     1818221666  
120      31679           21100             36500     1824073567  
121      38679           21500             14500     1831024886  
122      54179           30700             15200     1823960927  
123      34579           16600             36200     1825258733  
124      44879           23800             13500     1792283884  
125      37705           16026             23200     1787654048  
126      52505           34600             19800     1784686495  
127      61105           49400             40800     1685842838  
128     108305           55300              8100     1656214071  
129      73105           18100             53300     1656595118  
130      89805           35400             18700     1697678140  
131      92505           32900             30200     1697943275  
132      79205           23700             37000     1736650534  

[133 rows x 9 columns]
            close
2018-01-02  30.87
2018-01-03  31.20
2018-01-04  31.60
2018-01-05  31.13
2018-01-08  30.78
2018-01-09  31.71
2018-01-10  31.44
2018-01-11  31.89
2018-01-12  32.43
2018-01-15  31.65
2018-01-16  32.05
2018-01-17  31.60
2018-01-18  31.47
2018-01-19  31.00
2018-01-22  31.80
2018-01-23  31.85
2018-01-24  32.78
2018-01-25  32.59
2018-01-26  33.11
2018-01-29  32.58
2018-01-30  32.85
2018-01-31  31.73
2018-02-01  31.30
2018-02-02  30.74
2018-02-05  29.72
2018-02-06  26.95
2018-02-07  27.26
2018-02-08  27.43
2018-02-09  26.70
2018-02-12  27.65
...           ...
2018-06-08  46.07
2018-06-11  45.26
2018-06-12  47.19
2018-06-13  46.57
2018-06-14  45.25
2018-06-15  45.80
2018-06-19  43.75
2018-06-20  45.18
2018-06-21  40.66
2018-06-22  38.45
2018-06-25  36.60
2018-06-26  37.55
2018-06-27  36.01
2018-06-28  36.11
2018-06-29  37.99
2018-07-02  37.21
2018-07-03  36.59
2018-07-04  36.23
2018-07-05  35.22
2018-07-06  35.86
2018-07-09  37.06
2018-07-10  36.97
2018-07-11  36.15
2018-07-12  37.83
2018-07-13  38.51
2018-07-16  38.61
2018-07-17  37.92
2018-07-18  37.25
2018-07-19  35.18
2018-07-20  35.98

[134 rows x 1 columns]
plt.figure(figsize=[18,5])
a['sec_value'].plot(label='sec_value')
a['sec_sell_value'].plot(label='sec_sell_value')

b.plot()
plt.legend(loc='best')
<matplotlib.legend.Legend at 0x7f25628cab00>
df = get_price(get_industry_stocks('A01'), fields=('close',))['close']
print(df)
plt.figure(figsize=[18,5])
df['000998.XSHE'].plot()
pd.rolling_mean(df['000998.XSHE'],20).plot(label='20 day moving average')
pd.rolling_mean(df['000998.XSHE'],5).plot(label='5 day moving average')
plt.legend(loc='best')
            000998.XSHE  002041.XSHE  002772.XSHE  300087.XSHE  300189.XSHE  \
2015-01-05        19.34        12.71          NaN         3.96         2.71   
2015-01-06        19.73        12.92          NaN         4.08         2.78   
2015-01-07        19.57        12.85          NaN         4.04         2.76   
2015-01-08        20.11        13.03          NaN         4.13         2.77   
2015-01-09        19.75        12.87          NaN         4.02         2.72   
2015-01-12        19.22        12.98          NaN         3.91         2.66   
2015-01-13        19.59        13.15          NaN         4.04         2.73   
2015-01-14        19.21        12.96          NaN         3.98         2.68   
2015-01-15        19.37        13.04          NaN         4.05         2.70   
2015-01-16        19.77        13.26          NaN         4.17         2.76   
2015-01-19        19.21        13.31          NaN         4.12         2.66   
2015-01-20        19.61        13.55          NaN         4.26         2.73   
2015-01-21        20.03        13.79          NaN         4.38         2.80   
2015-01-22        20.62        13.92          NaN         4.41         2.88   
2015-01-23        20.21        13.66          NaN         4.33         2.83   
2015-01-26        20.31        13.76          NaN         4.35         2.86   
2015-01-27        20.76        13.94          NaN         4.61         2.91   
2015-01-28        20.30        13.68          NaN         4.79         2.88   
2015-01-29        20.20        13.39          NaN         4.71         2.88   
2015-01-30        20.96        13.66          NaN         4.77         2.95   
2015-02-02        20.53        13.32          NaN         4.74         2.88   
2015-02-03        20.15        13.11          NaN         4.82         2.86   
2015-02-04        19.70        13.11          NaN         4.76         2.85   
2015-02-05        19.54        12.88          NaN         4.62         2.85   
2015-02-06        18.73        12.57          NaN         4.45         2.79   
2015-02-09        18.42        12.76          NaN         4.48         2.79   
2015-02-10        18.71        12.81          NaN         4.46         2.84   
2015-02-11        18.61        12.93          NaN         4.58         2.85   
2015-02-12        18.89        12.77          NaN         4.72         2.87   
2015-02-13        19.10        12.90          NaN         4.77         2.90   
...                 ...          ...          ...          ...          ...   
2015-11-20        21.47        17.72        22.76         8.83        11.35   
2015-11-23        21.12        17.24        21.52         9.16        11.35   
2015-11-24        21.23        17.56        22.62         9.11        11.35   
2015-11-25        21.37        17.80        22.76         9.15        11.35   
2015-11-26        20.80        17.26        23.94         9.26        11.35   
2015-11-27        19.22        15.84        21.73         8.51        11.35   
2015-11-30        19.04        15.76        23.47         8.34        11.35   
2015-12-01        19.26        16.02        23.22         8.71        11.35   
2015-12-02        19.43        16.18        22.14         8.65        11.35   
2015-12-03        19.61        16.28        23.41         8.73        11.35   
2015-12-04        20.05        16.62        24.51         8.80        10.22   
2015-12-07        19.70        16.46        23.97         8.73         9.20   
2015-12-08        19.10        15.86        24.63         8.58         9.28   
2015-12-09        18.70        15.65        23.14         8.23         8.36   
2015-12-10        18.83        15.75        22.66         8.09         8.50   
2015-12-11        18.62        15.84        22.40         7.87         8.02   
2015-12-14        19.02        16.04        22.98         8.10         8.06   
2015-12-15        19.04        16.08        22.64         8.15         8.14   
2015-12-16        18.99        16.01        23.58         8.73         8.43   
2015-12-17        19.92        16.43        24.68         8.96         8.47   
2015-12-18        20.84        16.72        23.97         8.80         8.19   
2015-12-21        21.62        17.04        24.44         8.84         8.21   
2015-12-22        23.78        18.30        25.54         9.26         8.24   
2015-12-23        23.55        17.47        25.47         8.93         8.03   
2015-12-24        24.45        17.82        25.99         8.91         7.94   
2015-12-25        24.39        17.60        24.92         9.03         7.95   
2015-12-28        23.42        16.79        23.48         8.79         7.88   
2015-12-29        23.63        16.89        23.80         8.80         7.78   
2015-12-30        23.17        16.88        23.73         8.93         7.75   
2015-12-31        23.23        16.68        22.91         8.74         7.41   

            300511.XSHE  600108.XSHG  600313.XSHG  600354.XSHG  600359.XSHG  \
2015-01-05          NaN         9.51         4.50         8.81        10.92   
2015-01-06          NaN         9.75         4.62         8.75        11.08   
2015-01-07          NaN         9.98         4.70         8.85        11.07   
2015-01-08          NaN         9.77         4.74         8.89        11.12   
2015-01-09          NaN         9.41         4.59         8.60        10.80   
2015-01-12          NaN         9.45         4.58         8.47        10.73   
2015-01-13          NaN         9.50         4.69         8.78        10.90   
2015-01-14          NaN         9.45         4.62         8.64        10.88   
2015-01-15          NaN         9.56         4.66         8.65        11.11   
2015-01-16          NaN        10.00         4.80         8.80        11.25   
2015-01-19          NaN         9.66         4.72         8.42        10.79   
2015-01-20          NaN        10.02         4.95         8.59        11.10   
2015-01-21          NaN        10.23         5.24         8.84        11.29   
2015-01-22          NaN        10.41         5.44         9.18        11.58   
2015-01-23          NaN        10.09         5.39         8.98        11.36   
2015-01-26          NaN        10.13         5.49         9.08        11.49   
2015-01-27          NaN        10.44         5.89         9.37        11.73   
2015-01-28          NaN        10.17         5.66         9.24        11.54   
2015-01-29          NaN        10.06         5.67         9.36        11.24   
2015-01-30          NaN        10.25         5.73         9.40        11.34   
2015-02-02          NaN         9.64         5.32         8.93        11.31   
2015-02-03          NaN         9.44         5.37         8.74        11.13   
2015-02-04          NaN         9.22         5.17         8.60        10.87   
2015-02-05          NaN         8.96         5.11         8.44        10.70   
2015-02-06          NaN         8.57         4.92         8.14        10.35   
2015-02-09          NaN         8.63         5.28         8.18        10.33   
2015-02-10          NaN         8.69         5.43         8.25        10.27   
2015-02-11          NaN         8.80         5.74         8.28        10.61   
2015-02-12          NaN         8.75         5.70         8.20        10.57   
2015-02-13          NaN         8.88         5.66         8.34        10.71   
...                 ...          ...          ...          ...          ...   
2015-11-20          NaN         7.72         5.78         8.95        13.02   
2015-11-23          NaN         7.72         5.79         8.94        12.60   
2015-11-24          NaN         7.77         5.87         9.20        12.46   
2015-11-25          NaN         7.82         6.16         9.71        12.78   
2015-11-26          NaN         7.85         5.94         9.44        12.70   
2015-11-27          NaN         7.15         5.60         8.83        13.05   
2015-11-30          NaN         7.07         5.62         9.34        14.05   
2015-12-01          NaN         7.41         6.14         9.49        13.60   
2015-12-02          NaN         7.45         6.07         9.51        13.07   
2015-12-03          NaN         7.48         6.28         9.67        13.40   
2015-12-04          NaN         7.77         6.60        10.08        13.83   
2015-12-07          NaN         7.83         6.59        10.16        13.60   
2015-12-08          NaN         7.44         6.14         9.81        13.40   
2015-12-09          NaN         7.29         6.00         9.59        13.07   
2015-12-10          NaN         7.26         6.02        10.23        12.94   
2015-12-11          NaN         7.20         6.01         9.83        12.27   
2015-12-14          NaN         7.35         6.11         9.88        12.56   
2015-12-15          NaN         7.37         6.14         9.88        12.43   
2015-12-16          NaN         7.31         6.09         9.88        12.75   
2015-12-17          NaN         7.48         6.31         9.88        13.09   
2015-12-18          NaN         7.57         6.39         9.88        12.91   
2015-12-21          NaN         7.70         6.38         9.88        13.18   
2015-12-22          NaN         7.80         6.53         9.88        13.66   
2015-12-23          NaN         7.58         6.23         9.88        13.02   
2015-12-24          NaN         7.87         6.28         9.88        13.05   
2015-12-25          NaN         7.80         6.20         9.88        12.80   
2015-12-28          NaN         7.45         5.88         9.88        12.44   
2015-12-29          NaN         7.50         6.06         9.88        12.49   
2015-12-30          NaN         7.46         6.06         9.88        12.51   
2015-12-31          NaN         7.32         6.00         9.88        11.96   

            600371.XSHG  600506.XSHG  600540.XSHG  600598.XSHG  601118.XSHG  
2015-01-05        10.55        11.33         6.28         9.34         8.88  
2015-01-06        10.72        11.62         6.39         9.65         9.15  
2015-01-07        10.70        11.54         6.37         9.68         9.03  
2015-01-08        10.76        11.81         6.39         9.70         8.85  
2015-01-09        10.47        11.73         6.30         9.58         8.61  
2015-01-12        10.27        11.34         6.22         9.57         8.89  
2015-01-13        10.40        11.54         6.25         9.59         8.94  
2015-01-14        10.35        11.84         6.29         9.34         8.75  
2015-01-15        10.45        11.86         6.37         9.51         8.90  
2015-01-16        10.63        11.98         6.42         9.65         9.09  
2015-01-19        10.35        11.96         6.26         9.27         8.60  
2015-01-20        10.65        12.33         6.39         9.62         8.80  
2015-01-21        10.85        12.65         6.53         9.94         8.94  
2015-01-22        11.07        12.76         6.65        10.19         9.25  
2015-01-23        10.84        12.62         6.59        10.04         9.06  
2015-01-26        11.02        12.74         6.79        10.49         9.20  
2015-01-27        11.11        12.79         6.94        10.65         9.34  
2015-01-28        10.89        12.61         6.92        10.57         9.15  
2015-01-29        10.78        12.32         6.89        10.50         9.04  
2015-01-30        11.11        12.26         6.84        10.56         9.14  
2015-02-02        11.15        12.22         6.87        10.03         8.81  
2015-02-03        10.93        12.37         7.10         9.93         8.73  
2015-02-04        11.12        12.45         6.83         9.85         8.64  
2015-02-05        11.02        12.18         6.69         9.72         8.37  
2015-02-06        10.69        11.88         6.54         9.52         7.93  
2015-02-09        10.50        11.85         6.46         9.59         8.01  
2015-02-10        10.55        11.85         6.49         9.56         8.04  
2015-02-11        10.56        11.98         6.66         9.87         8.18  
2015-02-12        10.87        12.08         6.70        10.13         8.14  
2015-02-13        10.95        12.29         6.85        10.14         8.23  
...                 ...          ...          ...          ...          ...  
2015-11-20        17.25        21.69         8.39        14.07         7.75  
2015-11-23        17.61        21.15         8.16        14.08         7.86  
2015-11-24        17.90        21.18         8.36        14.19         7.98  
2015-11-25        18.93        21.28         8.67        14.48         7.98  
2015-11-26        18.96        21.55         8.84        14.31         8.15  
2015-11-27        19.33        19.49         8.64        13.19         7.43  
2015-11-30        21.26        19.05         8.35        12.77         7.29  
2015-12-01        20.77        19.81         8.69        13.35         7.68  
2015-12-02        20.04        19.26         8.39        13.39         7.74  
2015-12-03        20.63        20.69         8.51        13.45         7.82  
2015-12-04        21.81        20.70         8.77        14.35         8.15  
2015-12-07        21.74        20.94         8.82        14.73         8.15  
2015-12-08        20.32        20.95         8.45        13.87         7.70  
2015-12-09        20.32        20.53         8.23        13.36         7.68  
2015-12-10        19.58        21.12         8.12        13.61         7.58  
2015-12-11        20.09        21.12         8.18        13.25         7.46  
2015-12-14        20.68        21.29         8.23        13.43         7.63  
2015-12-15        20.69        21.76         8.31        13.55         7.67  
2015-12-16        21.94        22.07         8.32        13.45         7.54  
2015-12-17        22.14        22.82         8.68        14.11         7.70  
2015-12-18        21.59        23.35         9.03        14.21         7.80  
2015-12-21        21.35        22.92         8.92        14.36         7.97  
2015-12-22        23.49        23.10         8.89        14.79         8.14  
2015-12-23        22.48        22.87         8.71        14.17         7.90  
2015-12-24        22.97        23.60         8.75        14.53         8.11  
2015-12-25        23.06        24.05         9.13        14.46         8.03  
2015-12-28        22.28        22.30         9.04        13.71         7.68  
2015-12-29        22.31        22.71         9.05        13.80         7.74  
2015-12-30        22.42        22.62         8.79        13.70         7.70  
2015-12-31        22.27        23.43         8.46        13.53         7.56  

[244 rows x 15 columns]
<matplotlib.legend.Legend at 0x7f2560de19e8>
 

全部回复

0/140

量化课程

    移动端课程