修改python的默认最大递归层数

python李魔佛 发表了文章 • 0 个评论 • 5319 次浏览 • 2017-08-10 16:00 • 来自相关话题

python里面为了性能,默认的递归次数不能超过1000次。
 
运行下面的代码:
def recursion(n):
if(n <= 0):
print n
return
print n
recursion(n - 1)

if __name__ == "__main__":
recursion(1200)
返回下面的错误:
 
  File "C:/Git/base_function/resursion_usage.py", line 7, in recursion
    recursion(n - 1)
RuntimeError: maximum recursion depth exceeded
 
解决办法: 修改python默认的递归层数。
在程序开头的地方添加以下语句:
 
import sys
sys.setrecursionlimit(1500)
然后再次运行,就不会有上面的错误信息了。
  查看全部
python里面为了性能,默认的递归次数不能超过1000次。
 
运行下面的代码:
def recursion(n): 
if(n <= 0):
print n
return
print n
recursion(n - 1)

if __name__ == "__main__":
recursion(1200)

返回下面的错误:
 
  File "C:/Git/base_function/resursion_usage.py", line 7, in recursion
    recursion(n - 1)
RuntimeError: maximum recursion depth exceeded
 
解决办法: 修改python默认的递归层数。
在程序开头的地方添加以下语句:
 
import sys
sys.setrecursionlimit(1500)

然后再次运行,就不会有上面的错误信息了。
 

apt-get安装软件时 需要依赖更低版本的依赖库 通用解决办法

Linux李魔佛 发表了文章 • 0 个评论 • 6397 次浏览 • 2017-08-08 23:35 • 来自相关话题

比如ubuntu尝试安装sqlite3,
xda@xda-dt:~$ sudo apt-get install sqlite3 libsqlite3-0=3.7.9-2ubuntu1.1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libsqlite3-0 is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
sqlite3 : Depends: libsqlite3-0 (= 3.7.9-2ubuntu1) but 3.7.9-2ubuntu1.1 is to be installed
E: Unable to correct problems, you have held broken packages.
会出现上面的问题。
 
方法1,使用aptitude 安装。
 
xda@xda-dt:~$ sudo aptitude install sqlite3
The following NEW packages will be installed:
sqlite3{b}
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 26.9 kB of archives. After unpacking 174 kB will be used.
The following packages have unmet dependencies:
sqlite3 : Depends: libsqlite3-0 (= 3.7.9-2ubuntu1) but 3.7.9-2ubuntu1.1 is installed.
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) sqlite3 [Not Installed]



Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

Downgrade the following packages:
1) libsqlite3-0 [3.7.9-2ubuntu1.1 (now) -> 3.7.9-2ubuntu1 (precise)]



Accept this solution? [Y/n/q/?] Y
The following packages will be DOWNGRADED:
libsqlite3-0
The following NEW packages will be installed:
sqlite3
0 packages upgraded, 1 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 375 kB of archives. After unpacking 174 kB will be used.
Do you want to continue? [Y/n/?] Y
Get: 1 http://hk.archive.ubuntu.com/ubuntu/ precise/main libsqlite3-0 amd64 3.7.9-2ubuntu1 [348 kB]
Get: 2 http://hk.archive.ubuntu.com/ubuntu/ precise/main sqlite3 amd64 3.7.9-2ubuntu1 [26.9 kB]
Fetched 375 kB in 1s (306 kB/s)
dpkg: warning: downgrading libsqlite3-0 from 3.7.9-2ubuntu1.1 to 3.7.9-2ubuntu1.
(Reading database ... 162912 files and directories currently installed.)
Preparing to replace libsqlite3-0 3.7.9-2ubuntu1.1 (using .../libsqlite3-0_3.7.9-2ubuntu1_amd64.deb) ...
Unpacking replacement libsqlite3-0 ...
Selecting previously unselected package sqlite3.
Unpacking sqlite3 (from .../sqlite3_3.7.9-2ubuntu1_amd64.deb) ...
Processing triggers for man-db ...
Setting up libsqlite3-0 (3.7.9-2ubuntu1) ...
Setting up sqlite3 (3.7.9-2ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

xda@xda-dt:~$ sqlite3
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .exit

  查看全部
比如ubuntu尝试安装sqlite3,
xda@xda-dt:~$ sudo apt-get install sqlite3 libsqlite3-0=3.7.9-2ubuntu1.1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libsqlite3-0 is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
sqlite3 : Depends: libsqlite3-0 (= 3.7.9-2ubuntu1) but 3.7.9-2ubuntu1.1 is to be installed
E: Unable to correct problems, you have held broken packages.

会出现上面的问题。
 
方法1,使用aptitude 安装。
 
xda@xda-dt:~$ sudo aptitude install sqlite3
The following NEW packages will be installed:
sqlite3{b}
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 26.9 kB of archives. After unpacking 174 kB will be used.
The following packages have unmet dependencies:
sqlite3 : Depends: libsqlite3-0 (= 3.7.9-2ubuntu1) but 3.7.9-2ubuntu1.1 is installed.
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) sqlite3 [Not Installed]



Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

Downgrade the following packages:
1) libsqlite3-0 [3.7.9-2ubuntu1.1 (now) -> 3.7.9-2ubuntu1 (precise)]



