Пример #1
0
def migrateUSDQuotesFromCB(start_date):
    date_delta = date.today() - datetime.date(datetime.strptime(start_date, '%d.%m.%Y'))
    quote_type = 'usd'
    count_migrate_qoutes = 0
    for i in range(0, date_delta.days):
        quote_date = (date.today() - timedelta(days=i)).__str__()
        try:
            q = Quote.objects.get(quote_date=quote_date, quote_type=quote_type)
        except Quote.DoesNotExist:
            quote_value = getUSDQuotesOnDate(quote_date)
            q = Quote(quote_value=round(float(quote_value), 4), quote_type=quote_type, quote_date=quote_date)
            q.save()
    return count_migrate_qoutes
Пример #2
0
def updateTrainFile(count_dollar_samples, count_oil_samples, train_file):
    wb = load_workbook(filename=train_file)
    ws = wb.active
    count_rows = len(ws.rows)
    ws.append(ws.rows[-1])
    for i in range(count_rows - 1, 0, -1):
        print i
        print ws.rows[i]
        for j in range(1, len(ws.rows[i])):
            ws.cell(row=i + 1, column=j).value = ws.cell(row=i, column=j).value
    dollar_today_value = getUSDQuotesOnDate(date.today().__str__())
    oil_today_value = getCurrentOilQuotes()
    wb.save('simple.xlsx')
    return 1
Пример #3
0
def updateTrainFile(count_dollar_samples, count_oil_samples, train_file):
    wb = load_workbook(filename=train_file)
    ws = wb.active
    count_rows = len(ws.rows)
    ws.append(ws.rows[-1])
    for i in range(count_rows - 1, 0, -1):
        print i
        print ws.rows[i]
        for j in range(1, len(ws.rows[i])):
            ws.cell(row=i+1,column=j).value = ws.cell(row=i,column=j).value
    dollar_today_value = getUSDQuotesOnDate(date.today().__str__())
    oil_today_value = getCurrentOilQuotes()
    wb.save('simple.xlsx')
    return 1
Пример #4
0
def makeTrainFile(train_filename, count_samples, sample_length):
    wb = Workbook()
    # grab the active worksheet
    ws = wb.active
    # Data can be assigned directly to cells
    curslist = []

    for i in range(0, count_samples):
        if len(curslist) > 0:
            curslist.pop()  # remove date
            curslist.pop(4)  # remove last day value
            start = sample_length - 1
        else:
            start = 0
        curslist.insert(5, (date.today() - timedelta(days=i + 1)).__str__())
        for j in range(start, sample_length):
            day = (date.today() - timedelta(days=j + i)).__str__()
            c = getUSDQuotesOnDate(day)
            curslist.insert(0, c)
        print curslist
        ws.append(curslist)
    # Python types will automatically be converted
    # Save the file
    wb.save(train_filename)
Пример #5
0
def makeTrainFile(train_filename, count_samples, sample_length):
    wb = Workbook()
    # grab the active worksheet
    ws = wb.active
    # Data can be assigned directly to cells
    curslist = []

    for i in range(0, count_samples):
        if len(curslist) > 0:
            curslist.pop()   # remove date
            curslist.pop(4)  # remove last day value
            start = sample_length - 1
        else:
            start = 0
        curslist.insert(5, (date.today() - timedelta(days=i+1)).__str__())
        for j in range(start, sample_length):
            day = (date.today() - timedelta(days=j+i)).__str__()
            c = getUSDQuotesOnDate(day)
            curslist.insert(0, c)
        print curslist
        ws.append(curslist)
    # Python types will automatically be converted
    # Save the file
    wb.save(train_filename)