Beispiel #1
0
def crawStockDailyTrade(date):
    l = StockService.getAllFailedDailyTradeStockBaseModels(date)
    print l
    maxLoops = 1
    while len(l) > 0 and maxLoops > 0:
        for model in l:
            StockCrawlerService.fetchStockTradeInfoFromInternet(model, date)

        l = StockService.getAllFailedDailyTradeStockBaseModels(date)
        maxLoops = maxLoops - 1
Beispiel #2
0
def crawStockDaily(date):
    l = StockService.getAllFailedDailyStockBaseModels(date)
    maxLoops = 2
    while len(l) > 0 and maxLoops > 0:
        for model in l:
            StockCrawlerService.fetchDailyStockModelFromInternet(model)

        l = StockService.getAllFailedDailyStockBaseModels(date)

        maxLoops = maxLoops - 1
Beispiel #3
0
	def fetchAllStockCategoryRelationsFromInternet():
		"""从东方财富网抓取所有股票所属的板块"""
		dict = {}
		categories = StockService.getAllStockCategoryModels()
		for category in categories:
			dict[category.categoryName.encode('utf-8')] = category

		stocks = StockService.getAllStockBaseModels()
		for stock in stocks:
			l = StockCrawlerService.fetchStockCategoryRelationsFromInternet(stock)
			for s in l:
				category = dict.get(s)
				if category:
					StockStorage.saveStockCategoryRelation(stock, category)
					pass
				else:
					logger.info('%s no category fetched' % (stock.stockCode))
Beispiel #4
0
	def fetchAllStockCategoryRelationsFromInternet():
		"""从东方财富网抓取所有股票所属的板块"""
		dict = {}
		categories = StockService.getAllStockCategoryModels()
		for category in categories:
			dict[category.categoryName.encode('utf-8')] = category

		stocks = StockService.getAllStockBaseModels()
		for stock in stocks:
			l = StockCrawlerService.fetchStockCategoryRelationsFromInternet(stock)
			for s in l:
				category = dict.get(s)
				if category:
					StockStorage.saveStockCategoryRelation(stock, category)
					pass
				else:
					logger.info('%s no category fetched' % (stock.stockCode))
Beispiel #5
0
#encoding: utf-8

import sys

reload(sys)
sys.setdefaultencoding('utf-8')

from services.stock.StockService import StockService
from services.stock.StockCrawlerService import StockCrawlerService
from models.stock.StockBaseModel import StockBaseModel
from models.stock.StockModel import StockModel

if __name__ == '__main__':
    # StockCrawlerService.fetchAllStockBaseModelsFromInternet()

    # StockCrawlerService.fetchAllStockCategoryModelsFromInternet()

    l = StockService.getAllStockBaseModels()
    for model in l:
        StockCrawlerService.fetchDailyStockModelFromInternet(model)

    l = StockService.getAllStockBaseModels()
    for model in l:
        StockCrawlerService.fetchStockTradeInfoFromInternet(model)

    # stockBaseModel = StockBaseModel(62, '502000', '', 'sh')
    # StockCrawlerService.fetchDailyStockModelFromInternet(stockBaseModel)
Beispiel #6
0
#encoding: utf-8

import sys

reload(sys)
sys.setdefaultencoding('utf-8')

from services.stock.StockService import StockService
from services.stock.StockCrawlerService import StockCrawlerService
from models.stock.StockBaseModel import StockBaseModel
from models.stock.StockModel import StockModel

if __name__ == '__main__':
	# StockCrawlerService.fetchAllStockBaseModelsFromInternet()

	# StockCrawlerService.fetchAllStockCategoryModelsFromInternet()

	l = StockService.getAllStockBaseModels()
	for model in l:
		StockCrawlerService.fetchDailyStockModelFromInternet(model)

	l = StockService.getAllStockBaseModels()
	for model in l:
		StockCrawlerService.fetchStockTradeInfoFromInternet(model)

	# stockBaseModel = StockBaseModel(62, '502000', '', 'sh')
	# StockCrawlerService.fetchDailyStockModelFromInternet(stockBaseModel)