Plot Financial Data Using Matplotlib (super basic)

import libraries

In order to plot the data, we need to import libraries for dataframe and plot, also set plot inline if you’re using a notebook.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

plot stock price

Code is super simple, you just need to set the index of the dataframe to timestamp. If you find the figure to small, use pylab to set the figure size.

from pylab import rcParams
rcParams['figure.figsize'] = 50,13
apple_data = market_train_df[market_train_df['assetCode'] == 'AAPL.O']
apple_data.set_index('time')['close'].plot(grid = True)

compare multiple plots

Then I’m trying to sanitize the data by looking at the figure it self, I want to plot all suspicious assets.

for code in suspicious_asset_code:
    apple_data = market_train_df[market_train_df['assetCode'] == code]
    apple_data.set_index('time')['close'].plot(grid = True)

This only gives me one figure with all assets, it’s ugly. I want to plot them one by one.

Subplot will give you figures put up together, use

# treat the whole figure as a grid, specify how many rows and columns you wanna plot and the index of the current sub plot
fig.add_subplot(row, columns, index)

Then you’ll get graphs all together to detect abnormal data.

Configure Mailgun settings in Rails app

Recently I’m learning to create a Rails 5 api only application with an android mobile application. I want to send a activation email after user registered from the android app, and I found there is a free Mailgun add-on on Heroku. It’s perfect choice to start to play with because you can send up to 100 messages/hour without being charged. The documentation is good enough but I do found several steps confusing.

Firstly, you need to create a Mailgun account and add your credit card information, otherwise you can’t send to recipents other than authorized ones(which means test only).

Then, use the test domain( to ensure Mailgun not being blocked by your test mail address(In my case I use qq mail at first, it actually blocks all traffic from mailgun). After that, you need to add a custom domain. Go to your domain name provider and configure DNS settings as following the steps of Mailgun instructions. In my case I use Namecheap and it took me a while(a cup of coffee) for Mailgun to verify my domain.

After your custom domain is active, configure your development environment and make sure it works. In my case I use smtp instead of api call, the settings are for example:

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
	:address => "",
	:port => 587,
	:domain =>',
	:user_name => "",
	:password => XXXX

Then start your rails server and see if the mail was delivered. I spent quite a few hours here because at first my emails weren’t delivered. I refered to the log and showed Mailgun accepted the mail address, and one minute later a ESP throttling message showed up. The reason is Mailgun being blocked by certain ISP(like qq mail, in this case I have to use an extra mail hosting service), so I couldn’t see any mail sent inbox.

If OK in development environemnt, change your production settings as well, it should work as well.




shadowsocks的安装有两种方法,一是安装shadowsocks-qt5 GUI版,二是通过终端运行shadowsocks。我试过了第一种GUI安装,但是一直连不上服务器,发现输出的json配置文件格式是错误的,于是选择了第二种, 具体步骤如下:

1. 下载shadowsocks

sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python-setuptools m2crypto
pip install shadowsocks

2. 设置配置文件

"password":"your password",

3. 启动shadowsocks

sslocal -c /your/path/shadowsocks.json


INFO: loading config from /home/momoko/shadowsocks/ss-config.json
2016-12-06 19:31:54 INFO     loading libcrypto from
2016-12-06 19:31:54 INFO     starting local at

4. 设置浏览器


我使用的浏览器是Ubuntu下的Chromium,chrome插件本来可以在chrome商店里下载到,成功翻墙之前是进不去的。这里推荐从github上下载SwitchyOmega,里面有中文下载说明, 网址如下:


下载结束之后需要设置代理选项,情景模式里选socks 5, 端口号1080,其余设置参考上述链接。

打开youtube或是facebook测试一下,有点小惊喜呢。┌ ≧∇≦

5. Attention

值得注意的是,虽然浏览器可以翻墙了,但是用终端访问比如curl 还是没有响应,这里需要安装额外的插件,我使用的是proxychains4,具体安装方法请自行搜索。如果你运行的是例如polipo全局代理的插件,在终端运行某些命令会失败(比如说git clone),这时候暂时关掉代理插件即可。

什么?不会安装?浏览器都能翻墙了还不谷歌一下。 ( ̄▽ ̄人)) ((人 ̄▽ ̄)


へ( ̄ ̄へ)(ノ ̄ ̄)ノ パラパラ♪


Troubleshooting with Installing Broadcom Wireless Drivers in Ubuntu Desktop

Days before, I changed the operating system of my old laptop from Windows7 to Ubuntu Desktop, I installed Ubuntu from a USB stick from my friend. After installing I found I Broadcom wireless driver wasn’t installed so I couldn’t connect to my WiFi. I tried several ways then found the solution, hope it my be helpful.

To download the driver from Internet, you need to connect with Ethernet.

Open Software and Update from system and configuration, open the fifth tab optional drivers and see if wireless driver comes out or not.

Make sure allowing downloading drivers from Internet is checked in the first tab Ubuntu Software.

If it still doesn’t come out, you need to manually install it from terminal, use lspci -nn -d 14e4: command to see which network card you’re using, then install the corresponding driver. offers an excellent guide.

My Experience And Thoughts on Remote Working as A Junior Programmer

About Me And My Job

I started my current job a year ago when I was an exchange student in Japan, I was second year in university then. I worked in the office for 9 months, after that my exchange year ended, I went back to my home university and started remote working since then. Until now, it has been half year.

I rent an apartment and lived alone near my university. I’m not full-time employed, I worked for about 5 hours a day, every day in the week because I found this schedule suits me better. When I’m not working, I go to classes, playing the piano or reading books.

My Half Year on Remote Working

good parts

The best part of remote working is much more free time. I don’t have to wake up early and spend hours on a crowded subway to the office, I could spend more time on doing whatever I want to do.

Also for me, working from home is easier to concentrate because there are fewer distractions.

My desktop and my friends o(●´ω`●)oわくわく♪

challenges for a junior programmer

For me, the biggest challenge is finding out the solution to the problem independently. As a junior developer, I don’t have much experience, when I encounter a problem that appears for the first time, it’s hard to get response from my colleges immediately, more often, I have to find out how to handle it by myself, sometimes it’s quite hard because I really don’t know what to do with it, and have to dig really deep on the problem.

The second is about confirming specification. When I just started remote working, it’s quite often to get confused with specification in junior year, and confirming specification online usually takes more time than face to face, and I have to make sure my colleges are available at that time.

Another challenge is about building up habits. For me, I don’t have a fixed working schedule, sometimes I find it hard to get myself backing to working from the lure of reading Reddit or watching Youtube videos. It needs self-discipline to keep myself from slacking off.

mental challenges

It’s easy to feel emotionally detached with other people. Since I live alone, and my colleges are all in another country, I feel lonely from time to time. I can’t keep being productive if I feel lonely. It’s not healthy to keep sitting in front of a desktop for all day, going out and networking is also important.

My Thinkings

I loved my current living style. I can get my work done and do whatever I want to do. For me, it’s not easy at first, half year later, I enjoy more and more.

programming ( 13 )
中文 ( 2 )
language-learning ( 1 )
life ( 1 )
python ( 1 )
aws ( 2 )
study-note ( 2 )

About Me

I'm Yiwen, a web developer based in Tokyo, and I'm looking forward to opportunities in a international environment.