예제 #1
0
def test_board_meeting_day():

    start_date = "03-21-2019"
    stop_date = "01-01-2020"

    # dates in epoch timestamp of the dates:
    # respectively:  03-21-2019', '06-21-2019', '09-20-2019', '12-20-2019'
    # (mm:dd:yyyy format)
    ts_bmd_days = np.array(
        [1.5531264e09, 1.5610752e09, 1.5689376e09, 1.5768000e09])

    ts_gen = calc.board_meeting_day(start_date, stop_date)

    assert np.array_equal(ts_bmd_days, ts_gen)

    # checking if without declaring the second positional argument of the
    # board_meeting_day function, the function is still working
    start = datetime.strptime("01-01-2019", "%m-%d-%Y")
    today = datetime.now().strftime("%m-%d-%Y")
    today = datetime.strptime(today, "%m-%d-%Y")

    ts_date = calc.perdelta(start, today)

    # converting the perdelta-generated array of dates tu utc-timestamp
    ts_date = np.array(
        [x.replace(tzinfo=timezone.utc).timestamp() for x in ts_date])
    start = "01-01-2019"
    ts_gen = calc.board_meeting_day(start)

    assert np.array_equal(ts_date, ts_gen)
예제 #2
0
def hist_time_array_set(start_date=START_DATE):

    # define the variable containing all the date from start_date to yesterday.
    # the date are displayed as timestamp and each day refers to 12:00 am UTC
    reference_date_arr = date_gen(start_date)

    # define all the useful arrays containing the rebalance
    # start date, stop date, board meeting date
    reb_start_date = start_q(start_date)
    reb_stop_date = stop_q(reb_start_date)
    board_date = board_meeting_day()
    board_date_eve = day_before_board()
    next_reb_date = next_start()

    return (reference_date_arr, reb_start_date, reb_stop_date, board_date,
            board_date_eve, next_reb_date)
예제 #3
0
today_TS = int(today.replace(tzinfo=timezone.utc).timestamp())
y_TS = today_TS - 86400
two_before_TS = y_TS - 86400
today_human = data_setup.timestamp_to_human([today_TS])
yesterday_human = data_setup.timestamp_to_human([y_TS])
two_before_human = data_setup.timestamp_to_human([two_before_TS])

# define the variable containing all the date from start_date to today.
# the date are displayed as timestamp and each day refers to 12:00 am UTC
reference_date_vector = data_setup.date_gen(start_date)

# define all the useful arrays containing the rebalance start
# date, stop date, board meeting date
rebalance_start_date = calc.start_q("01-01-2016")
rebalance_stop_date = calc.stop_q(rebalance_start_date)
board_date = calc.board_meeting_day()
board_date_eve = calc.day_before_board()
next_rebalance_date = calc.next_start()


# call the function that creates a object containing
# the couple of quarterly start-stop date
quarterly_date = calc.quarterly_period()

# ############# MAIN PART #########################

# downloading the daily value from MongoDB and put it into a dataframe

# defining the dictionary for the MongoDB query
query_dict = {"Time": str(y_TS)}
# retriving the needed information on MongoDB
예제 #4
0
from cryptoindex.calc import (next_start, next_quarterly_period, start_q,
                              stop_q, board_meeting_day, day_before_board,
                              next_start)
from cryptoindex.index_hist import hist_time_single_date
from cryptoindex.data_setup import (timestamp_to_human)

from cryptoindex.index_func import days_variable

day = None

start_q_list = next_start()
board_eve_list = day_before_board()
board_day = board_meeting_day()
start_q = start_q()
print(start_q_list)
print(board_eve_list)
print(board_day)
print(start_q)
print(timestamp_to_human(start_q_list[1:len(start_q_list)]))

day_TS, _ = days_variable(day)
# day_TS = day_TS + 86400
print(day_TS)

if day_TS in start_q_list:

    print("First day of the quarter")

elif day_TS in board_eve_list:

    print("Board day")
today = datetime.strptime(today_str, "%Y-%m-%d")
today_TS = int(today.replace(tzinfo=timezone.utc).timestamp())
y_TS = today_TS - DAY_IN_SEC

# # define end date as as MM-DD-YYYY
# end_date = datetime.now().strftime("%m-%d-%Y")

# define the variable containing all the date from start_date to yesterday.
# the date are displayed as timestamp and each day refers to 12:00 am UTC
reference_date_vector = date_gen(START_DATE)

# define all the useful arrays containing the rebalance
# start date, stop date, board meeting date
rebalance_start_date = start_q(START_DATE)
rebalance_stop_date = stop_q(rebalance_start_date)
board_date = board_meeting_day()
board_date_eve = day_before_board()
next_rebalance_date = next_start()
print(rebalance_start_date)
print(rebalance_stop_date)
print(next_rebalance_date)
print(board_date_eve)
# defining time variables
last_reb_start = str(int(rebalance_start_date[len(rebalance_start_date) - 1]))
next_reb_stop = str(int(rebalance_stop_date[len(rebalance_stop_date) - 1]))
last_reb_stop = str(int(rebalance_stop_date[len(rebalance_stop_date) - 2]))
curr_board_eve = str(int(board_date_eve[len(board_date_eve) - 1]))
print(last_reb_start)
print(next_reb_stop)
print(curr_board_eve)
# call the function that creates a object containing the