Exemplo n.º 1
0
def start_main():
    data = common_lib.open_file(common_lib.NBA_STANDING_HTML_FILE)
    data = get_all_expanded_standings(data)

    while data.find('<a href="/teams/') > 0:
        data = parse_data_get_true_pct(data)

#########################
#    while data.find('<td class="team">') > 0:
 #       data = parse_html_file(data)
#########################

    thisList = common_lib.convert_list_into_str(list_of_team_stats.listOfTeamStats)
    common_lib.write_file(thisList, common_lib.NBA_STANDING_CSV_FILE)
Exemplo n.º 2
0
def start_main():
    data = common_lib.open_file(common_lib.NBA_STANDING_HTML_FILE)
    data = get_all_expanded_standings(data)

    while data.find('<a href="/teams/') > 0:
        data = parse_data_get_true_pct(data)

#########################
#    while data.find('<td class="team">') > 0:
#       data = parse_html_file(data)
#########################

    thisList = common_lib.convert_list_into_str(
        list_of_team_stats.listOfTeamStats)
    common_lib.write_file(thisList, common_lib.NBA_STANDING_CSV_FILE)
def get_statements_to_csv(stockFileDir, ticker):
    #print("in get_statements_to_csv")
    if ticker != 'Symbol':
        if(flagLastPriceClass.flagLastPrice == True):
            get_last_price_to_csv(ticker)
        elif(flagLastPriceClass.flagLastPrice == False):
            get_last_price_to_csv(ticker)
            time.sleep(1)
            get_everything_else(ticker)
            # I separated get_last_price_to_csv() from get_everything_else to allow commenting out get_everything_else,
            #   because balance sheets, income statements and cashflow statements doesn't change everyday,
            #   but the last price does. It would be faster this way.

        # Parse csv files
        readStr = common_lib.open_file(stockFileDir + ticker + " " + "Income" + " " + "Quarterly" + ".csv")
        readStr = parse_statements(readStr)
        common_lib.write_file(readStr, stockFileDir + ticker + " " + "Income" + " " + "Quarterly" + ".csv")

    #        ttmList = get_col_ttm(stockFileDir + ticker + " " + "Income" + " " + "Quarterly" + ".csv")
    #        print(ttmList)
    return
Exemplo n.º 4
0
def start_main():
    list2 = []
    finalList = []

    theList = common_lib.get_multiple_col(NBA_POWER_RANKING_CSV_FILE, 0, 1, 2,
                                          3, 4)

    i = 0
    while i < len(theList):
        teamName = common_lib.parse_the_popped_element_to_return_str(
            theList.pop())
        roadWin = common_lib.parse_the_popped_element_to_return_str(
            theList.pop())
        homeLoss = common_lib.parse_the_popped_element_to_return_str(
            theList.pop())
        pct = common_lib.parse_the_popped_element_to_return_str(theList.pop())
        truePct = common_lib.parse_the_popped_element_to_return_str(
            theList.pop())
        list2.append([teamName, roadWin, homeLoss, pct, truePct])

    # Add column 'PCT_GAP', 'TIER', and 'LABEL' onto header
    list2.reverse()
    header = list2.pop()
    header.append('PCT_GAP')
    header.append('TIER')
    header.append('LABEL')
    header.append('PROJECTION')
    finalList.append(header)

    # Evaluates team's TRUE_PCT to find PCT_GAP, TIER, and LABEL

    # Set initial values up for looping
    length = len(list2)
    tier = 0
    letterTier = chr(
        tier + ord('A'))  # Converts the int to corresponding english alphabet
    labelProjeTuple = assign_label_and_projection_to_tier(letterTier)
    element1 = list2.pop()
    element1.append('0')
    element1.append(str(letterTier))
    element1.append(str(labelProjeTuple[0]))
    element1.append(str(labelProjeTuple[1]))
    list2.append(element1)
    for i in range(length):
        #    for i in range(0,1):
        try:
            # Grab two elements from the list
            element1 = list2.pop()
            element2 = list2.pop()
        except IndexError:
            finalList.append(element2)
            break
        else:
            # Get PCT_GAP
            floatTruePct1 = float(element1[4])
            floatTruePct2 = float(element2[4])
            pctGap = (floatTruePct1 / floatTruePct2) - 1

            # Get TIER
            if pctGap > PCT_GAP_CUTOFF:
                tier += 1
                letterTier = chr(tier + ord('A'))

            # Assign LABEL to corresponding TIER
            labelProjeTuple = assign_label_and_projection_to_tier(letterTier)

            element2.append(str(pctGap))
            element2.append(str(letterTier))
            element2.append(str(labelProjeTuple[0]))
            element2.append(str(labelProjeTuple[1]))
            finalList.append(element1)
            list2.append(element2)

    finalList = common_lib.convert_list_into_str(finalList)
    common_lib.write_file(finalList, NBA_POWER_RANKING_CSV_FILE)