Accept this solution? [Y/n/q/?] Y
The following packages will be DOWNGRADED:
libsqlite3-0
The following NEW packages will be installed:
sqlite3
0 packages upgraded, 1 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 375 kB of archives. After unpacking 174 kB will be used.
Do you want to continue? [Y/n/?] Y
Get: 1 http://hk.archive.ubuntu.com/ubuntu/ precise/main libsqlite3-0 amd64 3.7.9-2ubuntu1 [348 kB]
Get: 2 http://hk.archive.ubuntu.com/ubuntu/ precise/main sqlite3 amd64 3.7.9-2ubuntu1 [26.9 kB]
Fetched 375 kB in 1s (306 kB/s)
dpkg: warning: downgrading libsqlite3-0 from 3.7.9-2ubuntu1.1 to 3.7.9-2ubuntu1.
(Reading database ... 162912 files and directories currently installed.)
Preparing to replace libsqlite3-0 3.7.9-2ubuntu1.1 (using .../libsqlite3-0_3.7.9-2ubuntu1_amd64.deb) ...
Unpacking replacement libsqlite3-0 ...
Selecting previously unselected package sqlite3.
Unpacking sqlite3 (from .../sqlite3_3.7.9-2ubuntu1_amd64.deb) ...
Processing triggers for man-db ...
Setting up libsqlite3-0 (3.7.9-2ubuntu1) ...
Setting up sqlite3 (3.7.9-2ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

xda@xda-dt:~$ sqlite3
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .exit

 

编译cmake到更新的版本 【ubuntu】

Linux李魔佛 发表了文章 • 0 个评论 • 5955 次浏览 • 2017-08-05 23:31 • 来自相关话题

ubuntu12.04 的cmake版本是2.8.7, 在一些QT程序下,需要较高的cmake版本。
如果只是使用命令: 
sudo apt-get install cmake 或者sudo apt-get upgrade cmake 
获取到的版本还是2.8.7
 
正确的做法:

cd ~/Downloads/ 
wget http://www.cmake.org/files/v2. ... ar.gz 
tar xzvf cmake-2.8.10.tar.gz 
cd cmake-2.8.10 
./configure 
make -j4 
sudo make install
 
 
关闭命令行后重新开一个命令行,然后运行 cmake --version, 就可以看到你的cmake已经更新到你要的版本。 查看全部
ubuntu12.04 的cmake版本是2.8.7, 在一些QT程序下,需要较高的cmake版本。
如果只是使用命令: 
sudo apt-get install cmake 或者sudo apt-get upgrade cmake 
获取到的版本还是2.8.7
 
正确的做法:

cd ~/Downloads/ 
wget http://www.cmake.org/files/v2. ... ar.gz 
tar xzvf cmake-2.8.10.tar.gz 
cd cmake-2.8.10 
./configure 
make -j4 
sudo make install
 
 
关闭命令行后重新开一个命令行,然后运行 cmake --version, 就可以看到你的cmake已经更新到你要的版本。

在uefi主板上安装ubuntu,grub一直无法写入

Linux李魔佛 发表了文章 • 0 个评论 • 8504 次浏览 • 2017-08-05 19:57 • 来自相关话题

主板是技嘉P61的板子,是一块uefi的主板。
因为要安装ubuntu,所以使用ultraISO烧录的启动u盘,然后u盘启动。 
重启后,顺利进入安装界面,一路下去后。 最后卡在 grub安装出错的界面处。
 
因为用的是最新的ubuntu16.04,所以开始以为是系统兼容性问题,所以就降级到12.04。 用ultraISO重新烧录可启动U盘。
 
结果问题依然存在,所以排除系统问题,因为以前在其他机子上装过很多次12.04了。
 
于是到ubuntu官网上搜了一下,发现这个很多人遇到问题。
 
解决方案无非有2个,一个是禁用uefi模式,一个是创建efi分区。
 
然后自己自己折腾自己的bios设置。 技嘉的板子没有直接禁用uefi的选项,百度之。 原来一部分主板bios的uefi的设置选项,是CSM, 这个选项默认是开启的了,然后把个功能关闭, 然后重新安装,问题还是出现。
 
而此之后,启动设备的优先级里面,一直会出现一个ubuntu的选项。 
重置bios设置,这个选项会一直都在。 
 
然后无解,只能用第二种方法。 启动uefi,在安装ubuntu过程中,分区选项里面,选择手工分区,分了以下分区:
/
/boot
/home
swap
/efi  (一定要这个分区)
 
划分上面分区,系统不再出现grub安装失败的错误。 可是,系统重启后,系统就会挂掉,很不稳定。
 
后来重试了几次,没办法,重试第一次的方法。 这一次,我把主板的电池扣掉,放电几分钟。 然后进bios,重新禁用CSM, 重装。 使用默认的分区方法, 然后重要成功了。
 
  查看全部
主板是技嘉P61的板子,是一块uefi的主板。
因为要安装ubuntu,所以使用ultraISO烧录的启动u盘,然后u盘启动。 
重启后,顺利进入安装界面,一路下去后。 最后卡在 grub安装出错的界面处。
 
因为用的是最新的ubuntu16.04,所以开始以为是系统兼容性问题,所以就降级到12.04。 用ultraISO重新烧录可启动U盘。
 
结果问题依然存在,所以排除系统问题,因为以前在其他机子上装过很多次12.04了。
 
于是到ubuntu官网上搜了一下,发现这个很多人遇到问题。
 
解决方案无非有2个,一个是禁用uefi模式,一个是创建efi分区。
 
然后自己自己折腾自己的bios设置。 技嘉的板子没有直接禁用uefi的选项,百度之。 原来一部分主板bios的uefi的设置选项,是CSM, 这个选项默认是开启的了,然后把个功能关闭, 然后重新安装,问题还是出现。
 
而此之后,启动设备的优先级里面,一直会出现一个ubuntu的选项。 
重置bios设置,这个选项会一直都在。 
 
然后无解,只能用第二种方法。 启动uefi,在安装ubuntu过程中,分区选项里面,选择手工分区,分了以下分区:
/
/boot
/home
swap
/efi  (一定要这个分区)
 
划分上面分区,系统不再出现grub安装失败的错误。 可是,系统重启后,系统就会挂掉,很不稳定。
 
后来重试了几次,没办法,重试第一次的方法。 这一次,我把主板的电池扣掉,放电几分钟。 然后进bios,重新禁用CSM, 重装。 使用默认的分区方法, 然后重要成功了。
 
 

树莓派上安装redis-server 亲测

树莓派李魔佛 发表了文章 • 0 个评论 • 6184 次浏览 • 2017-07-17 23:47 • 来自相关话题

采用的方法为到官网下载源码,然后在树莓派上编译。
 
1. 下载源码压缩包:
官方网址: https://redis.io/download
下载下来的格式为tar.gz
通过命令行解压: tar xvfz xxxxxx.tar.gz
 
2. 解压后进入 redis-4.0.0的目录,然后执行命令: make
 
3. 等待源码编译(树莓派上有点久), 见到这一行:Hint: It's a good idea to run 'make test' ;)
说明你安装成功了
 
4. 编译成功后, 记得运行命令 sudo src/redis-server
来启动redis server。
 
成功运行后的文字界面:
12718:C 17 Jul 23:09:24.447 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

12718:C 17 Jul 23:09:24.448 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=12718, just started

12718:C 17 Jul 23:09:24.448 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf

12718:M 17 Jul 23:09:24.450 * Increased maximum number of open files to 10032 (it was originally set to 256).

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 4.0.0 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._                                   

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 12718

  `-._    `-._  `-./  _.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |           http://redis.io        

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                  

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                           

              `-.__.-'                                               




12718:M 17 Jul 23:09:24.451 # Server initialized

12718:M 17 Jul 23:09:24.451 * Ready to accept connections 查看全部
采用的方法为到官网下载源码,然后在树莓派上编译。
 
1. 下载源码压缩包:
官方网址: https://redis.io/download
下载下来的格式为tar.gz
通过命令行解压: tar xvfz xxxxxx.tar.gz
 
2. 解压后进入 redis-4.0.0的目录,然后执行命令: make
 
3. 等待源码编译(树莓派上有点久), 见到这一行:Hint: It's a good idea to run 'make test' ;)
说明你安装成功了
 
4. 编译成功后, 记得运行命令 sudo src/redis-server
来启动redis server。
 
成功运行后的文字界面:
12718:C 17 Jul 23:09:24.447 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

12718:C 17 Jul 23:09:24.448 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=12718, just started

12718:C 17 Jul 23:09:24.448 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf

12718:M 17 Jul 23:09:24.450 * Increased maximum number of open files to 10032 (it was originally set to 256).

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 4.0.0 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._                                   

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 12718

  `-._    `-._  `-./  _.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |           http://redis.io        

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                  

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                           

              `-.__.-'                                               




12718:M 17 Jul 23:09:24.451 # Server initialized

12718:M 17 Jul 23:09:24.451 * Ready to accept connections

python matplotlib 中的plot legend的用法

python李魔佛 发表了文章 • 0 个评论 • 22880 次浏览 • 2017-07-13 11:59 • 来自相关话题

官方有链接说明:https://matplotlib.org/users/legend_guide.html
不过对于大部分人来说,英文教程,加上上面的例子有点晦涩。
 
所以以个人的理解,简单地用代码介绍下。 import matplotlib.pyplot as plt
import numpy as np

x = np.arange(10)
print x
fig = plt.figure()
ax = plt.subplot(111)

for i in xrange(5):
#ax.plot(x, i * x, label='y=%dx' %i)
ax.plot(x, i * x, label='$y = %ix$' % i)

ax.legend()

plt.show()
 
运行上面的代码后,得到的结果是:
 





 
如果把那句legend() 的语句去掉,那么图形上的图例也就会消失了。
 
所以legend()的主要只用就是用于在图上标明一个图例,用于说明每条曲线的文字显示。 你也可以把图例控制在左边,右边,底下等等。
 
 
实际使用中,legend()有一个loc参数,用于控制图例的位置。 比如 plot.legend(loc=2) , 这个位置就是4象项中的第二象项,也就是左上角。 loc可以为1,2,3,4 这四个数字。
原文连接:
http://30daydo.com/article/215
转载请注明出处 查看全部
官方有链接说明:https://matplotlib.org/users/legend_guide.html
不过对于大部分人来说,英文教程,加上上面的例子有点晦涩。
 
所以以个人的理解,简单地用代码介绍下。
    import matplotlib.pyplot as plt
import numpy as np

x = np.arange(10)
print x
fig = plt.figure()
ax = plt.subplot(111)

for i in xrange(5):
#ax.plot(x, i * x, label='y=%dx' %i)
ax.plot(x, i * x, label='$y = %ix$' % i)

ax.legend()

plt.show()

 
运行上面的代码后,得到的结果是:
 

legend.PNG

 
如果把那句legend() 的语句去掉,那么图形上的图例也就会消失了。
 
所以legend()的主要只用就是用于在图上标明一个图例,用于说明每条曲线的文字显示。 你也可以把图例控制在左边,右边,底下等等。
 
 
实际使用中,legend()有一个loc参数,用于控制图例的位置。 比如 plot.legend(loc=2) , 这个位置就是4象项中的第二象项,也就是左上角。 loc可以为1,2,3,4 这四个数字。
原文连接:
http://30daydo.com/article/215
转载请注明出处

为什么使用dataframe自带的plot函数绘图 没有输出图像?

python李魔佛 发表了文章 • 0 个评论 • 8514 次浏览 • 2017-07-11 18:32 • 来自相关话题

比如:
df=pd.read_csv('LoanStats_2017Q1.csv',header=0)
print df.head(10)
print df.describe()

analysis_columns = ['issue_d','term','int_rate','emp_title','grade','home_ownership','verification_status','purpose','loan_amnt','total_pymnt','out_prncp','total_rec_int','total_rec_prncp','installment','annual_inc','dti','fico_range_low','fico_range_high','last_fico_range_low','last_fico_range_high','open_acc','loan_status','delinq_amnt','acc_now_delinq','tot_coll_amt']
deal_data = df.loc[:,analysis_columns]
print deal_data
deal_data.groupby('issue_d').agg({'loan_amnt':'sum'}).plot(kind="bar")
deal_data.groupby('issue_d').agg({'issue_d':'count'}).plot(kind = 'bar')
在pycharm中程序运行完了就直接退出,没有输出任何的图像。
 
然后看了下源码后,需要在后面手工添加一句 plt.show()
 
这样就能够正常显示图像了。 查看全部
比如:
    df=pd.read_csv('LoanStats_2017Q1.csv',header=0)
print df.head(10)
print df.describe()

analysis_columns = ['issue_d','term','int_rate','emp_title','grade','home_ownership','verification_status','purpose','loan_amnt','total_pymnt','out_prncp','total_rec_int','total_rec_prncp','installment','annual_inc','dti','fico_range_low','fico_range_high','last_fico_range_low','last_fico_range_high','open_acc','loan_status','delinq_amnt','acc_now_delinq','tot_coll_amt']
deal_data = df.loc[:,analysis_columns]
print deal_data
deal_data.groupby('issue_d').agg({'loan_amnt':'sum'}).plot(kind="bar")
deal_data.groupby('issue_d').agg({'issue_d':'count'}).plot(kind = 'bar')

在pycharm中程序运行完了就直接退出,没有输出任何的图像。
 
然后看了下源码后,需要在后面手工添加一句 plt.show()
 
这样就能够正常显示图像了。

numpy/dataframe 中cumsum 的用法

python李魔佛 发表了文章 • 0 个评论 • 6864 次浏览 • 2017-07-11 17:54 • 来自相关话题

用途:cumsum                 样本值的累计和
 
例子:
 
x=np.arange(101)
y=x.cumsum()
print y
print len(y)
x为一个0到100的array, 那么对这个array进行cumsum操作后
y现在的值为:
 
[ 0 1 3 6 10 15 21 28 36 45 55 66 78 91 105
120 136 153 171 190 210 231 253 276 300 325 351 378 406 435
465 496 528 561 595 630 666 703 741 780 820 861 903 946 990
1035 1081 1128 1176 1225 1275 1326 1378 1431 1485 1540 1596 1653 1711 1770
1830 1891 1953 2016 2080 2145 2211 2278 2346 2415 2485 2556 2628 2701 2775
2850 2926 3003 3081 3160 3240 3321 3403 3486 3570 3655 3741 3828 3916 4005
4095 4186 4278 4371 4465 4560 4656 4753 4851 4950 5050]
 
从结果很明显看到 cumsum是将样本逐渐累加,第一个是0,第二个是0+1,第三个是0+1+2,所以第三个是3,第4个是0+1+2+3=6,如此类推,最后一个就是这101个数的累加和,5050
 
  查看全部
用途:cumsum                 样本值的累计和
 
例子:
 
    x=np.arange(101)
y=x.cumsum()
print y
print len(y)

x为一个0到100的array, 那么对这个array进行cumsum操作后
y现在的值为:
 
[   0    1    3    6   10   15   21   28   36   45   55   66   78   91  105
120 136 153 171 190 210 231 253 276 300 325 351 378 406 435
465 496 528 561 595 630 666 703 741 780 820 861 903 946 990
1035 1081 1128 1176 1225 1275 1326 1378 1431 1485 1540 1596 1653 1711 1770
1830 1891 1953 2016 2080 2145 2211 2278 2346 2415 2485 2556 2628 2701 2775
2850 2926 3003 3081 3160 3240 3321 3403 3486 3570 3655 3741 3828 3916 4005
4095 4186 4278 4371 4465 4560 4656 4753 4851 4950 5050]

 
从结果很明显看到 cumsum是将样本逐渐累加,第一个是0,第二个是0+1,第三个是0+1+2,所以第三个是3,第4个是0+1+2+3=6,如此类推,最后一个就是这101个数的累加和,5050
 
 

有道云笔记注销了某台设备后无法在该设备登录

网络绫波丽 发表了文章 • 0 个评论 • 6530 次浏览 • 2017-07-06 12:29 • 来自相关话题

自己有多台安卓设备,都在上面登录过有道云笔记,因为有时会借给其他人,所以使用了有道云笔记网页版上的设备管理的功能,选择注销安卓设备A,并远程删除数据。
 
然后拿回设备后,准备重新登录有道云笔记,结果界面一直在删除数据,接着重新登录后,会一直弹出一个信息,远程注销了给设备,需要重新登录。
 
最后折腾了一番后,直接把有道云笔记卸载掉,然后重新安装,重新登录,结果问题就解决了。 查看全部
自己有多台安卓设备,都在上面登录过有道云笔记,因为有时会借给其他人,所以使用了有道云笔记网页版上的设备管理的功能,选择注销安卓设备A,并远程删除数据。
 
然后拿回设备后,准备重新登录有道云笔记,结果界面一直在删除数据,接着重新登录后,会一直弹出一个信息,远程注销了给设备,需要重新登录。
 
最后折腾了一番后,直接把有道云笔记卸载掉,然后重新安装,重新登录,结果问题就解决了。

python uiautomator 安卓自动化测试

python再坚持一下就好了 发表了文章 • 0 个评论 • 4636 次浏览 • 2017-06-18 16:46 • 来自相关话题

本教程使用的是win7 系统 - python 2.7
1. 安装uiautomator 同pip install uiautomator
 时确保你的手机连上电脑后,adb可以正常使用, 在命令行运行adb devices,能够有设备的id输出

2. 获取手机的基本信息:
导入uiautomator包: 

from uiautomator import device as d

这样子就可以使用d操作手机,获取手机信息。info= d.info
print info
print type(info)
for i in info:
print i,info[i]
输出的内容:
 {u'displayRotation': 0, u'displaySizeDpY': 640, u'displaySizeDpX': 360, u'screenOn': False, u'currentPackageName': u'com.smartisanos.keyguard', u'productName': u'icesky_msm8992', u'displayWidth': 1080, u'sdkInt': 22, u'displayHeight': 1920, u'naturalOrientation': True}
<type 'dict'>
displayRotation 0
displaySizeDpY 640
displaySizeDpX 360
screenOn False
currentPackageName com.smartisanos.keyguard
productName icesky_msm8992
displayWidth 1080
sdkInt 22
displayHeight 1920
naturalOrientation True

手机的分辨率
displayWidth 1080
displayHeight 1920

当前打开的包名: currentPackageName com.smartisanos.keyguard
 
3.d.press.home()
result=d(text=u'设置').wait.exists(timeout=10000)
#单位是毫秒, 如果timeout还没有找到,就返回false
print "next"
if result:
print "You press setting"
else:
print "You don't touch any thing"

打开home主界面,然后查看时候有设置这个选项或者图标文字。
d(text=u'设置').wait.exists(timeout=10000)

如果在10s内找到这个字符,那么这一行就返回True, 否则返回False
 
  查看全部
本教程使用的是win7 系统 - python 2.7
1. 安装uiautomator 同
pip install uiautomator

 时确保你的手机连上电脑后,adb可以正常使用, 在命令行运行adb devices,能够有设备的id输出

2. 获取手机的基本信息:
导入uiautomator包: 

from uiautomator import device as d

这样子就可以使用d操作手机,获取手机信息。
info= d.info
print info
print type(info)
for i in info:
print i,info[i]

输出的内容:
 
{u'displayRotation': 0, u'displaySizeDpY': 640, u'displaySizeDpX': 360, u'screenOn': False, u'currentPackageName': u'com.smartisanos.keyguard', u'productName': u'icesky_msm8992', u'displayWidth': 1080, u'sdkInt': 22, u'displayHeight': 1920, u'naturalOrientation': True}
<type 'dict'>
displayRotation 0
displaySizeDpY 640
displaySizeDpX 360
screenOn False
currentPackageName com.smartisanos.keyguard
productName icesky_msm8992
displayWidth 1080
sdkInt 22
displayHeight 1920
naturalOrientation True


手机的分辨率
displayWidth 1080
displayHeight 1920

当前打开的包名: currentPackageName com.smartisanos.keyguard
 
3.
d.press.home()
result=d(text=u'设置').wait.exists(timeout=10000)
#单位是毫秒, 如果timeout还没有找到,就返回false
print "next"
if result:
print "You press setting"
else:
print "You don't touch any thing"


打开home主界面,然后查看时候有设置这个选项或者图标文字。
d(text=u'设置').wait.exists(timeout=10000)

如果在10s内找到这个字符,那么这一行就返回True, 否则返回False
 
 

为什么 2017 年 6 月 京东很多显卡断货

量化交易李魔佛 发表了文章 • 0 个评论 • 3419 次浏览 • 2017-06-15 22:40 • 来自相关话题

原来如此!!!! 
 
 以太坊一个月内4倍,现在显卡挖以太坊,3个月以内回本。还有做什么生意比这好的吗?各路资本都涌入了,显卡自然涨价。

显卡芯片生产速度完全跟不上显卡需求增长速度,A卡更是难买。

挖以太坊优先考虑RX470、RX480、RX570、RX580,A卡买不到才用N卡。

N卡挖以太坊用GTX1060和GTX1070,GTX1050、GTX1050Ti、GTX1080、GTX1080Ti挖以太坊效率太低,不适合用。

不仅显卡涨价了,连四川水电都涨价了。以前四川有很多矿场用水电站直供电,用电价格0.2元多一点,现在四川水电价格都涨起来了。新建矿场都去新疆和云南了。

也不能说显卡完全断货,只要愿意出价高,还是能买到。


链接:https://www.zhihu.com/question ... 47044
来源:知乎

  查看全部
原来如此!!!! 
 
 以太坊一个月内4倍,现在显卡挖以太坊,3个月以内回本。还有做什么生意比这好的吗?各路资本都涌入了,显卡自然涨价。

显卡芯片生产速度完全跟不上显卡需求增长速度,A卡更是难买。

挖以太坊优先考虑RX470、RX480、RX570、RX580,A卡买不到才用N卡。

N卡挖以太坊用GTX1060和GTX1070,GTX1050、GTX1050Ti、GTX1080、GTX1080Ti挖以太坊效率太低,不适合用。

不仅显卡涨价了,连四川水电都涨价了。以前四川有很多矿场用水电站直供电,用电价格0.2元多一点,现在四川水电价格都涨起来了。新建矿场都去新疆和云南了。

也不能说显卡完全断货,只要愿意出价高,还是能买到。


链接:https://www.zhihu.com/question ... 47044
来源:知乎

 

dataframe读取excel文件第一行是列名如何跳过

python李魔佛 发表了文章 • 0 个评论 • 13351 次浏览 • 2017-06-13 01:15 • 来自相关话题

比如数据如下:
 股票代码 股票简称 涨跌幅(%) 现价(元) 收盘价:前复权(元) 区间涨跌幅:前复权(%) 交易状态
2016.07.13 2016.07.13 2016.07.13
300501.SZ 海顺新材 10.00 144.65 131.50 3.06 交易
300384.SZ 三联虹普 -0.67 57.63 58.02 5.97 交易
300506.SZ 名家汇 5.98 60.98 57.54 5.52 交易
002572.SZ 索菲亚 1.03 56.80 56.22 -0.65 交易
600419.SH 天润乳业 4.66 57.10 54.56 0.06 交易
300494.SZ 盛天网络 4.86 54.19 51.68 2.64 交易
300369.SZ 绿盟科技 2.36 45.50 44.45 -0.96 交易
002113.SZ 天润数娱 -1.89 43.55 44.39 7.14 交易
002190.SZ 成飞集成 10.01 47.17 42.88 10.01 交易
600391.SH 成发科技 3.39 43.56 42.13 1.54 交易
002699.SZ 美盛文化 3.25 40.99 39.70 9.97 交易
603027.SH 千禾味业 3.70 40.39 38.95 -1.77 交易
600893.SH 中航动力 2.03 39.29 38.51 0.44 交易
603005.SH 晶方科技 4.34 40.16 38.49 2.89 交易
300339.SZ 润和软件 2.50 36.98 36.08 1.32 交易
300246.SZ 宝莱特 3.92 37.42 36.01 -0.91 交易
002368.SZ 太极股份 4.23 37.50 35.98 1.75 交易
000555.SZ 神州信息 0.35 34.66 34.54 -0.75 交易
002745.SZ 木林森 9.15 37.10 33.99 -0.23 交易
002589.SZ 瑞康医药 -1.49 33.00 33.50 4.82 交易
002007.SZ 华兰生物 3.31 33.36 32.29 -0.89 交易
002456.SZ 欧菲光 0.32 31.60 31.50 7.88 交易
002759.SZ 天际股份 9.99 34.01 30.92 0.00 重大事项,停牌自2016-07-12起连续停牌


那么怎样不把第一行的数据读入呢? 或者说把第一行的数据给忽略掉呢?
 sheet1 = pd.read_excel('test.xls', header=0, skiprows=[0] ) 
 
原文链接:http://30daydo.com/article/209
欢迎转载,转载请注明出处。 查看全部
比如数据如下:
 
股票代码	股票简称	涨跌幅(%)	现价(元)	收盘价:前复权(元)	区间涨跌幅:前复权(%)	交易状态
2016.07.13 2016.07.13 2016.07.13
300501.SZ 海顺新材 10.00 144.65 131.50 3.06 交易
300384.SZ 三联虹普 -0.67 57.63 58.02 5.97 交易
300506.SZ 名家汇 5.98 60.98 57.54 5.52 交易
002572.SZ 索菲亚 1.03 56.80 56.22 -0.65 交易
600419.SH 天润乳业 4.66 57.10 54.56 0.06 交易
300494.SZ 盛天网络 4.86 54.19 51.68 2.64 交易
300369.SZ 绿盟科技 2.36 45.50 44.45 -0.96 交易
002113.SZ 天润数娱 -1.89 43.55 44.39 7.14 交易
002190.SZ 成飞集成 10.01 47.17 42.88 10.01 交易
600391.SH 成发科技 3.39 43.56 42.13 1.54 交易
002699.SZ 美盛文化 3.25 40.99 39.70 9.97 交易
603027.SH 千禾味业 3.70 40.39 38.95 -1.77 交易
600893.SH 中航动力 2.03 39.29 38.51 0.44 交易
603005.SH 晶方科技 4.34 40.16 38.49 2.89 交易
300339.SZ 润和软件 2.50 36.98 36.08 1.32 交易
300246.SZ 宝莱特 3.92 37.42 36.01 -0.91 交易
002368.SZ 太极股份 4.23 37.50 35.98 1.75 交易
000555.SZ 神州信息 0.35 34.66 34.54 -0.75 交易
002745.SZ 木林森 9.15 37.10 33.99 -0.23 交易
002589.SZ 瑞康医药 -1.49 33.00 33.50 4.82 交易
002007.SZ 华兰生物 3.31 33.36 32.29 -0.89 交易
002456.SZ 欧菲光 0.32 31.60 31.50 7.88 交易
002759.SZ 天际股份 9.99 34.01 30.92 0.00 重大事项,停牌自2016-07-12起连续停牌


那么怎样不把第一行的数据读入呢? 或者说把第一行的数据给忽略掉呢?
 
sheet1 = pd.read_excel('test.xls', header=0, skiprows=[0] )
 
 
原文链接:http://30daydo.com/article/209
欢迎转载,转载请注明出处。

pycharm当前使用的换行是windows模式还是mac OSX模式 ?

Linux李魔佛 发表了文章 • 0 个评论 • 8966 次浏览 • 2017-05-31 11:40 • 来自相关话题

pycharm是一款很好用的python IDE软件。 在编写代码的时候怎样确定自己用的是windows的换行模式还是Mac OSX 或者Linux下的换行模式呢?
 
在pycharm的右下角,有一个状态栏,上面显示





 
如果显示的是: CRLF,说明当前文档用的是windows的换行,占用的是2个字符 \n\r
 
而对于Mac OSX 系统,显示的则是CR, 换行则是 \r
 
而Linux下的换行,显示的是LR, 字符为\n 查看全部
pycharm是一款很好用的python IDE软件。 在编写代码的时候怎样确定自己用的是windows的换行模式还是Mac OSX 或者Linux下的换行模式呢?
 
在pycharm的右下角,有一个状态栏,上面显示

换行.PNG

 
如果显示的是: CRLF,说明当前文档用的是windows的换行,占用的是2个字符 \n\r
 
而对于Mac OSX 系统,显示的则是CR, 换行则是 \r
 
而Linux下的换行,显示的是LR, 字符为\n

30天获取证券从业资格证和基金从业资格证

30天新尝试绫波丽 发表了文章 • 0 个评论 • 4506 次浏览 • 2017-05-31 10:58 • 来自相关话题

 
 证券从业资格考试









基金从业资格考试












这两门都是从业考试,所以难度不会太大。只要你能够大概把书翻一遍,或者看网上的视频教程,然后刷下题库,正常来说,通过是没问题的。 












(网上说基金从业的基础知识通过率才30%都不到。这也让我觉得不可思议,怀疑不少人是去裸考的吧)




这里只是想跟大家分享一下30天内让自己完成一个时间的一个心理过程和行为过程。




首先要强迫自己去做,那么就让自己投入一些沉没成本。




报考证券从业资格和基金从业资格这两门考试,每一门需要120块的考试费用,考试费用交了后,无论你去不去考试钱都没得退回来。 因为前期投入了金钱,后期心里就不甘心让自己钱打水漂了,学习的动力会更加充足。 




对于能够见得着的金钱成本,很多人都很精明,能够看得到,且能够量化到具体数额。 




可是,平时我们投入的时间成本,有多少人能够精确的量化出来?  计划了3个月内学会一门语言,制定了相应的学习计划,然后执行了3周后, 因为各种原因,比如公司年会准备,周末team building等,让你的学习计划中断了。 而后,因为年会或者team building之后身体太累,你就把学习新语言的计划往后挪。就是因为这一挪,破坏了你的计划的连贯性,而且,有了第一次,肯定就会有第二次,第三次。 最后很可能的结果就是没能在3个月完成你学会一门新语言的计划。

在这里,你能够算出你因为前期投入的时间,而沉没的成本吗? 




所以,换一本漂亮昂贵的日记本,买一套好的运动服,你坚持写日记,跑步的动力就会比随意拿个本子或穿件山寨耐克要充足好多。 




当然,上面是对那些本来计划容易被随意打断的人而言。 对于那些自律成魔的人, 或者兴趣爱好所致,一般不需要像上面说的那样强制自己投入大量沉没成本。  查看全部

考试.jpg

 
 证券从业资格考试

证券从业资格考试-1.png





基金从业资格考试


基金考试-1.png







这两门都是从业考试,所以难度不会太大。只要你能够大概把书翻一遍,或者看网上的视频教程,然后刷下题库,正常来说,通过是没问题的。 




通过率.PNG





(网上说基金从业的基础知识通过率才30%都不到。这也让我觉得不可思议,怀疑不少人是去裸考的吧)




这里只是想跟大家分享一下30天内让自己完成一个时间的一个心理过程和行为过程。




首先要强迫自己去做,那么就让自己投入一些沉没成本。




报考证券从业资格和基金从业资格这两门考试,每一门需要120块的考试费用,考试费用交了后,无论你去不去考试钱都没得退回来。 因为前期投入了金钱,后期心里就不甘心让自己钱打水漂了,学习的动力会更加充足。 




对于能够见得着的金钱成本,很多人都很精明,能够看得到,且能够量化到具体数额。 




可是,平时我们投入的时间成本,有多少人能够精确的量化出来?  计划了3个月内学会一门语言,制定了相应的学习计划,然后执行了3周后, 因为各种原因,比如公司年会准备,周末team building等,让你的学习计划中断了。 而后,因为年会或者team building之后身体太累,你就把学习新语言的计划往后挪。就是因为这一挪,破坏了你的计划的连贯性,而且,有了第一次,肯定就会有第二次,第三次。 最后很可能的结果就是没能在3个月完成你学会一门新语言的计划。

在这里,你能够算出你因为前期投入的时间,而沉没的成本吗? 




所以,换一本漂亮昂贵的日记本,买一套好的运动服,你坚持写日记,跑步的动力就会比随意拿个本子或穿件山寨耐克要充足好多。 




当然,上面是对那些本来计划容易被随意打断的人而言。 对于那些自律成魔的人, 或者兴趣爱好所致,一般不需要像上面说的那样强制自己投入大量沉没成本。 

比特币居然在25号那天突破过30000!

量化交易李魔佛 发表了文章 • 0 个评论 • 3151 次浏览 • 2017-05-31 07:39 • 来自相关话题

今天拉了下K线,才发现比特币居然还突破到30000大关。 当时只记得比特币突破了20000大关。没想到中间价格还到过30000,不知道被吊在30000的那个山顶上的朋友是怎么一个凉飕飕的感受。

比特币.PNG

今天拉了下K线,才发现比特币居然还突破到30000大关。 当时只记得比特币突破了20000大关。没想到中间价格还到过30000,不知道被吊在30000的那个山顶上的朋友是怎么一个凉飕飕的感受。

TA-Lib中MOM的计算公式

量化交易-Ptrade-QMT李魔佛 发表了文章 • 0 个评论 • 7009 次浏览 • 2017-05-29 01:38 • 来自相关话题

MOM是价格动能。
 TA-Lib中MOM的参数有
ouput=talib.MOM(closed,timeperiod=5)
 
closed是你传入的价格list,可以是每天的收盘价,开盘价,或者你想要计算的所有价格。
timeperiod是你要计算的时间周期。
 
假如timeperiod=5,那么,这个计算的输出值就是 p5-p0, 如果今天是1月6日,股价为14块,而1月1日的股价为12块,那么这里通过MOM运算,得出来的就是14-12=2 这个值了。 然后如此类推,如果今天是1月7日,股价为15块,而1月2日股价为11块,那么MOM得出的是4,这样子获取到所有的值,绘制成曲线,就是MOM的曲线了。 查看全部
MOM是价格动能。
 TA-Lib中MOM的参数有
ouput=talib.MOM(closed,timeperiod=5)
 
closed是你传入的价格list,可以是每天的收盘价,开盘价,或者你想要计算的所有价格。
timeperiod是你要计算的时间周期。
 
假如timeperiod=5,那么,这个计算的输出值就是 p5-p0, 如果今天是1月6日,股价为14块,而1月1日的股价为12块,那么这里通过MOM运算,得出来的就是14-12=2 这个值了。 然后如此类推,如果今天是1月7日,股价为15块,而1月2日股价为11块,那么MOM得出的是4,这样子获取到所有的值,绘制成曲线,就是MOM的曲线了。

Price Momentum

股票李魔佛 发表了文章 • 0 个评论 • 3352 次浏览 • 2017-05-29 01:20 • 来自相关话题

Understanding Price Momentum

Today's stock market is more than just a place to buy and hold securities. Many investors prefer to move quickly in and out of the market. That's just one reason technical strategies, such as price momentum, have grown in popularity.

In this article, we're going to provide some insights into the investment strategy known as price momentum.  We'll explain why some theorists believe this model offers investors a short-term profit opportunity.  We'll also talk about the pros and cons of this approach, including the long-term opportunity that price momentum provides the market.

What is Price Momentum?

Additional Resources

Calculating Stock Prices
Capital Asset Pricing Model
Arbitrage Pricing Theory
Stock Beta and Volatility
Random Walk Theory Explained

The theory behind price momentum is relatively simple.  Generally, we can talk about it in two ways; the first has to do with buying stocks:

Stocks that had relatively high returns over the past three to twelve months should return to investors above average returns over the next three to twelve months.

The theory also provides guidance on the right time to sell stocks:

Stocks that had relatively poor returns over the past three to twelve months should return to investors below average returns over the next three to twelve months.

This investment strategy was first theorized by Narasimhan Jegadeesh and Sheridan Titman in their publication "Returns to Buying Winners and Selling Losers: Implications for Stock Market Efficiency," which was published in The Journal of Finance back in March 1993.

Price Momentum Model

The model is based on the assumption the stock market is not completely efficient. This is something that most economists believe to be true.  The two most practical explanations for the performance of this model include:

Investors are taking advantage of human behavior, including a "herding" mentality and / or an overreaction to news.
Investors employing a price momentum strategy are taking on additional risk; therefore, higher returns are required to compensate these investors for the risk they're assuming.

Within their study, Jegadeesh and Titman examined a large number of trading strategies.  One of the conclusions from that study is stated below:

Buying past winners, and selling past losers, allowed investors to achieve above average returns over the period 1956 to 1989.  In particular, stocks that were classified based on their prior 6-month performance, and held for 6 months realized an excess return of over 12% per year on average.

The Momentum Formula

Technical stock analysts understand the value this particular technique provides.  They're constantly crunching numbers to see if patterns emerge.  The actual formula for calculating price momentum is really quite simple, and takes the form:

M = CP - CPn

Where:

M = Momentum
CP = Closing price in the current period
CPn = Closing price N periods ago

For example, if a stock was trading at $35 per share six months ago, and is currently trading at $40 per share, then its six-month price momentum would be 40 minus 35 or 5.

Unfortunately, this formula is not normalized, and this makes it difficult to compare stocks selling at different price points.  A stock experiencing a 1% price movement from $300 to $303 would have a momentum value of three.  A second stock experiencing a 100% increase in price from $3 to $6 also has a momentum value of three.

Rate of Change Formula

One of the ways technical stock analysts can work around this problem is by calculating a rate of change value, which normalizes momentum:

RoC = (CP - CPn) / CPn

Where:

RoC = Rate of Change
CP = Closing price in the current period
CPn = Closing price N periods ago

Using the example above, the stock selling at $303 per share that was trading at $300 six months ago would have a Rate of Change of 3 / 300 or 1%, while the second stock would have a Rate of Change of 3 / 3 or 100%.

Momentum and Moving Averages

A second way that stock analysts use price momentum is in conjunction with moving averages.  Here the technical analyst makes a series of price momentum calculations and plots these along with a moving average of the momentum.

For example, the plot might contain 28-day moving averages along with daily price momentum figures.  Buy signals can be triggered when price momentum travels above its moving averages, and stays there for several trading days.  Sell signals can be triggered when momentum travels below its moving average.

Contrarian Investing

As mentioned in the beginning of this article, this model tells investors they should buy past winners and sell past losers.  Because this theory is based on past price performance, or historical market information, price momentum is a trading model that technical analysts would follow.  Fundamental analysts believe that a stock is bought and sold based on its intrinsic value, including the company's potential to produce profits for its shareholders in the future.

Fortunately, fundamental analysts can also use price momentum to their advantage by adopting what is termed a contrarian investing strategy.  Contrarian investors take the opposite approach that a theory advocates.  For example, a fundamental analyst might conclude:

A stock that has been rising may now be overvalued, while a stock that has been falling may be undervalued.

One could argue the further a stock moves from its true market value, the greater the opportunity for profits.  By tracking price momentum, and using this as a screening tool, fundamental analysts can then assess if a stock is truly undervalued or overvalued by studying the company's long-term financial health and earnings power.

About the Author - Understanding Price Momentum (Last Reviewed on November 22, 2016)
 
http://30daydo.com/article/203
  查看全部
Understanding Price Momentum

Today's stock market is more than just a place to buy and hold securities. Many investors prefer to move quickly in and out of the market. That's just one reason technical strategies, such as price momentum, have grown in popularity.

In this article, we're going to provide some insights into the investment strategy known as price momentum.  We'll explain why some theorists believe this model offers investors a short-term profit opportunity.  We'll also talk about the pros and cons of this approach, including the long-term opportunity that price momentum provides the market.

What is Price Momentum?

Additional Resources

Calculating Stock Prices
Capital Asset Pricing Model
Arbitrage Pricing Theory
Stock Beta and Volatility
Random Walk Theory Explained

The theory behind price momentum is relatively simple.  Generally, we can talk about it in two ways; the first has to do with buying stocks:

Stocks that had relatively high returns over the past three to twelve months should return to investors above average returns over the next three to twelve months.

The theory also provides guidance on the right time to sell stocks:

Stocks that had relatively poor returns over the past three to twelve months should return to investors below average returns over the next three to twelve months.

This investment strategy was first theorized by Narasimhan Jegadeesh and Sheridan Titman in their publication "Returns to Buying Winners and Selling Losers: Implications for Stock Market Efficiency," which was published in The Journal of Finance back in March 1993.

Price Momentum Model

The model is based on the assumption the stock market is not completely efficient. This is something that most economists believe to be true.  The two most practical explanations for the performance of this model include:

Investors are taking advantage of human behavior, including a "herding" mentality and / or an overreaction to news.
Investors employing a price momentum strategy are taking on additional risk; therefore, higher returns are required to compensate these investors for the risk they're assuming.

Within their study, Jegadeesh and Titman examined a large number of trading strategies.  One of the conclusions from that study is stated below:

Buying past winners, and selling past losers, allowed investors to achieve above average returns over the period 1956 to 1989.  In particular, stocks that were classified based on their prior 6-month performance, and held for 6 months realized an excess return of over 12% per year on average.

The Momentum Formula

Technical stock analysts understand the value this particular technique provides.  They're constantly crunching numbers to see if patterns emerge.  The actual formula for calculating price momentum is really quite simple, and takes the form:

M = CP - CPn

Where:

M = Momentum
CP = Closing price in the current period
CPn = Closing price N periods ago

For example, if a stock was trading at $35 per share six months ago, and is currently trading at $40 per share, then its six-month price momentum would be 40 minus 35 or 5.

Unfortunately, this formula is not normalized, and this makes it difficult to compare stocks selling at different price points.  A stock experiencing a 1% price movement from $300 to $303 would have a momentum value of three.  A second stock experiencing a 100% increase in price from $3 to $6 also has a momentum value of three.

Rate of Change Formula

One of the ways technical stock analysts can work around this problem is by calculating a rate of change value, which normalizes momentum:

RoC = (CP - CPn) / CPn

Where:

RoC = Rate of Change
CP = Closing price in the current period
CPn = Closing price N periods ago

Using the example above, the stock selling at $303 per share that was trading at $300 six months ago would have a Rate of Change of 3 / 300 or 1%, while the second stock would have a Rate of Change of 3 / 3 or 100%.

Momentum and Moving Averages

A second way that stock analysts use price momentum is in conjunction with moving averages.  Here the technical analyst makes a series of price momentum calculations and plots these along with a moving average of the momentum.

For example, the plot might contain 28-day moving averages along with daily price momentum figures.  Buy signals can be triggered when price momentum travels above its moving averages, and stays there for several trading days.  Sell signals can be triggered when momentum travels below its moving average.

Contrarian Investing

As mentioned in the beginning of this article, this model tells investors they should buy past winners and sell past losers.  Because this theory is based on past price performance, or historical market information, price momentum is a trading model that technical analysts would follow.  Fundamental analysts believe that a stock is bought and sold based on its intrinsic value, including the company's potential to produce profits for its shareholders in the future.

Fortunately, fundamental analysts can also use price momentum to their advantage by adopting what is termed a contrarian investing strategy.  Contrarian investors take the opposite approach that a theory advocates.  For example, a fundamental analyst might conclude:

A stock that has been rising may now be overvalued, while a stock that has been falling may be undervalued.

One could argue the further a stock moves from its true market value, the greater the opportunity for profits.  By tracking price momentum, and using this as a screening tool, fundamental analysts can then assess if a stock is truly undervalued or overvalued by studying the company's long-term financial health and earnings power.

About the Author - Understanding Price Momentum (Last Reviewed on November 22, 2016)
 
http://30daydo.com/article/203
 

能否改变贫穷?

每日总结李魔佛 发表了文章 • 0 个评论 • 2997 次浏览 • 2017-05-29 01:17 • 来自相关话题

这是我的博士同事,Naphet,10月20日下午3点,他正式打出了他的博士论文,完成了四年的博士生涯。

Naphet 来自津巴布韦,世界上最混乱的国家之一(也许没有之一)。他没有谈他的童年,但我知道那一定不是我可以相比的。他从家乡出来后,成功地申请到了我们学校的 PhD,并且获得了英国国籍。这中间的努力,真的是我难以想象的。我至今深深记得,他去参加他的博士论文答辩的那天,抱着一本300多页厚厚的博士论文,像抱着一个婴儿那么珍惜。他的论文做定量的,主要工具是spss 程序,我曾经问过他从哪里学的 spss,他和我说,他在网上自学的。在读博的三年时间里,他就通过看 Youtube 的在线视频来从0开始学习 spss,如今,他的论文里充斥着各种精致的公式,而我的论文相比之下是如此的苍白无力。但他的论文还是没有通过答辩,因为我们学校新来的一个女老师质疑了他的方法,他很愤怒,因为他不理解为什么自己学校的老师竟然不支持他,但他没有气馁,而是继续每天早出晚归地来研究室修改论文。


他是有两个孩子的单亲爸爸。女儿已经上了高中,儿子才几个月大。他白天要在家里带孩子,晚上到火车站开出租车补贴学费和家用,挣来的钱还要寄回津巴布韦老家。因此他白天在家里通过远程桌面连接学校电脑学习,只有在晚上五点以后,他的女儿放学回来能照顾自己的弟弟,以及出租下班的时候才能来研究室学习。他周末的时候从来不回家,睡在出租车里,这样能多挣钱。而他一旦坐下,就会一动不动地全神贯注地开始工作。我有时候都很奇怪他从哪里来的精力,能够一边打工一边学习,并且能够如此专注。每每午夜十二点半,我离开研究室,而他仍然坐在电脑屏幕面前,专心调整着他公式的参数。

Naphet 的女儿非常优秀,她6岁的时候来到他身边。他充满自豪地同我分享了她女儿在 BBC 演讲比赛中获胜的演讲,并且告诉我她是英国青少年议会的议员,教区领袖,学校青少年协会的领导。“她的生活非常自律,比我更加自律,我从来没见过一个哪个17岁的孩子能够像她那么生活。”他对我说。在他女儿十五岁参加的那场演讲中,她把英语称之为杀手,并且分析了外国移民在英文环境中面对的语言困境。“我没有写一个字给她,都是她自己写的。我把这个视频用到了我的课程'社会学的想象力'中,这是一个可以作为博士论文的课题。”Naphet 非常自豪地对我说。我真的很震惊一个十五岁的女孩能够对环境有如此的敏感性。我提醒 Naphet 不要让她过于骄傲,他和我说:“我从来不夸奖她,我只是告诉她需要面对的挑战。她能够完成每一项挑战。”

他曾和我分享了他求职失败的经历,原因竟然是他过于优秀。三年博士期间,他获得了多个教师资格证书,比他的面试官还要优秀。结果可想而知,他精心准备的演讲反而害了他,实在是十分荒谬。但他没有气馁,他和我说:“我目前需要做的就是尽快博士毕业,好让自己有更多的自由去寻找更好的机会。”他的教学经验之丰富,远远超过了他的同辈,连他的面试官也只能嫉妒地说:“你实在是走的太快了。”我问他关于论文引用的问题,他却反过来向我求教我使用的引用软件,等我介绍完之后他掏出本子认真的记录着:“这个软件很好,我以后也要让我女儿试试。我现在就在为她准备大学需要面临的一切。”那一刻,我真的感觉到为什么人们说机会都是留给有准备的人。什么样的人是优秀的人?自强,自律,虚心,不骄不躁,永远充满信心,这样的父亲有这样的女儿,一点也不奇怪。

人在海外,社交圈很小,因此他给我的触动反倒更大。我第一次认真思考了何为一个有担当的男人。他没有钱,所以出去工作,他没有知识,所以上网自学。他面对着所有的不公正,却充满了自信的微笑。他对我说:“我要尽快完成我的博士,向我女儿证明我可以做到这一切。”是的,他一定可以的,我一点都不怀疑。反观我自己,在每一点上都放佛要被压榨出一个大大的“小”字来,我连对比的勇气都没有。他那岩石一般英朗的笑容背后有多少辛酸,多少委屈,我无法猜测,但我看到的是,他如同钟表一样准时的每天来到研究室,坐下,学习,创造着属于他和他女儿的未来。

他在论文的致谢部分写着:“献给我的母亲和我的四个兄弟,献给我过世的爸爸和五个叔叔。”

“我已经很多年没见过我母亲了。”他看着我读完了致谢之后说。

“你是怎么走过这一切的呢?”我问。

“压力。生活挤压着你,你只有前进。我所获得的一切都是靠我自己的双手得来的。”

他,是他们五兄弟中唯一走出来的。

很多时候,Naphet 这样的人是学不来的,但我想,他本身也许就是一个答案,在我们陷入迷茫和懦弱时,在我们给自己的人生拼命找借口时,带来一个声音:

贫穷不能改变吗?

能。

 
 
转至知乎:
https://www.zhihu.com/question/28098030/answer/68722565
  查看全部


c9c7e29cfff7929c9043e5bcefadcb4f_b.jpg

这是我的博士同事,Naphet,10月20日下午3点,他正式打出了他的博士论文,完成了四年的博士生涯。

Naphet 来自津巴布韦,世界上最混乱的国家之一(也许没有之一)。他没有谈他的童年,但我知道那一定不是我可以相比的。他从家乡出来后,成功地申请到了我们学校的 PhD,并且获得了英国国籍。这中间的努力,真的是我难以想象的。我至今深深记得,他去参加他的博士论文答辩的那天,抱着一本300多页厚厚的博士论文,像抱着一个婴儿那么珍惜。他的论文做定量的,主要工具是spss 程序,我曾经问过他从哪里学的 spss,他和我说,他在网上自学的。在读博的三年时间里,他就通过看 Youtube 的在线视频来从0开始学习 spss,如今,他的论文里充斥着各种精致的公式,而我的论文相比之下是如此的苍白无力。但他的论文还是没有通过答辩,因为我们学校新来的一个女老师质疑了他的方法,他很愤怒,因为他不理解为什么自己学校的老师竟然不支持他,但他没有气馁,而是继续每天早出晚归地来研究室修改论文。


他是有两个孩子的单亲爸爸。女儿已经上了高中,儿子才几个月大。他白天要在家里带孩子,晚上到火车站开出租车补贴学费和家用,挣来的钱还要寄回津巴布韦老家。因此他白天在家里通过远程桌面连接学校电脑学习,只有在晚上五点以后,他的女儿放学回来能照顾自己的弟弟,以及出租下班的时候才能来研究室学习。他周末的时候从来不回家,睡在出租车里,这样能多挣钱。而他一旦坐下,就会一动不动地全神贯注地开始工作。我有时候都很奇怪他从哪里来的精力,能够一边打工一边学习,并且能够如此专注。每每午夜十二点半,我离开研究室,而他仍然坐在电脑屏幕面前,专心调整着他公式的参数。

Naphet 的女儿非常优秀,她6岁的时候来到他身边。他充满自豪地同我分享了她女儿在 BBC 演讲比赛中获胜的演讲,并且告诉我她是英国青少年议会的议员,教区领袖,学校青少年协会的领导。“她的生活非常自律,比我更加自律,我从来没见过一个哪个17岁的孩子能够像她那么生活。”他对我说。在他女儿十五岁参加的那场演讲中,她把英语称之为杀手,并且分析了外国移民在英文环境中面对的语言困境。“我没有写一个字给她,都是她自己写的。我把这个视频用到了我的课程'社会学的想象力'中,这是一个可以作为博士论文的课题。”Naphet 非常自豪地对我说。我真的很震惊一个十五岁的女孩能够对环境有如此的敏感性。我提醒 Naphet 不要让她过于骄傲,他和我说:“我从来不夸奖她,我只是告诉她需要面对的挑战。她能够完成每一项挑战。”

他曾和我分享了他求职失败的经历,原因竟然是他过于优秀。三年博士期间,他获得了多个教师资格证书,比他的面试官还要优秀。结果可想而知,他精心准备的演讲反而害了他,实在是十分荒谬。但他没有气馁,他和我说:“我目前需要做的就是尽快博士毕业,好让自己有更多的自由去寻找更好的机会。”他的教学经验之丰富,远远超过了他的同辈,连他的面试官也只能嫉妒地说:“你实在是走的太快了。”我问他关于论文引用的问题,他却反过来向我求教我使用的引用软件,等我介绍完之后他掏出本子认真的记录着:“这个软件很好,我以后也要让我女儿试试。我现在就在为她准备大学需要面临的一切。”那一刻,我真的感觉到为什么人们说机会都是留给有准备的人。什么样的人是优秀的人?自强,自律,虚心,不骄不躁,永远充满信心,这样的父亲有这样的女儿,一点也不奇怪。

人在海外,社交圈很小,因此他给我的触动反倒更大。我第一次认真思考了何为一个有担当的男人。他没有钱,所以出去工作,他没有知识,所以上网自学。他面对着所有的不公正,却充满了自信的微笑。他对我说:“我要尽快完成我的博士,向我女儿证明我可以做到这一切。”是的,他一定可以的,我一点都不怀疑。反观我自己,在每一点上都放佛要被压榨出一个大大的“小”字来,我连对比的勇气都没有。他那岩石一般英朗的笑容背后有多少辛酸,多少委屈,我无法猜测,但我看到的是,他如同钟表一样准时的每天来到研究室,坐下,学习,创造着属于他和他女儿的未来。

他在论文的致谢部分写着:“献给我的母亲和我的四个兄弟,献给我过世的爸爸和五个叔叔。”

“我已经很多年没见过我母亲了。”他看着我读完了致谢之后说。

“你是怎么走过这一切的呢?”我问。

“压力。生活挤压着你,你只有前进。我所获得的一切都是靠我自己的双手得来的。”

他,是他们五兄弟中唯一走出来的。

很多时候,Naphet 这样的人是学不来的,但我想,他本身也许就是一个答案,在我们陷入迷茫和懦弱时,在我们给自己的人生拼命找借口时,带来一个声音:

贫穷不能改变吗?

能。

 
 
转至知乎:
https://www.zhihu.com/question/28098030/answer/68722565
 

TA-Lib MA_Type

股票李魔佛 发表了文章 • 0 个评论 • 17692 次浏览 • 2017-05-29 00:43 • 来自相关话题

在TA-Lib中有一个参数的类型是MA_Type, 谷歌了一下,把内容贴出来。 
 
主要就是使用不一样的加权方式对数据进行处理。import talib
from talib import MA_Type

MA_Type: 0=SMA, 1=EMA, 2=WMA, 3=DEMA, 4=TEMA, 5=TRIMA, 6=KAMA, 7=MAMA, 8=T3 (Default=SMA)
 
移动平均(英语:moving average,MA),又称“移动平均线”简称均线,是技术分析中一种分析时间序列数据的工具。最常见的是利用股价、回报或交易量等变数计算出移动平均。
移动平均可抚平短期波动,反映出长期趋势或周期。数学上,移动平均可视为一种卷积。
 

简单移动平均(英语:simple moving average,SMA)是某变数之前n个数值的未作加权算术平均。例如,收市价的10日简单移动平均指之前10日收市价的平均数。:

当计算连续的数值,一个新的数值加入,同时一个旧数值剔出,所以无需每次都重新逐个数值加起来。
在技术分析中,不同的市场对常用天数(n值)有不同的需求,例如:某些市场普遍的n值为10日、40日、200日;有些则是5日、10日、20日、60日、120日、240日,视乎分析时期长短而定。投资者冀从移动平均线的图表中分辨出支持位或阻力位。
 
 
 
加权移动平均(英语:weighted moving average,WMA)指计算平均值时将个别数据乘以不同数值,在技术分析中,n日WMA的最近期一个数值乘以n、次近的乘以n-1,如此类推,一直到0:
 
指数移动平均(英语:exponential moving average,EMA或EWMA)是以指数式递减加权的移动平均。各数值的加权影响力随时间而指数式递减,越近期的数据加权影响力越重,但较旧的数据也给予一定的加权值
 
     
     WMA                                             EMA
 
 
使用下面的代码实现不一样的MA
  #MA_Type: 0=SMA, 1=EMA, 2=WMA, 3=DEMA, 4=TEMA, 5=TRIMA, 6=KAMA, 7=MAMA, 8=T3 (Default=SMA)
df=ts.get_k_data('300580',start='2017-01-12',end='2017-05-26')
closed=df['close'].values
sma=talib.MA(closed,timeperiod=10,matype=0)
ema=talib.MA(closed,timeperiod=10,matype=1)
wma=talib.MA(closed,timeperiod=10,matype=2)
dema=talib.MA(closed,timeperiod=10,matype=3)
tema=talib.MA(closed,timeperiod=10,matype=4)
trima=talib.MA(closed,timeperiod=10,matype=5)
kma=talib.MA(closed,timeperiod=10,matype=6)
mama=talib.MA(closed,timeperiod=10,matype=7)
t3=talib.MA(closed,timeperiod=10,matype=8)
#ouput=talib.MA(closed,timeperiod=5,matype=0)
print closed
plt.ylim([0,40])
plt.plot(sma)
plt.plot(ema)
plt.plot(wma)
plt.plot(dema)
plt.plot(tema)
plt.plot(trima)
plt.plot(kma)
plt.plot(mama)
plt.plot(t3)
plt.grid()
plt.show()
生成的图像如下:





 
http://30daydo.com/article/201
转载请注明出处 查看全部
在TA-Lib中有一个参数的类型是MA_Type, 谷歌了一下,把内容贴出来。 
 
主要就是使用不一样的加权方式对数据进行处理。
import talib
from talib import MA_Type

MA_Type: 0=SMA, 1=EMA, 2=WMA, 3=DEMA, 4=TEMA, 5=TRIMA, 6=KAMA, 7=MAMA, 8=T3 (Default=SMA)

 
移动平均(英语:moving average,MA),又称“移动平均线”简称均线,是技术分析中一种分析时间序列数据的工具。最常见的是利用股价、回报或交易量等变数计算出移动平均。
移动平均可抚平短期波动,反映出长期趋势或周期。数学上,移动平均可视为一种卷积。
 

简单移动平均(英语:simple moving average,SMA)是某变数之前n个数值的未作加权算术平均。例如,收市价的10日简单移动平均指之前10日收市价的平均数。:

当计算连续的数值,一个新的数值加入,同时一个旧数值剔出,所以无需每次都重新逐个数值加起来。
在技术分析中,不同的市场对常用天数(n值)有不同的需求,例如:某些市场普遍的n值为10日、40日、200日;有些则是5日、10日、20日、60日、120日、240日,视乎分析时期长短而定。投资者冀从移动平均线的图表中分辨出支持位或阻力位。
 
 
 
加权移动平均(英语:weighted moving average,WMA)指计算平均值时将个别数据乘以不同数值,在技术分析中,n日WMA的最近期一个数值乘以n、次近的乘以n-1,如此类推,一直到0:
 
指数移动平均(英语:exponential moving average,EMA或EWMA)是以指数式递减加权的移动平均。各数值的加权影响力随时间而指数式递减,越近期的数据加权影响力越重,但较旧的数据也给予一定的加权值
 
     
     WMA                                             EMA
 
 
使用下面的代码实现不一样的MA
 
    #MA_Type: 0=SMA, 1=EMA, 2=WMA, 3=DEMA, 4=TEMA, 5=TRIMA, 6=KAMA, 7=MAMA, 8=T3 (Default=SMA)
df=ts.get_k_data('300580',start='2017-01-12',end='2017-05-26')
closed=df['close'].values
sma=talib.MA(closed,timeperiod=10,matype=0)
ema=talib.MA(closed,timeperiod=10,matype=1)
wma=talib.MA(closed,timeperiod=10,matype=2)
dema=talib.MA(closed,timeperiod=10,matype=3)
tema=talib.MA(closed,timeperiod=10,matype=4)
trima=talib.MA(closed,timeperiod=10,matype=5)
kma=talib.MA(closed,timeperiod=10,matype=6)
mama=talib.MA(closed,timeperiod=10,matype=7)
t3=talib.MA(closed,timeperiod=10,matype=8)
#ouput=talib.MA(closed,timeperiod=5,matype=0)
print closed
plt.ylim([0,40])
plt.plot(sma)
plt.plot(ema)
plt.plot(wma)
plt.plot(dema)
plt.plot(tema)
plt.plot(trima)
plt.plot(kma)
plt.plot(mama)
plt.plot(t3)
plt.grid()
plt.show()

生成的图像如下:

diff_ma.PNG

 
http://30daydo.com/article/201
转载请注明出处

TA-Lib 量化交易代码实例 <二> 获取布林线的上轨,中轨,下轨的数据

量化交易-Ptrade-QMT李魔佛 发表了文章 • 0 个评论 • 24435 次浏览 • 2017-05-28 23:08 • 来自相关话题

BOLL指标的原理
BOLL指标是美国股市分析家约翰·布林根据统计学中的标准差原理设计出来的一种非常简单实用的技术分析指标。一般而言,股价的运动总是围绕某一价值中枢(如均线、成本线等)在一定的范围内变动,布林线指标指标正是在上述条件的基础上,引进了“股价通道”的概念,其认为股价通道的宽窄随着股价波动幅度的大小而变化,而且股价通道又具有变异性,它会随着股价的变化而自动调整。正是由于它具有灵活性、直观性和趋势性的特点,BOLL指标渐渐成为投资者广为应用的市场上热门指标。
在众多技术分析指标中,BOLL指标属于比较特殊的一类指标。绝大多数技术分析指标都是通过数量的方法构造出来的,它们本身不依赖趋势分析和形态分析,而BOLL指标却股价的形态和趋势有着密不可分的联系。BOLL指标中的“股价通道”概念正是股价趋势理论的直观表现形式。BOLL是利用“股价通道”来显示股价的各种价位,当股价波动很小,处于盘整时,股价通道就会变窄,这可能预示着股价的波动处于暂时的平静期;当股价波动超出狭窄的股价通道的上轨时,预示着股价的异常激烈的向上波动即将开始;当股价波动超出狭窄的股价通道的下轨时,同样也预示着股价的异常激烈的向下波动将开始。
投资者常常会遇到两种最常见的交易陷阱,一是买低陷阱,投资者在所谓的低位买进之后,股价不仅没有止跌反而不断下跌;二是卖高陷阱,股票在所谓的高点卖出后,股价却一路上涨。布林线特别运用了爱因斯坦的相对论,认为各类市场间都是互动的,市场内和市场间的各种变化都是相对性的,是不存在绝对性的,股价的高低是相对的,股价在上轨线以上或在下轨线以下只反映该股股价相对较高或较低,投资者作出投资判断前还须综合参考其他技术指标,包括价量配合,心理类指标,类比类指标,市场间的关联数据等。
总之,BOLL指标中的股价通道对预测未来行情的走势起着重要的参考作用,它也是布林线指标所特有的分析手段。
[编辑]
BOLL指标的计算方法
在所有的指标计算中,BOLL指标的计算方法是最复杂的之一,其中引进了统计学中的标准差概念,涉及到中轨线(MB)、上轨线(UP)和下轨线(DN)的计算。另外,和其他指标的计算一样,由于选用的计算周期的不同,BOLL指标也包括日BOLL指标、周BOLL指标、月BOLL指标年BOLL指标以及分钟BOLL指标等各种类型。经常被用于股市研判的是日BOLL指标和周BOLL指标。虽然它们的计算时的取值有所不同,但基本的计算方法一样。以日BOLL指标计算为例,其计算方法如下:
1、日BOLL指标的计算公式
中轨线=N日的移动平均线
上轨线=中轨线+两倍的标准差
下轨线=中轨线-两倍的标准差
2、日BOLL指标的计算过程
1)计算MA
MA=N日内的收盘价之和÷N2)计算标准差MD
MD=平方根N日的(C-MA)的两次方之和除以N3)计算MB、UP、DN线
MB=(N-1)日的MA
UP=MB+2×MD
DN=MB-2×MD在股市分析软件中,BOLL指标一共由四条线组成,即上轨线UP 、中轨线MB、下轨线DN和价格线。其中上轨线UP是UP数值的连线,用黄色线表示;中轨线MB是MB数值的连线,用白色线表示;下轨线DN是DN数值的连线,用紫色线表示;价格线是以美国线表示,颜色为浅蓝色。和其他技术指标一样,在实战中,投资者不需要进行BOLL指标的计算,主要是了解BOLL的计算方法和过程,以便更加深入地掌握BOLL指标的实质,为运用指标打下基础。
 
