示例#1
0
class DataManager(object):
    def __init__(self, db="stock.db"):
        self.fas = FundASpider(db)
        self.db = db

    def update_funda(self, now):
        if not self._is_daily_data_exists(now):
            self.fas.insert_funda_data()
        else:
            self.fas.update_funda_data()

    def _is_daily_data_exists(self, date_time):
        with sqlite3.connect(self.db) as conn:
            cur = conn.cursor()
            cur.execute('''select distinct date from Afund where date = ?''',
                        (str(date_time.date()), ))
            return True if cur.fetchall() else False

    def update_all_data(self):
        now = datetime.now()
        if (stockdate.is_trading_date(now) and now.hour >= 15
                or stockdate.is_trading_datetime(now)):
            self.update_funda(now)
示例#2
0
class DataManager(object):
    def __init__(self, db="stock.db"):
        self.fas = FundASpider(db)
        self.db = db

    def update_funda(self, now):
        if not self._is_daily_data_exists(now):
            self.fas.insert_funda_data()
        else:
            self.fas.update_funda_data()

    def _is_daily_data_exists(self, date_time):
        with sqlite3.connect(self.db) as conn:
            cur = conn.cursor()
            cur.execute('''select distinct date from Afund where date = ?''',
                        (str(date_time.date()),))
            return True if cur.fetchall() else False

    def update_all_data(self):
        now = datetime.now()
        if (stockdate.is_trading_date(now) and now.hour >= 15
                or stockdate.is_trading_datetime(now)):
            self.update_funda(now)
示例#3
0
 def __init__(self, db="stock.db"):
     self.fas = FundASpider(db)
     self.db = db
示例#4
0
 def __init__(self, db="stock.db"):
     self.fas = FundASpider(db)
     self.db = db