Exemplo n.º 5
0
def start_main():
    list2 = []
    finalList = []

    theList = common_lib.get_multiple_col(NBA_POWER_RANKING_CSV_FILE, 0,1,2,3,4)

    i = 0
    while i < len(theList):
        teamName = common_lib.parse_the_popped_element_to_return_str(theList.pop())
        roadWin = common_lib.parse_the_popped_element_to_return_str(theList.pop())
        homeLoss = common_lib.parse_the_popped_element_to_return_str(theList.pop())
        pct = common_lib.parse_the_popped_element_to_return_str(theList.pop())
        truePct = common_lib.parse_the_popped_element_to_return_str(theList.pop())
        list2.append([teamName, roadWin, homeLoss, pct, truePct])

    # Add column 'PCT_GAP', 'TIER', and 'LABEL' onto header
    list2.reverse()
    header = list2.pop()
    header.append('PCT_GAP')
    header.append('TIER')
    header.append('LABEL')
    header.append('PROJECTION')
    finalList.append(header)

# Evaluates team's TRUE_PCT to find PCT_GAP, TIER, and LABEL

    # Set initial values up for looping
    length = len(list2)
    tier = 0
    letterTier = chr(tier + ord('A')) # Converts the int to corresponding english alphabet
    labelProjeTuple = assign_label_and_projection_to_tier(letterTier)
    element1 = list2.pop()
    element1.append('0')
    element1.append(str(letterTier))
    element1.append(str(labelProjeTuple[0]))
    element1.append(str(labelProjeTuple[1]))
    list2.append(element1)
    for i in range(length):
#    for i in range(0,1):
        try:
            # Grab two elements from the list
            element1 = list2.pop()
            element2 = list2.pop()
        except IndexError:
            finalList.append(element2)
            break
        else:
            # Get PCT_GAP
            floatTruePct1 = float(element1[4])
            floatTruePct2 = float(element2[4])
            pctGap = (floatTruePct1 / floatTruePct2) - 1

            # Get TIER
            if pctGap > PCT_GAP_CUTOFF:
                tier += 1
                letterTier = chr(tier + ord('A'))

            # Assign LABEL to corresponding TIER
            labelProjeTuple = assign_label_and_projection_to_tier(letterTier)

            element2.append(str(pctGap))
            element2.append(str(letterTier))
            element2.append(str(labelProjeTuple[0]))
            element2.append(str(labelProjeTuple[1]))
            finalList.append(element1)
            list2.append(element2)

    finalList = common_lib.convert_list_into_str(finalList)
    common_lib.write_file(finalList, NBA_POWER_RANKING_CSV_FILE)
def start_main():
    tmpList = sort_true_pct_ranking()

    tmpList = common_lib.convert_list_into_str(tmpList)
    common_lib.write_file(tmpList, NBA_POWER_RANKING_CSV_FILE)
def save_errorList():
    dataStr = common_lib.convert_errorList_into_dataStr(errorList)
    common_lib.write_file(dataStr, common_lib.ERROR_FILE_DIR + "download_fundamental_data_errorList.txt")
    return
Exemplo n.º 8
0
def start_main():
    tmpList = sort_true_pct_ranking()

    tmpList = common_lib.convert_list_into_str(tmpList)
    common_lib.write_file(tmpList, NBA_POWER_RANKING_CSV_FILE)