#通过tushare获取股票信息
df=ts.get_k_data('300580',start='2017-01-12',end='2017-05-26')
#提取收盘价
closed=df['close'].values

upper,middle,lower=talib.BBANDS(closed,matype=talib.MA_Type.T3)

print upper,middle,lower
plt.plot(upper)
plt.plot(middle)
plt.plot(lower)
plt.grid()
plt.show()
diff1=upper-middle
diff2=middle-lower
print diff1
print diff2





 
最后那里可以看到diff1和diff2是一样的。 验证了布林线的定义ma+2d,m-2d。 查看全部

BOLL指标的原理
BOLL指标是美国股市分析家约翰·布林根据统计学中的标准差原理设计出来的一种非常简单实用的技术分析指标。一般而言,股价的运动总是围绕某一价值中枢(如均线、成本线等)在一定的范围内变动,布林线指标指标正是在上述条件的基础上,引进了“股价通道”的概念,其认为股价通道的宽窄随着股价波动幅度的大小而变化,而且股价通道又具有变异性,它会随着股价的变化而自动调整。正是由于它具有灵活性、直观性和趋势性的特点,BOLL指标渐渐成为投资者广为应用的市场上热门指标。
在众多技术分析指标中,BOLL指标属于比较特殊的一类指标。绝大多数技术分析指标都是通过数量的方法构造出来的,它们本身不依赖趋势分析和形态分析,而BOLL指标却股价的形态和趋势有着密不可分的联系。BOLL指标中的“股价通道”概念正是股价趋势理论的直观表现形式。BOLL是利用“股价通道”来显示股价的各种价位,当股价波动很小,处于盘整时,股价通道就会变窄,这可能预示着股价的波动处于暂时的平静期;当股价波动超出狭窄的股价通道的上轨时,预示着股价的异常激烈的向上波动即将开始;当股价波动超出狭窄的股价通道的下轨时,同样也预示着股价的异常激烈的向下波动将开始。
投资者常常会遇到两种最常见的交易陷阱,一是买低陷阱,投资者在所谓的低位买进之后,股价不仅没有止跌反而不断下跌;二是卖高陷阱,股票在所谓的高点卖出后,股价却一路上涨。布林线特别运用了爱因斯坦的相对论,认为各类市场间都是互动的,市场内和市场间的各种变化都是相对性的,是不存在绝对性的,股价的高低是相对的,股价在上轨线以上或在下轨线以下只反映该股股价相对较高或较低,投资者作出投资判断前还须综合参考其他技术指标,包括价量配合,心理类指标,类比类指标,市场间的关联数据等。
总之,BOLL指标中的股价通道对预测未来行情的走势起着重要的参考作用,它也是布林线指标所特有的分析手段。
[编辑]
BOLL指标的计算方法
在所有的指标计算中,BOLL指标的计算方法是最复杂的之一,其中引进了统计学中的标准差概念,涉及到中轨线(MB)、上轨线(UP)和下轨线(DN)的计算。另外,和其他指标的计算一样,由于选用的计算周期的不同,BOLL指标也包括日BOLL指标、周BOLL指标、月BOLL指标年BOLL指标以及分钟BOLL指标等各种类型。经常被用于股市研判的是日BOLL指标和周BOLL指标。虽然它们的计算时的取值有所不同,但基本的计算方法一样。以日BOLL指标计算为例,其计算方法如下:
1、日BOLL指标的计算公式
中轨线=N日的移动平均线
上轨线=中轨线+两倍的标准差
下轨线=中轨线-两倍的标准差
2、日BOLL指标的计算过程
1)计算MA
MA=N日内的收盘价之和÷N2)计算标准差MD
MD=平方根N日的(C-MA)的两次方之和除以N3)计算MB、UP、DN线
MB=(N-1)日的MA
UP=MB+2×MD
DN=MB-2×MD在股市分析软件中,BOLL指标一共由四条线组成,即上轨线UP 、中轨线MB、下轨线DN和价格线。其中上轨线UP是UP数值的连线,用黄色线表示;中轨线MB是MB数值的连线,用白色线表示;下轨线DN是DN数值的连线,用紫色线表示;价格线是以美国线表示,颜色为浅蓝色。和其他技术指标一样,在实战中,投资者不需要进行BOLL指标的计算,主要是了解BOLL的计算方法和过程,以便更加深入地掌握BOLL指标的实质,为运用指标打下基础。
 
    #通过tushare获取股票信息
