def __init__(self, stock): QuoteListener.__init__(self, 'Saver') self.stockid = stock self.filename = stock + time.strftime('%Y%m%d.csv',time.localtime(time.time())) self.outfile = open(self.filename, 'a+') self.outfile.write(QuoteData.csvHead()) self.outfile.close()
def __init__(self, stock): QuoteListener.__init__(self, 'Saver') self.stockid = stock self.filename = stock + time.strftime('%Y%m%d.csv', time.localtime(time.time())) self.outfile = open(self.filename, 'a+') self.outfile.write(QuoteData.csvHead()) self.outfile.close()
def testQuoteDiffValuesInformer(): inform = QuoteDiffValuesInformer('510050', [-0.009,-0.019,-0.029], [0.009, 0.019, 0.029], '10.0') qd = QuoteData() qd.id = '510050' qd.lastPrice = '10.0' qd.preClose = '10.0' qd.lowPrice = '0' qd.highPrice = '0' for v in ['10.001', '10.010', '10.020', '10.030', '10.040', '9.990', '9.980', '9.970', '9.960', '10.0']: qd.lastPrice = v inform.OnRecvQuote(qd) sleep(3)
def testQuoteDiffValuesInformer(): inform = QuoteDiffValuesInformer('510050', [-0.009, -0.019, -0.029], [0.009, 0.019, 0.029], '10.0') qd = QuoteData() qd.id = '510050' qd.lastPrice = '10.0' qd.preClose = '10.0' qd.lowPrice = '0' qd.highPrice = '0' for v in [ '10.001', '10.010', '10.020', '10.030', '10.040', '9.990', '9.980', '9.970', '9.960', '10.0' ]: qd.lastPrice = v inform.OnRecvQuote(qd) sleep(3)
QuoteListener.__init__(self, 'Saver') self.stockid = stock self.filename = stock + time.strftime('%Y%m%d.csv',time.localtime(time.time())) self.outfile = open(self.filename, 'a+') self.outfile.write(QuoteData.csvHead()) self.outfile.close() def OnRecvQuote(self, quoteData): if cmp(self.stockid, quoteData.id) == 0 : self.outfile = open(self.filename, 'a+') self.outfile.write(quoteData.toCSVString()) self.outfile.close() #def testQuoteSaveToCSV(): if __name__ == '__main__': d = QuoteData() d.name = "ETF300" d.id = "510300" d.lastPrice = "2.130" d.preClose = "2.108" d.openPrice = "2.084" d.lowPrice = "2.078" d.highPrice = "2.160" d.date = "2014-04-03" d.time = "15:05:03" inform = QuoteSaveToCSV("510300") inform.OnRecvQuote(d) d.lastPrice = "2.530" inform.OnRecvQuote(d); sleep(5) d.lastPrice = "1.981"
self.filename = stock + time.strftime('%Y%m%d.csv', time.localtime(time.time())) self.outfile = open(self.filename, 'a+') self.outfile.write(QuoteData.csvHead()) self.outfile.close() def OnRecvQuote(self, quoteData): if cmp(self.stockid, quoteData.id) == 0: self.outfile = open(self.filename, 'a+') self.outfile.write(quoteData.toCSVString()) self.outfile.close() #def testQuoteSaveToCSV(): if __name__ == '__main__': d = QuoteData() d.name = "ETF300" d.id = "510300" d.lastPrice = "2.130" d.preClose = "2.108" d.openPrice = "2.084" d.lowPrice = "2.078" d.highPrice = "2.160" d.date = "2014-04-03" d.time = "15:05:03" inform = QuoteSaveToCSV("510300") inform.OnRecvQuote(d) d.lastPrice = "2.530" inform.OnRecvQuote(d) sleep(5) d.lastPrice = "1.981"