Python socket编程之六:多窗口的应用

import struct
import sqlalchemy
import pandas
import matplotlib.pyplot as Plot
from matplotlib.finance import candlestick_ohlc as Drawk

Engine = sqlalchemy.create_engine('mssql+pyodbc://sa:123456@XiTongDSN')
Dataframe = pandas.read_sql('sh', Engine)

I = list(Dataframe['date'].index)
O = Dataframe['open']
H = Dataframe['high']
L = Dataframe['low']
C = Dataframe['close']
V = Dataframe['volume']
Quotes = []
for i in range(0, len(I)):
    Quotes.append((I[i], O[i], H[i], L[i], C[i], V[i]))
    
figure = Plot.figure('Made by DengChaohai')

f1 = figure.add_subplot(3, 4, (1, 7), title = 'Index of Shanghai')
Drawk(f1, Quotes, colorup='g', colordown='r')
Plot.grid(True)
Plot.axis('tight')

f2 = figure.add_subplot(1, 4, 4, title = 'Quotes')
f2.text(0.2, 0.8, 'Bid2', color = 'g')
f2.text(0.2, 0.6, 'Bid1', color = 'g')
f2.text(0.2, 0.4, 'Ask1', color = 'r')
f2.text(0.2, 0.2, 'Ask2', color = 'r')
Plot.grid(True)

f3 = figure.add_subplot(3, 4, (9, 11), title = 'Volume')
f3.bar(I, V, color = 'c', edgecolor = 'c')
Plot.grid(True)
Plot.axis('tight')
Plot.show()

made_by_dengchaohai

posted @ 2016-06-02 19:33  佩雷尔曼的信徒  阅读(396)  评论(0编辑  收藏  举报