df=ts.get_k_data('300580',start='2017-01-12',end='2017-05-26')
#提取收盘价
closed=df['close'].values

upper,middle,lower=talib.BBANDS(closed,matype=talib.MA_Type.T3)

print upper,middle,lower
plt.plot(upper)
plt.plot(middle)
plt.plot(lower)
plt.grid()
plt.show()
diff1=upper-middle
diff2=middle-lower
print diff1
print diff2


布林线.PNG

 
最后那里可以看到diff1和diff2是一样的。 验证了布林线的定义ma+2d,m-2d。

TA-Lib 量化交易代码实例 <一> 获取5日,10日,20日均线数据

量化交易-Ptrade-QMT李魔佛 发表了文章 • 0 个评论 • 24001 次浏览 • 2017-05-28 21:37 • 来自相关话题

第一节
 
安装教程在前面内容已经介绍过了,对于新手也是有点障碍,可以参照前面的文章进行一步一步操作。 http://30daydo.com/article/195 #通过tushare获取股票信息
df=ts.get_k_data('300580',start='2017-01-12',end='2017-05-26')
#提取收盘价
closed=df['close'].values
#获取均线的数据,通过timeperiod参数来分别获取 5,10,20 日均线的数据。
ma5=talib.SMA(closed,timeperiod=5)
ma10=talib.SMA(closed,timeperiod=10)
ma20=talib.SMA(closed,timeperiod=20)

