Exemple #1
0
# -*- coding: utf8 -*-
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from quantdigger.indicators.common import MA
from quantdigger.datasource.data import csv2frame

# 创建画布
fig, ax = plt.subplots()
# 加载数据
price_data = csv2frame("IF000.SHFE-10.Minute.csv")
# 创建平均线
ma10 = MA(None, price_data.close, 10, 'MA10', 'y', 2)
ma20 = MA(None, price_data.close, 60, 'MA10', 'b', 2)
# 绘制指标
ma10.plot(ax)
ma20.plot(ax)
plt.show()
Exemple #2
0
##ax.grid(True)

## rotates and right aligns the x labels, and moves the bottom of the
## axes up to make room for them
##fig.autofmt_xdate()

#plt.show()

import numpy
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import Formatter

from quantdigger.datasource.data import csv2frame

r = csv2frame("IF000.SHFE-10.Minute.csv")


class MyFormatter(Formatter):
    #def __init__(self, dates, fmt='%Y-%m-%d'):
    # 分类 --format
    def __init__(self, dates, fmt='%m-%d %H:%M'):
        self.dates = dates
        self.fmt = fmt

    def __call__(self, x, pos=0):
        'Return the label for time x at position pos'
        ind = int(round(x))
        if ind >= len(self.dates) or ind < 0: return ''

        return self.dates[ind].strftime(self.fmt)
Exemple #3
0
## axes up to make room for them
##fig.autofmt_xdate()

#plt.show()




import numpy
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import Formatter

from quantdigger.datasource.data import csv2frame

r = csv2frame("IF000.SHFE-10.Minute.csv")


class MyFormatter(Formatter):
    #def __init__(self, dates, fmt='%Y-%m-%d'):
    # 分类 --format
    def __init__(self, dates, fmt='%m-%d %H:%M'):
        self.dates = dates
        self.fmt = fmt

    def __call__(self, x, pos=0):
        'Return the label for time x at position pos'
        ind = int(round(x))
        if ind>=len(self.dates) or ind<0: return ''

        return self.dates[ind].strftime(self.fmt)