from datetime import datetime


def convert_timestamp_to_minutes(timestamp):
    """ Convert a unix timestamp to the minute of a year.
    Example: 1616257800000 = 2021-03-20 16:30 -> minute 990

    :param timestamp: unix timestamp
    :return: int
    """
    # binance timestamp is in ms not in s --> divide by 1000
    timestamp /= 1000

    # get year of timestamp and subtract timestamp of year/1/1 to get timestamp without the year
    year = datetime.utcfromtimestamp(timestamp).year
    timestamp = timestamp - datetime(year, 1, 1).timestamp()

    # divide by 60 to get minutes
    return timestamp / 60