#打印出来每一个数据
print closed
print ma5
print ma10
print ma20

#通过plog函数可以很方便的绘制出每一条均线
plt.plot(closed)
plt.plot(ma5)
plt.plot(ma10)
plt.plot(ma20)
#添加网格,可有可无,只是让图像好看点
plt.grid()
#记得加这一句,不然不会显示图像
plt.show()
上面第一句使用tushare获取股票的数据,如果不知道怎么操作的,可以在这里参考,同样是入门的教程。
http://30daydo.com/article/13
 
 
运行上面的代码后,可以得到下面的曲线:
 





 
你们可以去对比一下贝斯特的收盘价,5日,10日,20日均线。是不是一样的?
就这样我们就完成了均线的获取。 是不是很简单?
 
 
  查看全部
第一节
 
安装教程在前面内容已经介绍过了,对于新手也是有点障碍,可以参照前面的文章进行一步一步操作。 http://30daydo.com/article/195
    #通过tushare获取股票信息
df=ts.get_k_data('300580',start='2017-01-12',end='2017-05-26')
#提取收盘价
closed=df['close'].values
#获取均线的数据,通过timeperiod参数来分别获取 5,10,20 日均线的数据。
ma5=talib.SMA(closed,timeperiod=5)
ma10=talib.SMA(closed,timeperiod=10)
ma20=talib.SMA(closed,timeperiod=20)

#打印出来每一个数据
print closed
print ma5
print ma10
print ma20

#通过plog函数可以很方便的绘制出每一条均线
plt.plot(closed)
plt.plot(ma5)
plt.plot(ma10)
plt.plot(ma20)
#添加网格,可有可无,只是让图像好看点
plt.grid()
#记得加这一句,不然不会显示图像
plt.show()

上面第一句使用tushare获取股票的数据,如果不知道怎么操作的,可以在这里参考,同样是入门的教程。
http://30daydo.com/article/13
 
 
运行上面的代码后,可以得到下面的曲线:
 

贝斯特曲线.PNG

 
你们可以去对比一下贝斯特的收盘价,5日,10日,20日均线。是不是一样的?
就这样我们就完成了均线的获取。 是不是很简单?
 
 
 

ImportError: No module named _tkinter

python李魔佛 发表了文章 • 0 个评论 • 6521 次浏览 • 2017-05-28 21:33 • 来自相关话题

ImportError: No module named _tkinter, please install the python-tk package ubuntu运行tkinter错误
 
 这是由于Python的版本没有包含tkinter的模块,只需要把tk的package安装就可以了。 一般在Linux才出现,windows版本一般已经包含了tkinter模块。

apt-get install python-tk 查看全部
ImportError: No module named _tkinter, please install the python-tk package ubuntu运行tkinter错误
 
 这是由于Python的版本没有包含tkinter的模块,只需要把tk的package安装就可以了。 一般在Linux才出现,windows版本一般已经包含了tkinter模块。

apt-get install python-tk

量化工具TA-Lib 使用例子

量化交易-Ptrade-QMT李魔佛 发表了文章 • 0 个评论 • 18283 次浏览 • 2017-05-26 23:51 • 来自相关话题

http://30daydo.com/article/196
 TA-Lib主要用来计算一些股市中常见的指标。
比如MACD,BOLL,均线等参数。
 #-*-coding=utf-8-*-
import Tkinter as tk
from Tkinter import *
import ttk
import matplotlib.pyplot as plt

import numpy as np
import talib as ta

series = np.random.choice([1, -1], size=200)
close = np.cumsum(series).astype(float)

# 重叠指标
def overlap_process(event):
print(event.widget.get())
overlap = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(overlap, fontproperties="SimHei")

