def main(): target_date = get_today_as_str() result = utils.structured_data_utils.get_structed_data_from_date( target_date) result = sort_by(result, "날짜") result = filter_remove_not_equals(result, "종류", "주식") result = filter_remove_equals(result, "수량", "") first_date = str2date(get_first_date(result)) print_annual_profit_rate(result, first_date, datetime.date.today())
def get_evaluation_stock_sum(structured_data, target_date_as_string): structured_data = filter_remove_greater_than(structured_data, "날짜", target_date_as_string) # structured_data = filter_remove_equals(structured_data, "현재평가금", "") # print_data(structured_data) structured_data = sort_by(structured_data, "날짜") structured_data = sort_by(structured_data, "종목") current_evaluation = {} current_quantity = {} for idx, each in enumerate(structured_data.data): # print(structured_data.get_value_with_label(idx, "날짜")) # print(structured_data.get_value_with_label(idx, "종목")) # print(structured_data.get_value_with_label(idx, "현재평가금")) # print() name = structured_data.get_value_with_label(idx, "종목") current_price = structured_data.get_value_with_label(idx, "현재평가금") # print("current_price", current_price) if current_price: current_evaluation[name] = int(current_price) if name not in current_quantity: current_quantity[name] = 0 price = safe_int(structured_data.get_value_with_label(idx, "가격")) quantity = safe_int(structured_data.get_value_with_label(idx, "수량")) direction = safe_division(price, abs(price)) # print("direction") # print(direction) current_quantity[name] += direction * quantity # print("name", name) # print("current_quantity[name]", current_quantity[name]) evaluation_sum = 0 for idx, val in current_evaluation.items(): evaluation_sum += current_quantity[idx] * val return evaluation_sum
def main(): target_date = get_today_as_str() result = utils.structured_data_utils.get_structed_data_from_date(target_date) result = sort_by(result, "날짜") result = filter_remove_not_equals(result, "종류", "주식") result = filter_remove_equals(result, "수량", "") # result = filter_remove_not_equals(result, "종목", "아프리카TV") # result = filter_remove_not_equals(result, "종목", "시디즈") # result = filter_remove_not_equals(result, "종목", "엔에이치엔") # result = filter_remove_not_equals(result, "종목", "이마트") result = filter_remove_not_equals(result, "종목", "카카오") do_something(result, "2019-01-01", "2019-09-01")
def main(): target_date_as_string = get_today_as_str() # target_date_as_string = "2019-03-31" structured_data = structured_data_utils.get_structed_data_from_date( get_today_as_str()) structured_data = sort_by(structured_data, "날짜") for p2pname in [ "어니스트펀드", "테라펀딩", "피플펀드", "투게더", ]: print(p2pname) print_information(structured_data, target_date_as_string, "p2p", p2pname) print() # print("Total") # print_information(strcted_data, target_date_as_string, "p2p") print()
def main(): target_date = get_today_as_str() result = utils.structured_data_utils.get_structed_data_from_date( target_date) result = sort_by(result, "날짜") result = filter_remove_not_equals(result, "종류", "주식") # result = filter_remove_not_equals(result, "종목", "NAVER") # result = filter_remove_not_equals(result, "종목", "SK텔레콤") # result = filter_remove_not_equals(result, "종목", "tiger 200 it") # result = filter_remove_not_equals(result, "종목", "카카오") # result = filter_remove_equals(result, "가격", "") for idx, each_row in enumerate(result.data): each_price = safe_int(result.get_value_with_label(idx, "가격")) quantity = safe_int(result.get_value_with_label(idx, "수량")) result.data[idx][result.get_label_idx("총가격")] = each_price * quantity print(result.data[idx][result.get_label_idx("총가격")]) average_balance = get_average_balance(result, target_date) # print(average_balance) start_date_as_string = get_start_date(result) days = date_minus(target_date, start_date_as_string) current_profit = get_stock_profit(result, target_date) annual_interest_rate = get_annual_interest_rate(current_profit, average_balance, days) print_profits(average_balance=average_balance, current_profit=current_profit, start_date=start_date_as_string, target_date=target_date, days=days, annual_interest_rate=annual_interest_rate)
def get_start_date(structured_data): assert isinstance(structured_data, StructuredData) assert len(structured_data.data) > 0 structured_data = sort_by(structured_data, "날짜") return structured_data.get_value_with_label(0, "날짜")
def get_first_date(structured_data): structured_data = sort_by(structured_data, "날짜") return structured_data.get_value_with_label(0, "날짜")