예제 #1
0
def PR_UpdateDailyQuotation(H5Db,
                            start_datecode,
                            end_datecode=DayCode().today(),
                            DEBUG=False):
    DailyQ_twse = Web_TwseDailyQuotation(H5Db)
    DailyQ_tpex = Web_TpexDailyQuotation(H5Db)

    daycode = DayCode().copy_from(start_datecode)

    while daycode.to_int() <= end_datecode.to_int():
        #info
        percentage = 100 * (daycode.to_int() - start_datecode.to_int()) / (
            end_datecode.to_int() - start_datecode.to_int())
        print("\n\n\n===>Progress: %s/[%s-%s] (%d%%).....\n" %
              (daycode, start_datecode, end_datecode, percentage))

        #上市行情
        stock_dq = DailyQ_twse.get_data(daycode, DEBUG)
        H5Db.update_daily_quotation(stock_dq)

        #上櫃行情
        stock_dq = DailyQ_tpex.get_data(daycode, DEBUG)
        H5Db.update_daily_quotation(stock_dq)

        #Advance one day
        daycode.go_next_day()
예제 #2
0
    def testCalendar(self):
        d = DayCode(2016, 9, 27)

        while d.to_int() < 20181107:
            print(d.go_next_day())

        while d.to_int() > 20170215:
            print(d.go_prev_day())

        print(d.today())
예제 #3
0
def PR_UpdateDailyQuotation(H5Db, start_datecode, end_datecode = DayCode().today(), DEBUG=False):
    DailyQ_twse = Web_TwseDailyQuotation(H5Db)
    DailyQ_tpex = Web_TpexDailyQuotation(H5Db)
    
    daycode = DayCode().copy_from( start_datecode )
    
    while daycode.to_int() <= end_datecode.to_int():
        #info
        percentage = 100*(daycode.to_int() - start_datecode.to_int()) / (end_datecode.to_int() - start_datecode.to_int())
        print("\n\n\n===>Progress: %s/[%s-%s] (%d%%).....\n" % (daycode, start_datecode, end_datecode, percentage ) )
    
        #上市行情
        stock_dq = DailyQ_twse.get_data(daycode, DEBUG)
        H5Db.update_daily_quotation(stock_dq)
        
        #上櫃行情
        stock_dq = DailyQ_tpex.get_data(daycode, DEBUG)
        H5Db.update_daily_quotation(stock_dq)
        
        #Advance one day
        daycode.go_next_day()