if overlap == '布林线':
pass
elif overlap == '双指数移动平均线':
real = ta.DEMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '指数移动平均线 ':
real = ta.EMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '希尔伯特变换——瞬时趋势线':
real = ta.HT_TRENDLINE(close)
axes[1].plot(real, '')
elif overlap == '考夫曼自适应移动平均线':
real = ta.KAMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '移动平均线':
real = ta.MA(close, timeperiod=30, matype=0)
axes[1].plot(real, '')
elif overlap == 'MESA自适应移动平均':
mama, fama = ta.MAMA(close, fastlimit=0, slowlimit=0)
axes[1].plot(mama, '')
axes[1].plot(fama, '')
elif overlap == '变周期移动平均线':
real = ta.MAVP(close, periods, minperiod=2, maxperiod=30, matype=0)
axes[1].plot(real, '')
elif overlap == '简单移动平均线':
real = ta.SMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '三指数移动平均线(T3)':
real = ta.T3(close, timeperiod=5, vfactor=0)
axes[1].plot(real, '')
elif overlap == '三指数移动平均线':
real = ta.TEMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '三角形加权法 ':
real = ta.TRIMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '加权移动平均数':
real = ta.WMA(close, timeperiod=30)
axes[1].plot(real, '')
plt.show()

# 动量指标
def momentum_process(event):
print(event.widget.get())
momentum = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(momentum, fontproperties="SimHei")

