Beispiel #1
0
def save_png(df, code):
    meta = get_stock_meta(code)
    if not meta:
        print("Can't get stock(%s) meta..." % code)
        return
    industry_dir = 'png/%s' % meta['industry']
    if not os.path.exists(industry_dir):
        os.makedirs(industry_dir)
    pngpath = 'png/%s/%s.png' % (meta['industry'], code)
    if os.path.exists(pngpath):
        print("%s already exists..." % pngpath)
        return
    title = u'%s(%s)' % (meta['name'], code)
    end = datetime.datetime.now()
    start = end - datetime.timedelta(days=500)
    start_idx = int(start.strftime("%Y%m%d"))
    end_idx = int(end.strftime("%Y%m%d"))
    fig = plt.figure(facecolor='white')
    ax1 = fig.add_subplot(211)
    ax2 = fig.add_subplot(212)
    stocklib.draw_ma(ax1, df, title=title, start=start_idx, end=end_idx)
    stocklib.draw_k(ax2, df, title=title, start=start_idx, end=end_idx)
    # plt.show()
    fig.savefig(pngpath)
    plt.close()
Beispiel #2
0
def show(df):
    fig = plt.figure(facecolor='white')
    ax1 = fig.add_subplot(211)
    ax2 = fig.add_subplot(212)
    stocklib.draw_ma(ax1, df, start=20150101)
    stocklib.draw_k(ax2, df, start=20150101)
    plt.show()
Beispiel #3
0
#-*-coding:utf-8-*-

import sys
import pandas as pd
import numpy as np
import os

import datetime
import numpy as np
import matplotlib.colors as colors
import matplotlib.finance as finance
import matplotlib.dates as mdates
import matplotlib.ticker as mticker
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager

import stocklib

if __name__ == "__main__":
    csvpath = 'sh999999.csv'
    df = pd.read_csv(csvpath, index_col=0)
    df['date'] = pd.to_datetime(df['date'], format='%Y%m%d')
    ax = plt.gca()
    # stocklib.draw_k(ax, df, with_money=False)
    stocklib.draw_ma(ax, df)
    #plt.show()
    plt.savefig('1.png')
    

Beispiel #4
0
def show_ma(df):
    fig = plt.figure(facecolor="white")
    ax1 = fig.add_subplot(111)
    stocklib.draw_ma(ax1, df)
    plt.show()
Beispiel #5
0
def show_ma(df):
    fig = plt.figure(facecolor='white')
    ax1 = fig.add_subplot(111)
    stocklib.draw_ma(ax1, df, cycle=df.shape[0], line_cnt=200, start=20100101)
    plt.show()