Пример #1
0
 def generateId(self):
     last_id = self.getLastId()
     # check if year is current
     if date.today().strftime("%y") == last_id[0:2]:
         job_id = eval(last_id) + 1
     else:
         job_id = eval(date.today().strftime("%y")) + ('001')
Пример #2
0
def GetSWexponent(ExponentID=None,BeginTime=None,EndTime=None):
    if(ExponentID==None):
        print("沒有传入申万之一指数代码,数据将返回所有申万一级指数的数据")
        ExponentID = '801010.SI,801020.SI,801030.SI,\
                     801040.SI,801050.SI,801080.SI,801110.SI,\
                     801120.SI,801130.SI,801140.SI,801150.SI,\
                     801160.SI,801170.SI,801180.SI,801200.SI,\
                     801210.SI,801230.SI,801710.SI,801720.SI,\
                     801730.SI,801740.SI,801750.SI,801760.SI,\
                     801770.SI,801780.SI,801790.SI,801880.SI,\
                     801890.SI'
    if(BeginTime==None):
        BeginTime = '2010-01-01'
        
    if(EndTime==None):
        EndTime=date.today();
    
    tmp = (ExponentID,'close',BeginTime,EndTime,'Fill=Previous')
    data = w.wsd(*tmp)
    
    Value = []
    for i in range(0,len(data.Codes)):
        for j in range(0,len(data.Data[0])):
            value = data.Data[i][j];
            if isnan(value):
                value=0.0
            Value.append((str(data.Codes[i]),data.Times[j].strftime("%Y-%m-%d"),str(value)))
    for n in Value:
        print(n)
    return Value
Пример #3
0
def getDowAlbumName(albumLink):
    albumReader = urlopen(albumLink);
    albumSoup = BeautifulSoup(albumReader, "html.parser");
    albumNameElm = albumSoup.find("span", { "class" : "red" });
    if (albumNameElm != None) :
        return "{} [{}]".format(albumNameElm.string.strip(), str(date.today().year));
    return None
Пример #4
0
def todolist(request, interval='all'):

    assert isinstance(request, HttpRequest)

    if request.method == 'GET' and 'search' in request.GET:
        search = request.GET['search']
        if not search:
           tasks = {}
        else:
           tasks = Task.objects.filter(Q(name__icontains=search) |
                                       Q(description__icontains=search) |
                                       Q(date__icontains=search))
        return render(request,
                      'app/todolist.html',
                      {
                          'title': 'ToDoList',
                          'year':datetime.now().year,
                          'message': "Hello",
                          'tasks': tasks,
                      })

    now = date.today()
    step = request.GET.get('step', timedelta(days=1))
    tasks = False
    gap = now
    if interval == 'today':
        gap = now
    elif interval == 'tomorrow':
        now += timedelta(days=1)
        gap = now
    elif interval == 'week':
        gap = now + timedelta(days=7)
    elif interval == 'month':
        gap = now + timedelta(days=31)
    elif interval == 'year':
        gap = now + timedelta(days=365)
    else:
        tasks = Task.objects.all()

    if not tasks:
        currentDay = str(now.year) + '-' + str(now.month) + '-' + str(now.day)
        nextDay = str(gap.year) + '-' + str(gap.month) + '-' + str(gap.day)
        tasks = Task.objects.filter(date__range=[currentDay, nextDay])

    return render(
        request,
        'app/todolist.html',
        {
            'title': 'ToDoList',
            'year':datetime.now().year,
            'message': "Hello",
            'tasks': tasks,

        }
    )
Пример #5
0
 def setDates():
     currentDate = date.today()
     ui.EstStartDay_date.setDate(currentDate)
     ui.DepositDate_date.setDate(currentDate)
     ui.StartDate_date.setDate(currentDate)
     ui.PlanCheckReturn_date.setDate(currentDate)
     ui.EngDeadline_date.setDate(currentDate)
     ui.DftDeadline_date.setDate(currentDate)
     ui.PlanCheck_date.setDate(currentDate)
     ui.EngRevision_date.setDate(currentDate)
     ui.DftRevision_date.setDate(currentDate)
     ui.FinalDeadline_date.setDate(currentDate)
Пример #6
0
def ExponentScale(fundid=None, begintime='2010-01-01', endtime=date.today()):
    if(fundid == None):
        fundid = FundID()
        
    param = (fundid, 'prt_totalasset', begintime, endtime, 'Period=Q', 'Fill=Previous')
    data = w.wsd(*param)
    Value = []
    for i in range(0, len(data.Codes)):
        for j in range(0, len(data.Data[0])):
            stockvalue = data.Data[i][j]
            print(stockvalue)
            if(stockvalue is None or isnan(stockvalue)):
                stockvalue = 0.0
            record = (data.Codes[i], data.Times[j].strftime("%Y-%m-%d"), stockvalue)
            print(record)
            Value.append(record)
            
    return Value
Пример #7
0
def IndustryConfiguration(fundid=None, industry=None, begintime='2010-01-01', endtime=date.today()):
    if(fundid == None):
        print("没选择基金,默认为全部基金")
        fundid = FundID()
        
    if(industry == None):
        print("未选择行业,默认为全部19个新证监会行业指标")
        industry = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,15,16, 17, 18, 19]

    Value = []
    for k in range(0, len(industry)):
        param = (fundid, 'prt_stockvalue_industrytoasset2', begintime, endtime,
                 'industry=' + str(industry[k]), 'Period=Q', 'Fill=Previous')
        data = w.wsd(*param)
        
        if(data.ErrorCode != 0):
            print("Wind  Error")
            
        for i in range(0, len(data.Codes)):
            for j in range(0, len(data.Data[0])):
                value = data.Data[i][j]
                if(value is None or isnan(value)):
                    value = 0.0
                record = (data.Codes[i], data.Times[j].strftime("%Y-%m-%d"), industry[k], value)
                Value.append(record)
    return Value
Пример #8
0
def validate_warranty_date(value):
    if value <= date.today():
        raise ValidationError('Дата гарантии должна быть больше сегодняшней даты.')
Пример #9
0
def validate_date_naklad(value):
    if value > date.today():
        raise ValidationError('Нельзя указать дату накладной больше сегодняшней')
    elif value < date(1970, 1, 1):
        raise ValidationError('Дата накладной должна быть старше 1 января 1970')
Пример #10
0
 def activate(self, date_str, date_bool = False):
     if date_bool != False:
         self.date = datetime.strptime(date_str, '%m/%d/%Y')
     else:
         self.date = date.today()
         self.job_id = self.generateId(date_str)