if momentum == '绝对价格振荡器':
real = ta.APO(close, fastperiod=12, slowperiod=26, matype=0)
axes[1].plot(real, '')
elif momentum == '钱德动量摆动指标':
real = ta.CMO(close, timeperiod=14)
axes[1].plot(real, '')
elif momentum == '移动平均收敛/散度':
macd, macdsignal, macdhist = ta.MACD(close, fastperiod=12, slowperiod=26, signalperiod=9)
axes[1].plot(macd, '')
axes[1].plot(macdsignal, '')
axes[1].plot(macdhist, '')
elif momentum == '带可控MA类型的MACD':
macd, macdsignal, macdhist = ta.MACDEXT(close, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0)
axes[1].plot(macd, '')
axes[1].plot(macdsignal, '')
axes[1].plot(macdhist, '')
elif momentum == '移动平均收敛/散度 固定 12/26':
macd, macdsignal, macdhist = ta.MACDFIX(close, signalperiod=9)
axes[1].plot(macd, '')
axes[1].plot(macdsignal, '')
axes[1].plot(macdhist, '')
elif momentum == '动量':
real = ta.MOM(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '比例价格振荡器':
real = ta.PPO(close, fastperiod=12, slowperiod=26, matype=0)
axes[1].plot(real, '')
elif momentum == '变化率':
real = ta.ROC(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '变化率百分比':
real = ta.ROCP(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '变化率的比率':
real = ta.ROCR(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '变化率的比率100倍':
real = ta.ROCR100(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '相对强弱指数':
real = ta.RSI(close, timeperiod=14)
axes[1].plot(real, '')
elif momentum == '随机相对强弱指标':
fastk, fastd = ta.STOCHRSI(close, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0)
axes[1].plot(fastk, '')
axes[1].plot(fastd, '')
elif momentum == '三重光滑EMA的日变化率':
real = ta.TRIX(close, timeperiod=30)
axes[1].plot(real, '')

plt.show()

# 周期指标
def cycle_process(event):
print(event.widget.get())
cycle = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(cycle, fontproperties="SimHei")

if cycle == '希尔伯特变换——主要的循环周期':
real = ta.HT_DCPERIOD(close)
axes[1].plot(real, '')
elif cycle == '希尔伯特变换,占主导地位的周期阶段':
real = ta.HT_DCPHASE(close)
axes[1].plot(real, '')
elif cycle == '希尔伯特变换——相量组件':
inphase, quadrature = ta.HT_PHASOR(close)
axes[1].plot(inphase, '')
axes[1].plot(quadrature, '')
elif cycle == '希尔伯特变换——正弦曲线':
sine, leadsine = ta.HT_SINE(close)
axes[1].plot(sine, '')
axes[1].plot(leadsine, '')
elif cycle == '希尔伯特变换——趋势和周期模式':
integer = ta.HT_TRENDMODE(close)
axes[1].plot(integer, '')

plt.show()


# 统计功能
def statistic_process(event):
print(event.widget.get())
statistic = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(statistic, fontproperties="SimHei")

if statistic == '线性回归':
real = ta.LINEARREG(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '线性回归角度':
real = ta.LINEARREG_ANGLE(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '线性回归截距':
real = ta.LINEARREG_INTERCEPT(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '线性回归斜率':
real = ta.LINEARREG_SLOPE(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '标准差':
real = ta.STDDEV(close, timeperiod=5, nbdev=1)
axes[1].plot(real, '')
elif statistic == '时间序列预测':
real = ta.TSF(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '方差':
real = ta.VAR(close, timeperiod=5, nbdev=1)
axes[1].plot(real, '')

plt.show()


# 数学变换
def math_transform_process(event):
print(event.widget.get())
math_transform = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(math_transform, fontproperties="SimHei")


if math_transform == '反余弦':
real = ta.ACOS(close)
axes[1].plot(real, '')
elif math_transform == '反正弦':
real = ta.ASIN(close)
axes[1].plot(real, '')
elif math_transform == '反正切':
real = ta.ATAN(close)
axes[1].plot(real, '')
elif math_transform == '向上取整':
real = ta.CEIL(close)
axes[1].plot(real, '')
elif math_transform == '余弦':
real = ta.COS(close)
axes[1].plot(real, '')
elif math_transform == '双曲余弦':
real = ta.COSH(close)
axes[1].plot(real, '')
elif math_transform == '指数':
real = ta.EXP(close)
axes[1].plot(real, '')
elif math_transform == '向下取整':
real = ta.FLOOR(close)
axes[1].plot(real, '')
elif math_transform == '自然对数':
real = ta.LN(close)
axes[1].plot(real, '')
elif math_transform == '常用对数':
real = ta.LOG10(close)
axes[1].plot(real, '')
elif math_transform == '正弦':
real = ta.SIN(close)
axes[1].plot(real, '')
elif math_transform == '双曲正弦':
real = ta.SINH(close)
axes[1].plot(real, '')
elif math_transform == '平方根':
real = ta.SQRT(close)
axes[1].plot(real, '')
elif math_transform == '正切':
real = ta.TAN(close)
axes[1].plot(real, '')
elif math_transform == '双曲正切':
real = ta.TANH(close)
axes[1].plot(real, '')

plt.show()


# 数学操作
def math_operator_process(event):
print(event.widget.get())
math_operator = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(math_operator, fontproperties="SimHei")


if math_operator == '指定的期间的最大值':
real = ta.MAX(close, timeperiod=30)
axes[1].plot(real, '')
elif math_operator == '指定的期间的最大值的索引':
integer = ta.MAXINDEX(close, timeperiod=30)
axes[1].plot(integer, '')
elif math_operator == '指定的期间的最小值':
real = ta.MIN(close, timeperiod=30)
axes[1].plot(real, '')
elif math_operator == '指定的期间的最小值的索引':
integer = ta.MININDEX(close, timeperiod=30)
axes[1].plot(integer, '')
elif math_operator == '指定的期间的最小和最大值':
min, max = ta.MINMAX(close, timeperiod=30)
axes[1].plot(min, '')
axes[1].plot(max, '')
elif math_operator == '指定的期间的最小和最大值的索引':
minidx, maxidx = ta.MINMAXINDEX(close, timeperiod=30)
axes[1].plot(minidx, '')
axes[1].plot(maxidx, '')
elif math_operator == '合计':
real = ta.SUM(close, timeperiod=30)
axes[1].plot(real, '')

plt.show()


root = tk.Tk()

# 第一行:重叠指标
rowframe1 = tk.Frame(root)
rowframe1.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe1, text="重叠指标").pack(side=tk.LEFT)

overlap_indicator = tk.StringVar() # 重叠指标
combobox1 = ttk.Combobox(rowframe1, textvariable=overlap_indicator)
combobox1['values'] = ['布林线','双指数移动平均线','指数移动平均线 ','希尔伯特变换——瞬时趋势线',
'考夫曼自适应移动平均线','移动平均线','MESA自适应移动平均','变周期移动平均线',
'简单移动平均线','三指数移动平均线(T3)','三指数移动平均线','三角形加权法 ','加权移动平均数']
combobox1.current(0)
combobox1.pack(side=tk.LEFT)

combobox1.bind('<<ComboboxSelected>>', overlap_process)


# 第二行:动量指标
rowframe2 = tk.Frame(root)
rowframe2.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe2, text="动量指标").pack(side=tk.LEFT)

momentum_indicator = tk.StringVar() # 动量指标
combobox2 = ttk.Combobox(rowframe2, textvariable=momentum_indicator)
combobox2['values'] = ['绝对价格振荡器','钱德动量摆动指标','移动平均收敛/散度','带可控MA类型的MACD',
'移动平均收敛/散度 固定 12/26','动量','比例价格振荡器','变化率','变化率百分比',
'变化率的比率','变化率的比率100倍','相对强弱指数','随机相对强弱指标','三重光滑EMA的日变化率']

combobox2.current(0)
combobox2.pack(side=tk.LEFT)

combobox2.bind('<<ComboboxSelected>>', momentum_process)



# 第三行:周期指标
rowframe3 = tk.Frame(root)
rowframe3.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe3, text="周期指标").pack(side=tk.LEFT)

cycle_indicator = tk.StringVar() # 周期指标
combobox3 = ttk.Combobox(rowframe3, textvariable=cycle_indicator)
combobox3['values'] = ['希尔伯特变换——主要的循环周期','希尔伯特变换——主要的周期阶段','希尔伯特变换——相量组件',
'希尔伯特变换——正弦曲线','希尔伯特变换——趋势和周期模式']

combobox3.current(0)
combobox3.pack(side=tk.LEFT)

combobox3.bind('<<ComboboxSelected>>', cycle_process)


# 第四行:统计功能
rowframe4 = tk.Frame(root)
rowframe4.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe4, text="统计功能").pack(side=tk.LEFT)

statistic_indicator = tk.StringVar() # 统计功能
combobox4 = ttk.Combobox(rowframe4, textvariable=statistic_indicator)
combobox4['values'] = ['贝塔系数;投资风险与股市风险系数','皮尔逊相关系数','线性回归','线性回归角度',
'线性回归截距','线性回归斜率','标准差','时间序列预测','方差']

combobox4.current(0)
combobox4.pack(side=tk.LEFT)

combobox4.bind('<<ComboboxSelected>>', statistic_process)


# 第五行:数学变换
rowframe5 = tk.Frame(root)
rowframe5.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe5, text="数学变换").pack(side=tk.LEFT)

math_transform = tk.StringVar() # 数学变换
combobox5 = ttk.Combobox(rowframe5, textvariable=math_transform_process)
combobox5['values'] = ['反余弦','反正弦','反正切','向上取整','余弦','双曲余弦','指数','向下取整',
'自然对数','常用对数','正弦','双曲正弦','平方根','正切','双曲正切']

combobox5.current(0)
combobox5.pack(side=tk.LEFT)

combobox5.bind('<<ComboboxSelected>>', math_transform_process)


# 第六行:数学操作
rowframe6 = tk.Frame(root)
rowframe6.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe6, text="数学操作").pack(side=tk.LEFT)

math_operator = tk.StringVar() # 数学操作
combobox6 = ttk.Combobox(rowframe6, textvariable=math_operator_process)
combobox6['values'] = ['指定期间的最大值','指定期间的最大值的索引','指定期间的最小值','指定期间的最小值的索引',
'指定期间的最小和最大值','指定期间的最小和最大值的索引','合计']

combobox6.current(0)
combobox6.pack(side=tk.LEFT)

combobox6.bind('<<ComboboxSelected>>', math_operator_process)




root.mainloop() 查看全部
http://30daydo.com/article/196
 TA-Lib主要用来计算一些股市中常见的指标。
比如MACD,BOLL,均线等参数。
 
#-*-coding=utf-8-*-
import Tkinter as tk
from Tkinter import *
import ttk
import matplotlib.pyplot as plt

import numpy as np
import talib as ta

series = np.random.choice([1, -1], size=200)
close = np.cumsum(series).astype(float)

# 重叠指标
def overlap_process(event):
print(event.widget.get())
overlap = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(overlap, fontproperties="SimHei")

if overlap == '布林线':
pass
elif overlap == '双指数移动平均线':
real = ta.DEMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '指数移动平均线 ':
real = ta.EMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '希尔伯特变换——瞬时趋势线':
real = ta.HT_TRENDLINE(close)
axes[1].plot(real, '')
elif overlap == '考夫曼自适应移动平均线':
real = ta.KAMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '移动平均线':
real = ta.MA(close, timeperiod=30, matype=0)
axes[1].plot(real, '')
elif overlap == 'MESA自适应移动平均':
mama, fama = ta.MAMA(close, fastlimit=0, slowlimit=0)
axes[1].plot(mama, '')
axes[1].plot(fama, '')
elif overlap == '变周期移动平均线':
real = ta.MAVP(close, periods, minperiod=2, maxperiod=30, matype=0)
axes[1].plot(real, '')
elif overlap == '简单移动平均线':
real = ta.SMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '三指数移动平均线(T3)':
real = ta.T3(close, timeperiod=5, vfactor=0)
axes[1].plot(real, '')
elif overlap == '三指数移动平均线':
real = ta.TEMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '三角形加权法 ':
real = ta.TRIMA(close, timeperiod=30)
axes[1].plot(real, '')
elif overlap == '加权移动平均数':
real = ta.WMA(close, timeperiod=30)
axes[1].plot(real, '')
plt.show()

# 动量指标
def momentum_process(event):
print(event.widget.get())
momentum = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(momentum, fontproperties="SimHei")

if momentum == '绝对价格振荡器':
real = ta.APO(close, fastperiod=12, slowperiod=26, matype=0)
axes[1].plot(real, '')
elif momentum == '钱德动量摆动指标':
real = ta.CMO(close, timeperiod=14)
axes[1].plot(real, '')
elif momentum == '移动平均收敛/散度':
macd, macdsignal, macdhist = ta.MACD(close, fastperiod=12, slowperiod=26, signalperiod=9)
axes[1].plot(macd, '')
axes[1].plot(macdsignal, '')
axes[1].plot(macdhist, '')
elif momentum == '带可控MA类型的MACD':
macd, macdsignal, macdhist = ta.MACDEXT(close, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0)
axes[1].plot(macd, '')
axes[1].plot(macdsignal, '')
axes[1].plot(macdhist, '')
elif momentum == '移动平均收敛/散度 固定 12/26':
macd, macdsignal, macdhist = ta.MACDFIX(close, signalperiod=9)
axes[1].plot(macd, '')
axes[1].plot(macdsignal, '')
axes[1].plot(macdhist, '')
elif momentum == '动量':
real = ta.MOM(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '比例价格振荡器':
real = ta.PPO(close, fastperiod=12, slowperiod=26, matype=0)
axes[1].plot(real, '')
elif momentum == '变化率':
real = ta.ROC(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '变化率百分比':
real = ta.ROCP(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '变化率的比率':
real = ta.ROCR(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '变化率的比率100倍':
real = ta.ROCR100(close, timeperiod=10)
axes[1].plot(real, '')
elif momentum == '相对强弱指数':
real = ta.RSI(close, timeperiod=14)
axes[1].plot(real, '')
elif momentum == '随机相对强弱指标':
fastk, fastd = ta.STOCHRSI(close, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0)
axes[1].plot(fastk, '')
axes[1].plot(fastd, '')
elif momentum == '三重光滑EMA的日变化率':
real = ta.TRIX(close, timeperiod=30)
axes[1].plot(real, '')

plt.show()

# 周期指标
def cycle_process(event):
print(event.widget.get())
cycle = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(cycle, fontproperties="SimHei")

if cycle == '希尔伯特变换——主要的循环周期':
real = ta.HT_DCPERIOD(close)
axes[1].plot(real, '')
elif cycle == '希尔伯特变换,占主导地位的周期阶段':
real = ta.HT_DCPHASE(close)
axes[1].plot(real, '')
elif cycle == '希尔伯特变换——相量组件':
inphase, quadrature = ta.HT_PHASOR(close)
axes[1].plot(inphase, '')
axes[1].plot(quadrature, '')
elif cycle == '希尔伯特变换——正弦曲线':
sine, leadsine = ta.HT_SINE(close)
axes[1].plot(sine, '')
axes[1].plot(leadsine, '')
elif cycle == '希尔伯特变换——趋势和周期模式':
integer = ta.HT_TRENDMODE(close)
axes[1].plot(integer, '')

plt.show()


# 统计功能
def statistic_process(event):
print(event.widget.get())
statistic = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(statistic, fontproperties="SimHei")

if statistic == '线性回归':
real = ta.LINEARREG(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '线性回归角度':
real = ta.LINEARREG_ANGLE(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '线性回归截距':
real = ta.LINEARREG_INTERCEPT(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '线性回归斜率':
real = ta.LINEARREG_SLOPE(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '标准差':
real = ta.STDDEV(close, timeperiod=5, nbdev=1)
axes[1].plot(real, '')
elif statistic == '时间序列预测':
real = ta.TSF(close, timeperiod=14)
axes[1].plot(real, '')
elif statistic == '方差':
real = ta.VAR(close, timeperiod=5, nbdev=1)
axes[1].plot(real, '')

plt.show()


# 数学变换
def math_transform_process(event):
print(event.widget.get())
math_transform = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(math_transform, fontproperties="SimHei")


if math_transform == '反余弦':
real = ta.ACOS(close)
axes[1].plot(real, '')
elif math_transform == '反正弦':
real = ta.ASIN(close)
axes[1].plot(real, '')
elif math_transform == '反正切':
real = ta.ATAN(close)
axes[1].plot(real, '')
elif math_transform == '向上取整':
real = ta.CEIL(close)
axes[1].plot(real, '')
elif math_transform == '余弦':
real = ta.COS(close)
axes[1].plot(real, '')
elif math_transform == '双曲余弦':
real = ta.COSH(close)
axes[1].plot(real, '')
elif math_transform == '指数':
real = ta.EXP(close)
axes[1].plot(real, '')
elif math_transform == '向下取整':
real = ta.FLOOR(close)
axes[1].plot(real, '')
elif math_transform == '自然对数':
real = ta.LN(close)
axes[1].plot(real, '')
elif math_transform == '常用对数':
real = ta.LOG10(close)
axes[1].plot(real, '')
elif math_transform == '正弦':
real = ta.SIN(close)
axes[1].plot(real, '')
elif math_transform == '双曲正弦':
real = ta.SINH(close)
axes[1].plot(real, '')
elif math_transform == '平方根':
real = ta.SQRT(close)
axes[1].plot(real, '')
elif math_transform == '正切':
real = ta.TAN(close)
axes[1].plot(real, '')
elif math_transform == '双曲正切':
real = ta.TANH(close)
axes[1].plot(real, '')

plt.show()


# 数学操作
def math_operator_process(event):
print(event.widget.get())
math_operator = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
fig, axes = plt.subplots(2, 1, sharex=True)
ax1, ax2 = axes[0], axes[1]
axes[0].plot(close, '', markersize=3)
axes[0].plot(upperband, '')
axes[0].plot(middleband, '')
axes[0].plot(lowerband, '')
axes[0].set_title(math_operator, fontproperties="SimHei")


if math_operator == '指定的期间的最大值':
real = ta.MAX(close, timeperiod=30)
axes[1].plot(real, '')
elif math_operator == '指定的期间的最大值的索引':
integer = ta.MAXINDEX(close, timeperiod=30)
axes[1].plot(integer, '')
elif math_operator == '指定的期间的最小值':
real = ta.MIN(close, timeperiod=30)
axes[1].plot(real, '')
elif math_operator == '指定的期间的最小值的索引':
integer = ta.MININDEX(close, timeperiod=30)
axes[1].plot(integer, '')
elif math_operator == '指定的期间的最小和最大值':
min, max = ta.MINMAX(close, timeperiod=30)
axes[1].plot(min, '')
axes[1].plot(max, '')
elif math_operator == '指定的期间的最小和最大值的索引':
minidx, maxidx = ta.MINMAXINDEX(close, timeperiod=30)
axes[1].plot(minidx, '')
axes[1].plot(maxidx, '')
elif math_operator == '合计':
real = ta.SUM(close, timeperiod=30)
axes[1].plot(real, '')

plt.show()


root = tk.Tk()

# 第一行:重叠指标
rowframe1 = tk.Frame(root)
rowframe1.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe1, text="重叠指标").pack(side=tk.LEFT)

overlap_indicator = tk.StringVar() # 重叠指标
combobox1 = ttk.Combobox(rowframe1, textvariable=overlap_indicator)
combobox1['values'] = ['布林线','双指数移动平均线','指数移动平均线 ','希尔伯特变换——瞬时趋势线',
'考夫曼自适应移动平均线','移动平均线','MESA自适应移动平均','变周期移动平均线',
'简单移动平均线','三指数移动平均线(T3)','三指数移动平均线','三角形加权法 ','加权移动平均数']
combobox1.current(0)
combobox1.pack(side=tk.LEFT)

combobox1.bind('<<ComboboxSelected>>', overlap_process)


# 第二行:动量指标
rowframe2 = tk.Frame(root)
rowframe2.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe2, text="动量指标").pack(side=tk.LEFT)

momentum_indicator = tk.StringVar() # 动量指标
combobox2 = ttk.Combobox(rowframe2, textvariable=momentum_indicator)
combobox2['values'] = ['绝对价格振荡器','钱德动量摆动指标','移动平均收敛/散度','带可控MA类型的MACD',
'移动平均收敛/散度 固定 12/26','动量','比例价格振荡器','变化率','变化率百分比',
'变化率的比率','变化率的比率100倍','相对强弱指数','随机相对强弱指标','三重光滑EMA的日变化率']

combobox2.current(0)
combobox2.pack(side=tk.LEFT)

combobox2.bind('<<ComboboxSelected>>', momentum_process)



# 第三行:周期指标
rowframe3 = tk.Frame(root)
rowframe3.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe3, text="周期指标").pack(side=tk.LEFT)

cycle_indicator = tk.StringVar() # 周期指标
combobox3 = ttk.Combobox(rowframe3, textvariable=cycle_indicator)
combobox3['values'] = ['希尔伯特变换——主要的循环周期','希尔伯特变换——主要的周期阶段','希尔伯特变换——相量组件',
'希尔伯特变换——正弦曲线','希尔伯特变换——趋势和周期模式']

combobox3.current(0)
combobox3.pack(side=tk.LEFT)

combobox3.bind('<<ComboboxSelected>>', cycle_process)


# 第四行:统计功能
rowframe4 = tk.Frame(root)
rowframe4.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe4, text="统计功能").pack(side=tk.LEFT)

statistic_indicator = tk.StringVar() # 统计功能
combobox4 = ttk.Combobox(rowframe4, textvariable=statistic_indicator)
combobox4['values'] = ['贝塔系数;投资风险与股市风险系数','皮尔逊相关系数','线性回归','线性回归角度',
'线性回归截距','线性回归斜率','标准差','时间序列预测','方差']

combobox4.current(0)
combobox4.pack(side=tk.LEFT)

combobox4.bind('<<ComboboxSelected>>', statistic_process)


# 第五行:数学变换
rowframe5 = tk.Frame(root)
rowframe5.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe5, text="数学变换").pack(side=tk.LEFT)

math_transform = tk.StringVar() # 数学变换
combobox5 = ttk.Combobox(rowframe5, textvariable=math_transform_process)
combobox5['values'] = ['反余弦','反正弦','反正切','向上取整','余弦','双曲余弦','指数','向下取整',
'自然对数','常用对数','正弦','双曲正弦','平方根','正切','双曲正切']

combobox5.current(0)
combobox5.pack(side=tk.LEFT)

combobox5.bind('<<ComboboxSelected>>', math_transform_process)


# 第六行:数学操作
rowframe6 = tk.Frame(root)
rowframe6.pack(side=tk.TOP, ipadx=3, ipady=3)
tk.Label(rowframe6, text="数学操作").pack(side=tk.LEFT)

math_operator = tk.StringVar() # 数学操作
combobox6 = ttk.Combobox(rowframe6, textvariable=math_operator_process)
combobox6['values'] = ['指定期间的最大值','指定期间的最大值的索引','指定期间的最小值','指定期间的最小值的索引',
'指定期间的最小和最大值','指定期间的最小和最大值的索引','合计']

combobox6.current(0)
combobox6.pack(side=tk.LEFT)

combobox6.bind('<<ComboboxSelected>>', math_operator_process)




root.mainloop()

破解安卓锁屏图案

python李魔佛 发表了文章 • 0 个评论 • 11130 次浏览 • 2017-05-23 23:56 • 来自相关话题

http://30daydo.com/article/194
 目前成功的有2种方法:
 
方法1: 暴力,快速。 只需几秒钟的时间就可以了。 不过前提需要你的手机又root权限。
 
具体操作: ADB连接手机,然后运行“adb rm /data/system/gesture.key”删除掉gesture.key文件,此时图形锁就失效了,随意画一下就能解锁。
 
方法2: 速度慢,但是可以还原你的锁屏图案。 这个方法同样需要root





 
 # -*- coding: cp936 -*-
import itertools
import hashlib
import time
import os

#调用cmd,ADB连接到手机,读取SHA1加密后的字符串
os.system("adb pull /data/system/gesture.key gesture.key")
time.sleep(5)
f=open('gesture.key','r')
pswd=f.readline()
f.close()
pswd_hex=pswd.encode('hex')
print '加密后的密码为:%s'%pswd_hex

#生成解锁序列,得到['00','01','02','03','04','05','06','07','08']
matrix=
for i in range(0,9):
str_temp = '0'+str(i)
matrix.append(str_temp)

#将00——08的字符进行排列,至少取4个数排列,最多全部进行排列

min_num=4
max_num=len(matrix)

for num in range(min_num,max_num+1):#从04 -> 08
iter1 = itertools.permutations(matrix,num)#从9个数字中挑出n个进行排列
list_m=
list_m.append(list(iter1))#将生成的排列全部存放到 list_m 列表中
for el in list_m[0]:#遍历这n个数字的全部排列
strlist=''.join(el)#将list转换成str。[00,03,06,07,08]-->0003060708
strlist_sha1 = hashlib.sha1(strlist.decode('hex')).hexdigest()#将字符串进行SHA1加密
if pswd_hex==strlist_sha1:#将手机文件里的字符串与加密字符串进行对比
print '解锁密码为:',strlist
原理分析
 
首先科普一下,安卓手机是如何标记这9个点的。通过阅读安卓系统源码可知,每个点都有其编号,组成了一个3×3的矩阵,形如:
 00 01 02
03 04 05
06 07 08
假如设定解锁图形为一个“L”形,如图:
 





 
那么这几个点的排列顺序是这样的:00 03 06 07 08。系统就记下来了这一串数字,然后将这一串数字(以十六进制的方式)进行SHA1加密,存储在了手机里的/data/system/gesture.key 文件中
 
WinHex等十六进制编辑程序打开gesture.key,会发现文件内是SHA1加密过的字符串:c8c0b24a15dc8bbfd411427973574695230458f0
 
当你下次解锁的时候,系统就对比你画的图案,看对应的数字串是不是0003060708对应的加密结果。如果是,就解锁;不是就继续保持锁定。那么,如果穷举所有的数字串排列,会有多少呢?联想到高中的阶乘,如果用4个点做解锁图形的话,就是9x8x7x6=3024种可能性,那5个点就是15120,6个点的话60480,7个点181440,8个点362880,9个点362880。总共是985824种可能性‍‍(但这么计算并不严密,因为同一条直线上的点只能和他们相邻的点相连)‍‍。

满打满算,也不到985824种可能性。乍一看很大,但在计算机面前,穷举出来这些东西用不了几秒钟。
 
当你下次解锁的时候,系统就对比你画的图案,看对应的数字串是不是0003060708对应的加密结果。如果是,就解锁;不是就继续保持锁定。那么,如果穷举所有的数字串排列,会有多少呢?联想到高中的阶乘,如果用4个点做解锁图形的话,就是9x8x7x6=3024种可能性,那5个点就是15120,6个点的话60480,7个点181440,8个点362880,9个点362880。总共是985824种可能性‍‍(但这么计算并不严密,因为同一条直线上的点只能和他们相邻的点相连)‍‍。

满打满算,也不到985824种可能性。乍一看很大,但在计算机面前,穷举出来这些东西用不了几秒钟。
 
 
  查看全部
http://30daydo.com/article/194
 目前成功的有2种方法:
 
方法1: 暴力,快速。 只需几秒钟的时间就可以了。 不过前提需要你的手机又root权限。
 
具体操作: ADB连接手机,然后运行“adb rm /data/system/gesture.key”删除掉gesture.key文件,此时图形锁就失效了,随意画一下就能解锁。
 
方法2: 速度慢,但是可以还原你的锁屏图案。 这个方法同样需要root

14255226989905.jpg

 
 
# -*- coding: cp936 -*-
import itertools
import hashlib
import time
import os

#调用cmd,ADB连接到手机,读取SHA1加密后的字符串
os.system("adb pull /data/system/gesture.key gesture.key")
time.sleep(5)
f=open('gesture.key','r')
pswd=f.readline()
f.close()
pswd_hex=pswd.encode('hex')
print '加密后的密码为:%s'%pswd_hex

#生成解锁序列,得到['00','01','02','03','04','05','06','07','08']
matrix=
for i in range(0,9):
str_temp = '0'+str(i)
matrix.append(str_temp)

#将00——08的字符进行排列,至少取4个数排列,最多全部进行排列

min_num=4
max_num=len(matrix)

for num in range(min_num,max_num+1):#从04 -> 08
iter1 = itertools.permutations(matrix,num)#从9个数字中挑出n个进行排列
list_m=
list_m.append(list(iter1))#将生成的排列全部存放到 list_m 列表中
for el in list_m[0]:#遍历这n个数字的全部排列
strlist=''.join(el)#将list转换成str。[00,03,06,07,08]-->0003060708
strlist_sha1 = hashlib.sha1(strlist.decode('hex')).hexdigest()#将字符串进行SHA1加密
if pswd_hex==strlist_sha1:#将手机文件里的字符串与加密字符串进行对比
print '解锁密码为:',strlist

原理分析
 
首先科普一下,安卓手机是如何标记这9个点的。通过阅读安卓系统源码可知,每个点都有其编号,组成了一个3×3的矩阵,形如:
 
00 01 02
03 04 05
06 07 08

假如设定解锁图形为一个“L”形,如图:
 

77681425522640.png

 
那么这几个点的排列顺序是这样的:00 03 06 07 08。系统就记下来了这一串数字,然后将这一串数字(以十六进制的方式)进行SHA1加密,存储在了手机里的/data/system/gesture.key 文件中
 
WinHex等十六进制编辑程序打开gesture.key,会发现文件内是SHA1加密过的字符串:c8c0b24a15dc8bbfd411427973574695230458f0
 
当你下次解锁的时候,系统就对比你画的图案,看对应的数字串是不是0003060708对应的加密结果。如果是,就解锁;不是就继续保持锁定。那么,如果穷举所有的数字串排列,会有多少呢?联想到高中的阶乘,如果用4个点做解锁图形的话,就是9x8x7x6=3024种可能性,那5个点就是15120,6个点的话60480,7个点181440,8个点362880,9个点362880。总共是985824种可能性‍‍(但这么计算并不严密,因为同一条直线上的点只能和他们相邻的点相连)‍‍。

满打满算,也不到985824种可能性。乍一看很大,但在计算机面前,穷举出来这些东西用不了几秒钟。
 
当你下次解锁的时候,系统就对比你画的图案,看对应的数字串是不是0003060708对应的加密结果。如果是,就解锁;不是就继续保持锁定。那么,如果穷举所有的数字串排列,会有多少呢?联想到高中的阶乘,如果用4个点做解锁图形的话,就是9x8x7x6=3024种可能性,那5个点就是15120,6个点的话60480,7个点181440,8个点362880,9个点362880。总共是985824种可能性‍‍(但这么计算并不严密,因为同一条直线上的点只能和他们相邻的点相连)‍‍。

满打满算,也不到985824种可能性。乍一看很大,但在计算机面前,穷举出来这些东西用不了几秒钟。
 
 
 

对A股上有过不诚信纪录的公司进行纪录 持续更新

股票李魔佛 发表了文章 • 0 个评论 • 2641 次浏览 • 2017-05-23 09:02 • 来自相关话题

买股票就是买公司,如果是长线持有股票,应该避开那些没有诚信,出尔反尔,有欺诈行为或者一系列损坏散户利益的个股(清仓式减持)
 
本纪录只是本人浏览公告的时候筛选出来,如果其他朋友也有看到相关公司的一些违规行为(或者你觉得这个公司不道德),也可以贴上来让我更新一下。
 
05-22 16:21    阳光股份 遭股东清仓式减持
---> http://ggjd.cnstock.com/company/scp_ggjd/tjd_ggkx/201705/4080444.htm
 
 
獐子岛: 出名了的骗子公司。 财务作假,把散户当傻子。 獐子岛上演惊天逆转 "失踪的扇贝游回来了" http://money.163.com/15/0606/05/ARDEJNT100251LJJ.html
  查看全部
买股票就是买公司,如果是长线持有股票,应该避开那些没有诚信,出尔反尔,有欺诈行为或者一系列损坏散户利益的个股(清仓式减持)
 
本纪录只是本人浏览公告的时候筛选出来,如果其他朋友也有看到相关公司的一些违规行为(或者你觉得这个公司不道德),也可以贴上来让我更新一下。
 
05-22 16:21    阳光股份 遭股东清仓式减持
---> http://ggjd.cnstock.com/company/scp_ggjd/tjd_ggkx/201705/4080444.htm
 
 
獐子岛: 出名了的骗子公司。 财务作假,把散户当傻子。 獐子岛上演惊天逆转 "失踪的扇贝游回来了" http://money.163.com/15/0606/05/ARDEJNT100251LJJ.html
 

量化交易 获取获取上市公司年报

量化交易-Ptrade-QMT李魔佛 发表了文章 • 0 个评论 • 5781 次浏览 • 2017-05-22 11:37 • 来自相关话题

http://30daydo.com/article/192
 
 tushare有一个函数, ts.get_report_data(年份,季度), 可以获取每一年的季度的业绩。

如果想要获取上市公司的年报,只要吧季度参数改为4即可 

例如 要获取 中国银行的2016年的年报

df=ts.get_report_data(2016,4)

print df[df['code']=='601988']


输出的结果如下:
 
In [4]: print df[df['code']=='601988']
        code  name   eps  eps_yoy  bvps    roe  epcf  net_profits  \
1826  601988  中国银行  0.54    -3.57  4.46  12.58   NaN   16457800.0

      profits_yoy  distrib report_date
1826        -3.67  10派1.68       04-01
 
 
  查看全部
http://30daydo.com/article/192
 
 tushare有一个函数, ts.get_report_data(年份,季度), 可以获取每一年的季度的业绩。

如果想要获取上市公司的年报,只要吧季度参数改为4即可 

例如 要获取 中国银行的2016年的年报

df=ts.get_report_data(2016,4)

print df[df['code']=='601988']


输出的结果如下:
 
In [4]: print df[df['code']=='601988']
        code  name   eps  eps_yoy  bvps    roe  epcf  net_profits  \
1826  601988  中国银行  0.54    -3.57  4.46  12.58   NaN   16457800.0

      profits_yoy  distrib report_date
1826        -3.67  10派1.68       04-01
 
 
 

证券投资基金考试

股票绫波丽 发表了文章 • 0 个评论 • 2534 次浏览 • 2017-05-21 00:45 • 来自相关话题

证券投资基金考试深圳考点在龙岗的大运软件小镇,现在觉得大运是变化好大。
证券投资基金考试深圳考点在龙岗的大运软件小镇,现在觉得大运是变化好大。

安装secureCRT7.3.4 配置公私钥远程登陆debian

Linux追着萝卜的驴 发表了文章 • 0 个评论 • 3998 次浏览 • 2017-05-20 19:00 • 来自相关话题

1.下载secureCRT安装程序与注册机;下载地址:http://download.csdn.net/detail/deng0zhaotai/9422554
(1)next;





 
(2)accept;





 
(3)Common profile;





 
(4)Custom;





 
(5)改变安装路径;





 
(6)next;





 
(7)Install;















 
(8)保持securtCRT.exe未打开的状态,打开keygen.exee,选择path;





 
(9)在secureCRT安装路径选择secureCRT.ext和LicenseHelper.exe;















 
(10)选择“Generate”更换序列;





 
(11)打开secureCRT.exe(安装完成后的快捷方式),对应位置填入内容;































(12)完成安装,打开secureCRT,选择Tool-Create Public key;











(13)选择RSA,下一步;






(14)登陆输入口令和密码,建议留空,comment默认主机名字






(15)密码长度默认;











(16)选择openSSHkey format;修改存储路径,确定为global public key;










 
(17)创建公私钥成功,后缀为pub为公钥,另外一个为私钥;





 
(18)打开虚拟机,进入终端界面,配置SSH服务(ctrl + alt + F1 可切换界面);su -




进入root用户;





 
(19)创建.ssh目录,修改该目录权限为700
     创建authorized_keys文件,修改文件权限为600或者644;
     将公钥(后缀.pub)内容拷贝到authorized_keys(可通过邮件从主机发送到虚拟机,再修改文件名字为authorized_keys)mkdir ~/.ssh
chmod 700 ~/.ssh
mv /home/osboxes/Downloads/Identity.pub ~/.ssh/authorized_keys
#(下载文件保存在主用户目录,osboxes为安装时创建的用户)
#(以上语句将公钥文件移动到~/.ssh ,并且修改名字为authorized_keys)
chmod 600 ~/.ssh/authorized_keys
cat ~/.ssh/authorize_keys
#(查看公钥内容)
ls -al ~
#(查看.ssh目录权限)
ls -al ~/.
#(查看authorized_keys权限,该文件的用户组为osboxes会导致链接失败,应该修改为root)
chown root.root ~/.ssh/authorized_keys
ls -al ~/.
#(可见文件用户组和用户已经修改为root)














 
(20)修改sshd_conf配置;vi /etc/ssh/shhd_configPermitRootLogin no # 禁止root用户登陆;
RSAAuthentication yes # 启用 RSA 认证;
AuthorizedKeysFile %h/.ssh/authorized_keys # 验证公钥的存放路径;
PubkeyAuthentication yes # 启用公钥认证;
PasswordAuthentication yes # 禁止密码认证,默认是打开的;
 
(21)回到虚拟机,修改网络连接方式,注意进入网络适配器,禁用虚拟机另外一个网络;









/etc/init.d/ssh restart
#重启ssh服务
/etc/init.d/networking restart
#重启网络服务
ifconfig
#查看虚拟机IP地址





(22)配置远程链接,打开secureCRT,Quick Connect;






(23)配置虚拟机IP地址,登陆账号,将公钥提前启动档次,选择properties;






(24)选择私钥路径,connet;






(25)回车键链接成功;





  查看全部
1.下载secureCRT安装程序与注册机;下载地址:http://download.csdn.net/detail/deng0zhaotai/9422554
(1)next;

1.png

 
(2)accept;

2.png

 
(3)Common profile;

3.png

 
(4)Custom;

4.png

 
(5)改变安装路径;

5.png

 
(6)next;

6.png

 
(7)Install;

7.png


8.png


9.png

 
(8)保持securtCRT.exe未打开的状态,打开keygen.exee,选择path;

10.png

 
(9)在secureCRT安装路径选择secureCRT.ext和LicenseHelper.exe;

11.png


12.png


13.png

 
(10)选择“Generate”更换序列;

14.png

 
(11)打开secureCRT.exe(安装完成后的快捷方式),对应位置填入内容;

15.png


16.png


17.png


18.png


19.png


20.png


(12)完成安装,打开secureCRT,选择Tool-Create Public key;

21.png


22.png


(13)选择RSA,下一步;

23.png


(14)登陆输入口令和密码,建议留空,comment默认主机名字

24.png


(15)密码长度默认;

25.png


26.png


(16)选择openSSHkey format;修改存储路径,确定为global public key;

27.png


28.png

 
(17)创建公私钥成功,后缀为pub为公钥,另外一个为私钥;

29.png

 
(18)打开虚拟机,进入终端界面,配置SSH服务(ctrl + alt + F1 可切换界面);
su -




进入root用户;

30.png

 
(19)创建.ssh目录,修改该目录权限为700
     创建authorized_keys文件,修改文件权限为600或者644;
     将公钥(后缀.pub)内容拷贝到authorized_keys(可通过邮件从主机发送到虚拟机,再修改文件名字为authorized_keys)
mkdir ~/.ssh
chmod 700 ~/.ssh
mv /home/osboxes/Downloads/Identity.pub ~/.ssh/authorized_keys
#(下载文件保存在主用户目录,osboxes为安装时创建的用户)
#(以上语句将公钥文件移动到~/.ssh ,并且修改名字为authorized_keys)
chmod 600 ~/.ssh/authorized_keys
cat ~/.ssh/authorize_keys
#(查看公钥内容)
ls -al ~
#(查看.ssh目录权限)
ls -al ~/.
#(查看authorized_keys权限,该文件的用户组为osboxes会导致链接失败,应该修改为root)
chown root.root ~/.ssh/authorized_keys
ls -al ~/.
#(可见文件用户组和用户已经修改为root)

31.png


32.png


33.png

 
(20)修改sshd_conf配置;
vi /etc/ssh/shhd_config
PermitRootLogin no # 禁止root用户登陆;
RSAAuthentication yes # 启用 RSA 认证;
AuthorizedKeysFile %h/.ssh/authorized_keys # 验证公钥的存放路径;
PubkeyAuthentication yes # 启用公钥认证;
PasswordAuthentication yes # 禁止密码认证,默认是打开的;
 
(21)回到虚拟机,修改网络连接方式,注意进入网络适配器,禁用虚拟机另外一个网络;

0.png


0.1_.png
/etc/init.d/ssh restart
#重启ssh服务
/etc/init.d/networking restart
#重启网络服务
ifconfig
#查看虚拟机IP地址

4.png


(22)配置远程链接,打开secureCRT,Quick Connect;

34.png


(23)配置虚拟机IP地址,登陆账号,将公钥提前启动档次,选择properties;

5.png


(24)选择私钥路径,connet;

6.png


(25)回车键链接成功;

8.png

 

在VirtualBox安装debian8.6系统的方法(简易版)

Linux追着萝卜的驴 发表了文章 • 0 个评论 • 4001 次浏览 • 2017-05-20 11:35 • 来自相关话题

 1.简易版,是加载由VirtualBox提供的虚拟硬盘镜像进行安装,简易而且方便,适合新手体验;
官网: http://www.osboxes.org/  安装向导: http://www.osboxes.org/guide/
根据虚拟机的软件和要安装的linux系统进行选择:
    本机使用的是VirtualBox5.0.40版本,系统是osboxes提供的debian8.6镜像;
1.1进入官网,在左上角搜索debian;





 
1.2选择最新版本的镜像8.6;





 
1.3下拉点击下载页面;





 
1.4根据虚拟机版本和电脑系统版本选择下载的镜像;
注意点:
(1)右红框为该系统的【日常用户账号,登陆密码】【管理员账号,登陆密码】;
(2)在安装完成后首次登陆系统的账号,后续可因需要个人进行修改密码;
(3)登陆需使用日常用户账号登陆,再通过“su -”命令切换至root账号;





 
1.5下载完成后,打开虚拟机进行首次安装,点击新建,弹出“新建虚拟电脑”,输入系统名称后,版本和类型会自动更换为相应的信息,如错误,可自行选择,此处输入debian;





 
1.6设定虚拟内存,设定1024就足够了;





 
1.7选择使用已有的虚拟硬盘软件,选中刚下载的“debian镜像文件,点击创建”





 
1.8设定网络链接,选中debian,点击设置,在弹出的对话框中,选中网络选项,设置为“桥接方式”,网卡为“接了网线则为有线网卡,无线则为无线网卡”,下方的接入网线必选;





 
1.9之后双击直接启动虚拟机,也可通过虚拟机的右键选择启动选项;





 
2.0以上简易版安装完毕
 

 
 
 
 
 
 
 
  查看全部
 1.简易版,是加载由VirtualBox提供的虚拟硬盘镜像进行安装,简易而且方便,适合新手体验;
官网: http://www.osboxes.org/  安装向导: http://www.osboxes.org/guide/
根据虚拟机的软件和要安装的linux系统进行选择:
    本机使用的是VirtualBox5.0.40版本,系统是osboxes提供的debian8.6镜像;
1.1进入官网,在左上角搜索debian;

1.jpg

 
1.2选择最新版本的镜像8.6;

2.png

 
1.3下拉点击下载页面;

3.png

 
1.4根据虚拟机版本和电脑系统版本选择下载的镜像;
注意点:
(1)右红框为该系统的【日常用户账号,登陆密码】【管理员账号,登陆密码】;
(2)在安装完成后首次登陆系统的账号,后续可因需要个人进行修改密码;
(3)登陆需使用日常用户账号登陆,再通过“su -”命令切换至root账号;

4.png

 
1.5下载完成后,打开虚拟机进行首次安装,点击新建,弹出“新建虚拟电脑”,输入系统名称后,版本和类型会自动更换为相应的信息,如错误,可自行选择,此处输入debian

5.jpg

 
1.6设定虚拟内存,设定1024就足够了;

6.jpg

 
1.7选择使用已有的虚拟硬盘软件,选中刚下载的“debian镜像文件,点击创建”

7.jpg

 
1.8设定网络链接,选中debian,点击设置,在弹出的对话框中,选中网络选项,设置为“桥接方式”,网卡为“接了网线则为有线网卡,无线则为无线网卡”,下方的接入网线必选;

8.jpg

 
1.9之后双击直接启动虚拟机,也可通过虚拟机的右键选择启动选项;

9.png

 
2.0以上简易版安装完毕
 

 
 
 
 
 
 
 
 

安装VirtualBox

Linux追着萝卜的驴 发表了文章 • 0 个评论 • 2929 次浏览 • 2017-05-20 10:26 • 来自相关话题

1.下载安装Virtualbox;
官网:https://www.virtualbox.org/ ; 截止文章发表的时间,目前最新的版本是5.1.2;但我下载最新版本使用时与系统有些配置出现冲突,因此退而求其次使用了5.0.40;

1.1根据自己所需要的版本进行下载,主机电脑是windows,因此下载windos版本;






1.2点击主程序进行安装,建议是一路next,只要修改安装的路径即可;






1.3修改安装路径,next;






1.4根据需要修改启动方式和快捷键,next;






1.5安装时网络会暂时中断,Yes;






1.6点击install;





 
1.7完成安装,界面如下;










 
  查看全部
1.下载安装Virtualbox;
官网:https://www.virtualbox.org/ ; 截止文章发表的时间,目前最新的版本是5.1.2;但我下载最新版本使用时与系统有些配置出现冲突,因此退而求其次使用了5.0.40

1.1根据自己所需要的版本进行下载,主机电脑是windows,因此下载windos版本;

1.png


1.2点击主程序进行安装,建议是一路next,只要修改安装的路径即可;

2.png


1.3修改安装路径,next;

3.jpg


1.4根据需要修改启动方式和快捷键,next;

4.png


1.5安装时网络会暂时中断,Yes;

5.png


1.6点击install;

6.png

 
1.7完成安装,界面如下;

7.png


8.png