ImportstructImportSQLAlchemyImportPandasImportMatplotlib.pyplot as Plot fromMatplotlib.financeImportCANDLESTICK_OHLC as Drawkengine= Sqlalchemy.create_engine ('Mssql+pyodbc://sa:[email protected]') 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= [] forIinchRange (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, one), title ='Volume') F3.bar (I, V, color='C', Edgecolor ='C') Plot.grid (True) Plot.axis ('Tight') plot.show ()
Python Socket Programming Six: multi-window applications