Example #1
0
 def test_try_to_move_back_in_time(self):
     # Create a nice event to make time fly
     event = Event(10)
     event.perform(self.world)
     # Create an event that tries to move back in time
     wrong_event = Event(5)
     self.assertRaises(ValueError, wrong_event.perform, self.world)
Example #2
0
def main():
    granularity = 15  # TODO allow change of granularity

    dt_start = sys.argv[1]
    dt_end = sys.argv[2]
    tx_location = sys.argv[3]
    tx_rrule = sys.argv[4]
    temp = open("C:/wamp/www/mesa/python/temp1.json",
                "r")  # TODO make relative path
    bl_calendars = json.loads(temp.read())
    temp.close()
    temp = open("C:/wamp/www/mesa/python/temp2.json", "r")
    bl_settings = json.loads(temp.read())
    temp.close()

    rrule = parse_rrule(tx_rrule)  # TODO create use for rrule

    priorities = parse_priorities(bl_settings)
    original_event = Event(
        "blevent", {
            "blEvent": {
                "start_time": dt_start.replace(" ", "T") + "Z",
                "end_time": dt_end.replace(" ", "T") + "Z",
                "location": tx_location,
                "travel_time": 0
            }
        })
    calendar_set = construct_calendar_set(bl_calendars)
    point_list = construct_point_list(calendar_set, granularity,
                                      original_event, bl_settings)

    cost_output = smallest_cost(point_list, priorities, original_event,
                                granularity, tx_location, calendar_set)
    print(cost_output)
Example #3
0
 def test_add_event(self):
     shuffled_events = [Event(time) for time in range(10, 41, 10)]
     random.shuffle(shuffled_events)
     for event in shuffled_events:
         self.world.add_event(event)
     self.assertSequenceEqual([event.time for event in self.world.stack],
                              range(10, 41, 10))
def find_events():
    events_list = []
    try:
        events_url = "https://api.betsapi.com/v2/events/upcoming?token={}&sport_id=151?day=TODAY".format(
            os.environ.get("BETS_API_TOKEN"))
        events = requests.get(events_url).json()

        current_epoch_time = int(time.time())
        events_access = events["results"]
    except:
        logging.info("Couldnt get upcoming events")
    else:
        for events_data in events_access:
            try:
                event_id = events_data["id"]
                event_time = events_data["time"]
                home_team = events_data["home"]["name"]
                away_team = events_data["away"]["name"]
                league = events_data["league"]["name"]
            except:
                logging.debug(
                    "Could not retrieve event id and time in find_events()")
            else:
                # get events within the next 2 hours (7200 sec)
                if (int(event_time) - int(current_epoch_time)) > 0 and (
                        int(event_time) - int(current_epoch_time)) < 7200:
                    events_list.append(
                        Event(event_id, event_time, home_team, away_team,
                              league))

    # if we find a good event/bet add it
    for event in events_list:
        try:
            oddsUrl = "https://api.betsapi.com/v2/event/odds?token={}&event_id={}&odds_market=1&source=pinnaclesports".format(
                os.environ.get("BETS_API_TOKEN"), event.eventId)
            odds = requests.get(oddsUrl).json()
            odds_access = odds["results"]["odds"]["151_1"]
            homeOddsNow = float(odds_access[0]["home_od"])
            homeOddsEarlier = float(odds_access[1]["home_od"])
            awayOddsNow = float(odds_access[0]["away_od"])
            awayOddsEarlier = float(odds_access[1]["away_od"])

            if homeOddsNow < (homeOddsEarlier * 0.95):
                if do_bet_exist(event.eventId) == False:
                    place_bet(event.eventId, "H", homeOddsNow, 50)
                    logging.info(
                        "Placed bet on home team {} vs {} with id {}".format(
                            event.home_team, event.away_team, event.eventId))

            if awayOddsNow < (awayOddsEarlier * 0.95):
                if do_bet_exist(event.eventId) == False:
                    place_bet(event.eventId, "A", awayOddsNow, 50)
                    logging.info(
                        "Placed bet on away team {} vs {} with id {}".format(
                            event.home_team, event.away_team, event.eventId))
        except:
            logging.debug("No event odds in find_events()")
Example #5
0
 def endElement(self, tag):
     if tag == "trace":
         if self.log in self.logs:
             if self.tracename in self.logs[self.log]:
                 print(self.log)
                 print(self.tracename)
                 raise RuntimeError("Trace already exists")
         else:
             self.logs[self.log] = {}
             self.start_events[self.log] = collections.defaultdict(int)
             self.end_events[self.log] = collections.defaultdict(int)
         if (self.lifecycle_options['lifecycle_exists'] == 0):
             self.start_events[self.log][self.event_start] += 1
             self.end_events[self.log][self.event_end] += 1
         elif (self.lifecycle_options['lifecycle_exists'] == 1
               and len(self.lifecycle_options['lifecycle_options']) == 1):
             self.start_events[self.log][self.event_start] += 1
             self.end_events[self.log][self.event_end] += 1
         else:
             self.start_events[self.log][self.event_start_start] += 1
             self.end_events[self.log][self.event_end_start] += 1
         self.logs[self.log][self.tracename] = Trace(
             self.log, self.tracename, self.trace)
         self.event_start = None
         self.event_end = None
         self.event_start_start = None
         self.event_end_start = None
         self.tracename = None
         self.trace = []
     if tag == "event":
         self.event_map[self.attrib['concept:name']] += 1
         if 'lifecycle:transition' not in self.attrib:
             self.lifecycle_options[
                 'lifecycle_exists'] = 0  # if there is at least one event without a lifecycle transition, then we cannot use lifecycles.
         else:
             self.lifecycle_options['lifecycle_options'].add(
                 self.attrib['lifecycle:transition'])
         if self.lifecycle_options[
                 'lifecycle_exists'] == 0 or self.lifecycle_options[
                     'lifecycle_exists'] == 1 and self.attrib[
                         'lifecycle:transition'] == "start":
             if not self.event_start_start:
                 self.event_start_start = self.attrib['concept:name']
             self.event_end_start = self.attrib['concept:name']
         if self.lifecycle_options[
                 'lifecycle_exists'] == 0 or self.lifecycle_options[
                     'lifecycle_exists'] == 1 and self.attrib[
                         'lifecycle:transition'] == "complete":
             if not self.event_start:
                 self.event_start = self.attrib['concept:name']
             self.event_end = self.attrib['concept:name']
         self.trace.append(Event(self.log, self.tracename, self.attrib))
         self.attrib = None
     self.tag = tag
Example #6
0
def JSONtoEvent(j: json):
    event = Event(j["min"], j["max"], j["Location"], j["Time"], j["Title"],
                  j["Description"])

    persons = []
    for participant in j["Participants"]:
        persons.append(
            Participant(participant[0]["Email"], participant[0]["Name"]))

    event.addParticipants(persons)

    return event
Example #7
0
    def get_all_events(self,
                       calendar_id: int,
                       strip_private=False) -> List[Event]:
        ''' Return list of Event objects that match the provided calendar_id. 
            If strip_private is True, all non-private events will be returned. '''
        cid: Tuple = (calendar_id, )

        if strip_private:
            self._execute(
                "SELECT * FROM events WHERE calendar_id = ? AND private = 0",
                cid)
        else:
            self._execute("SELECT * FROM events WHERE calendar_id = ?", cid)

        results = self._get_all_results()
        return [Event(*event)
                for event in results]  # list comps are so comfy unf
Example #8
0
    def build_workout_sequence(self, duration, profile):
        # determine workout format
        exercise_sequence = []
        if self.profile['warmup']:
            duration -= 2
            exercise_sequence.append(Event(self.make_exercise('Warmup'), 120))

        total_rounds = int(np.floor(duration * 60 / 200))
        total_exercises = total_rounds * 2

        exercises_list = self.do_sampling(profile, total_exercises)

        def divide_chunks(l, n):
            for i in range(0, len(l), n):
                yield l[i:i + n]

        num_humans = 1 if 'num_humans' not in profile else profile['num_humans']
        #this is reaaly only a 2 human format
        chunksize = 2
        for chunk in divide_chunks(exercises_list, chunksize):
            if len(chunk) < chunksize:
                continue  #non multiple number of minutes
            if num_humans == 1:
                for iter in range(2):
                    exercise_sequence.append(Event(chunk[0], 40))
                    exercise_sequence.append(Event(chunk[1], 40))
                    exercise_sequence.append(
                        Event(self.make_exercise('Rest'), 20))
            else:
                for iter in range(2):
                    exercise_sequence.append(Event((chunk[0], chunk[1]), 40))
                    exercise_sequence.append(Event((chunk[1], chunk[0]), 40))
                    exercise_sequence.append(
                        Event(self.make_exercise('Rest'), 20))
        exercise_sequence = exercise_sequence[:-1]  #remove final rest

        #     #30 reps of each exercise; do full circuit twice
        return exercise_sequence
Example #9
0
 def get_event(self, event_id: int) -> Event:
     ''' Return a single event, selected by event_id. '''
     eid: Tuple = (event_id, )
     self._execute("SELECT * FROM events WHERE event_id = ?", eid)
     return Event(*self._get_result())
Example #10
0
def project(XK, XV, LorY, surfSrc, surfTar, K_diag, V_diag, IorE, self, param,
            ind0, timing, kernel):

    if param.GPU == 1:
        tic = cuda.Event()
        toc = cuda.Event()
    else:
        tic = Event()
        toc = Event()

    REAL = param.REAL
    Ns = len(surfSrc.triangle)
    Nt = len(surfTar.triangle)
    L = numpy.sqrt(2 * surfSrc.Area)  # Representative length

    tic.record()
    K = param.K
    w = getWeights(K)
    X_V = numpy.zeros(Ns * K)
    X_Kx = numpy.zeros(Ns * K)
    X_Ky = numpy.zeros(Ns * K)
    X_Kz = numpy.zeros(Ns * K)
    X_Kc = numpy.zeros(Ns * K)
    X_Vc = numpy.zeros(Ns * K)

    NsK = numpy.arange(Ns * K)
    X_V[:] = XV[NsK / K] * w[NsK % K] * surfSrc.Area[NsK / K]
    X_Kx[:] = XK[NsK / K] * w[NsK % K] * surfSrc.Area[NsK /
                                                      K] * surfSrc.normal[NsK /
                                                                          K, 0]
    X_Ky[:] = XK[NsK / K] * w[NsK % K] * surfSrc.Area[NsK /
                                                      K] * surfSrc.normal[NsK /
                                                                          K, 1]
    X_Kz[:] = XK[NsK / K] * w[NsK % K] * surfSrc.Area[NsK /
                                                      K] * surfSrc.normal[NsK /
                                                                          K, 2]
    X_Kc[:] = XK[NsK / K]
    X_Vc[:] = XV[NsK / K]

    toc.record()
    toc.synchronize()
    timing.time_mass += tic.time_till(toc) * 1e-3

    tic.record()
    C = 0
    getMultipole(surfSrc.tree, C, surfSrc.xj, surfSrc.yj, surfSrc.zj, X_V,
                 X_Kx, X_Ky, X_Kz, ind0, param.P, param.NCRIT)
    toc.record()
    toc.synchronize()
    timing.time_P2M += tic.time_till(toc) * 1e-3

    tic.record()
    for C in reversed(range(1, len(surfSrc.tree))):
        PC = surfSrc.tree[C].parent
        upwardSweep(surfSrc.tree, C, PC, param.P, ind0.II, ind0.JJ, ind0.KK,
                    ind0.index, ind0.combII, ind0.combJJ, ind0.combKK,
                    ind0.IImii, ind0.JJmjj, ind0.KKmkk, ind0.index_small,
                    ind0.index_ptr)
    toc.record()
    toc.synchronize()
    timing.time_M2M += tic.time_till(toc) * 1e-3

    tic.record()
    X_V = X_V[surfSrc.sortSource]
    X_Kx = X_Kx[surfSrc.sortSource]
    X_Ky = X_Ky[surfSrc.sortSource]
    X_Kz = X_Kz[surfSrc.sortSource]
    X_Kc = X_Kc[surfSrc.sortSource]
    X_Vc = X_Vc[surfSrc.sortSource]
    toc.record()
    toc.synchronize()
    timing.time_sort += tic.time_till(toc) * 1e-3

    param.Nround = len(surfTar.twig) * param.NCRIT
    K_aux = numpy.zeros(param.Nround)
    V_aux = numpy.zeros(param.Nround)
    AI_int = 0

    ### CPU code
    if param.GPU == 0:
        K_aux, V_aux = M2P_sort(surfSrc, surfTar, K_aux, V_aux, self,
                                ind0.index_large, param, LorY, timing)

        K_aux, V_aux = P2P_sort(surfSrc, surfTar, X_V, X_Kx, X_Ky, X_Kz, X_Kc,
                                X_Vc, K_aux, V_aux, self, LorY, K_diag, V_diag,
                                IorE, L, w, param, timing)

    ### GPU code
    elif param.GPU == 1:
        K_gpu = cuda.to_device(K_aux.astype(REAL))
        V_gpu = cuda.to_device(V_aux.astype(REAL))

        if surfTar.offsetMlt[self, len(surfTar.twig)] > 0:
            K_gpu, V_gpu = M2P_gpu(surfSrc, surfTar, K_gpu, V_gpu, self, ind0,
                                   param, LorY, timing, kernel)

        K_gpu, V_gpu = P2P_gpu(surfSrc, surfTar, X_V, X_Kx, X_Ky, X_Kz, X_Kc,
                               X_Vc, K_gpu, V_gpu, self, LorY, K_diag, IorE, L,
                               w, param, timing, kernel)

        tic.record()
        K_aux = cuda.from_device(K_gpu, len(K_aux), dtype=REAL)
        V_aux = cuda.from_device(V_gpu, len(V_aux), dtype=REAL)
        toc.record()
        toc.synchronize()
        timing.time_trans += tic.time_till(toc) * 1e-3

    tic.record()
    K_lyr = K_aux[surfTar.unsort]
    V_lyr = V_aux[surfTar.unsort]
    toc.record()
    toc.synchronize()
    timing.time_sort += tic.time_till(toc) * 1e-3

    return K_lyr, V_lyr
Example #11
0
def project_Kt(XKt, LorY, surfSrc, surfTar, Kt_diag, self, param, ind0, timing,
               kernel):

    if param.GPU == 1:
        tic = cuda.Event()
        toc = cuda.Event()
    else:
        tic = Event()
        toc = Event()

    REAL = param.REAL
    Ns = len(surfSrc.triangle)
    Nt = len(surfTar.triangle)
    L = numpy.sqrt(2 * surfSrc.Area)  # Representative length

    tic.record()
    K = param.K
    w = getWeights(K)
    X_Kt = numpy.zeros(Ns * K)
    X_Ktc = numpy.zeros(Ns * K)

    NsK = numpy.arange(Ns * K)
    X_Kt[:] = XKt[NsK / K] * w[NsK % K] * surfSrc.Area[NsK / K]
    X_Ktc[:] = XKt[NsK / K]

    toc.record()
    toc.synchronize()
    timing.time_mass += tic.time_till(toc) * 1e-3

    tic.record()
    C = 0
    X_aux = numpy.zeros(Ns * K)
    getMultipole(surfSrc.tree, C, surfSrc.xj, surfSrc.yj, surfSrc.zj, X_Kt,
                 X_aux, X_aux, X_aux, ind0, param.P, param.NCRIT)
    toc.record()
    toc.synchronize()
    timing.time_P2M += tic.time_till(toc) * 1e-3

    tic.record()
    for C in reversed(range(1, len(surfSrc.tree))):
        PC = surfSrc.tree[C].parent
        upwardSweep(surfSrc.tree, C, PC, param.P, ind0.II, ind0.JJ, ind0.KK,
                    ind0.index, ind0.combII, ind0.combJJ, ind0.combKK,
                    ind0.IImii, ind0.JJmjj, ind0.KKmkk, ind0.index_small,
                    ind0.index_ptr)
    toc.record()
    toc.synchronize()
    timing.time_M2M += tic.time_till(toc) * 1e-3

    tic.record()
    X_Kt = X_Kt[surfSrc.sortSource]
    X_Ktc = X_Ktc[surfSrc.sortSource]
    toc.record()
    toc.synchronize()
    timing.time_sort += tic.time_till(toc) * 1e-3

    param.Nround = len(surfTar.twig) * param.NCRIT
    Ktx_aux = numpy.zeros(param.Nround)
    Kty_aux = numpy.zeros(param.Nround)
    Ktz_aux = numpy.zeros(param.Nround)
    AI_int = 0

    ### CPU code
    if param.GPU == 0:
        if surfTar.offsetMlt[self, len(surfTar.twig)] > 0:
            Ktx_aux, Kty_aux, Ktz_aux = M2PKt_sort(surfSrc, surfTar, Ktx_aux,
                                                   Kty_aux, Ktz_aux, self,
                                                   ind0.index_large, param,
                                                   LorY, timing)

        Ktx_aux, Kty_aux, Ktz_aux = P2PKt_sort(surfSrc, surfTar, X_Kt, X_Ktc,
                                               Ktx_aux, Kty_aux, Ktz_aux, self,
                                               LorY, w, param, timing)

    ### GPU code
    elif param.GPU == 1:
        Ktx_gpu = cuda.to_device(Ktx_aux.astype(REAL))
        Kty_gpu = cuda.to_device(Kty_aux.astype(REAL))
        Ktz_gpu = cuda.to_device(Ktz_aux.astype(REAL))

        if surfTar.offsetMlt[self, len(surfTar.twig)] > 0:
            Ktx_gpu, Kty_gpu, Ktz_gpu = M2PKt_gpu(surfSrc, surfTar, Ktx_gpu,
                                                  Kty_gpu, Ktz_gpu, self, ind0,
                                                  param, LorY, timing, kernel)

        Ktx_gpu, Kty_gpu, Ktz_gpu = P2PKt_gpu(surfSrc, surfTar, X_Kt, X_Ktc,
                                              Ktx_gpu, Kty_gpu, Ktz_gpu, self,
                                              LorY, w, param, timing, kernel)

        tic.record()
        Ktx_aux = cuda.from_device(Ktx_gpu, len(Ktx_aux), dtype=REAL)
        Kty_aux = cuda.from_device(Kty_gpu, len(Kty_aux), dtype=REAL)
        Ktz_aux = cuda.from_device(Ktz_gpu, len(Ktz_aux), dtype=REAL)
        toc.record()
        toc.synchronize()
        timing.time_trans += tic.time_till(toc) * 1e-3

    tic.record()
    Kt_lyr = Ktx_aux[surfTar.unsort]*surfTar.normal[:,0] \
           + Kty_aux[surfTar.unsort]*surfTar.normal[:,1] \
           + Ktz_aux[surfTar.unsort]*surfTar.normal[:,2]

    if abs(Kt_diag) > 1e-12:  # if same surface
        Kt_lyr += Kt_diag * XKt

    toc.record()
    toc.synchronize()
    timing.time_sort += tic.time_till(toc) * 1e-3

    return Kt_lyr
Example #12
0
 def test_run(self):
     self.world.stack = [Event(time) for time in range(10, 41, 10)]
     self.world.run()
Example #13
0
    # Read sensor data from Arduino via serial
    reading = ser.readline()
    if ser.isButtonPressed(reading):
        ongoingMeal.forceToggle(buffer.latest())
    else:
        if not buffer.isFull():
            buffer.add(reading)
            continue
        outlier = buffer.score(reading,
                               useTypical=eventInProgress) > OUTLIER_Z_SCORE
        if not eventInProgress:
            buffer.updateTypicalDev()
        if not eventInProgress and outlier:
            eventInProgress = True
            events.append(Event([buffer.earliest()], reading))
        elif eventInProgress:
            if outlier:
                events[-1].add(reading)
            else:
                eventInProgress = False
                events[-1].end()
                ongoingMeal.updateWithEvent(events[-1])

        buffer.add(reading)

    if ongoingMeal.checkIfIdle() or ongoingMeal.forceEnd:
        success = ongoingMeal.endMeal(buffer.latest())
        if success == -1:
            print("Invalid Meal!")
        else:
Example #14
0
def parse_file(folder):
    print("######################")
    print("PROCESSING:  ")
    print(folder)
    print("######################")
    list_events = []
    folder = os.path.join(os.path.dirname(__file__), folder)
    for filename in os.listdir(folder):
        print(filename)
        if "STAKING_FLEX" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                for line in a_file:
                    if not line.startswith("--"):
                        line_parts = re.split(r'\t+', line)
                        e = Event(trans_type="Staking",
                                  buy_amt=line_parts[3],
                                  buy_cur=line_parts[1],
                                  comment="Binance Flexible Staking",
                                  effective_date=parse_date(
                                      line_parts[0], '%Y-%m-%d %H:%M:%S'),
                                  exchange="Binance")
                        list_events.append(e)
        if "STAKING_LOCKED" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                for line in a_file:
                    if not line.startswith("--"):
                        try:
                            line_parts = re.split(r'\t+', line)
                            e = Event(trans_type="Staking",
                                      buy_amt=line_parts[3],
                                      buy_cur=line_parts[0],
                                      comment="Binance Locked Staking",
                                      effective_date=parse_date(
                                          line_parts[4], '%Y-%m-%d'),
                                      exchange="Binance")
                            list_events.append(e)
                        except:
                            print("ERROR:")
                            print(line)
        if "Buy History" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                df = pd.read_excel(filename, sheet_name="sheet1")
                df = df[df["Status"] == "Completed"]
                for index, row in df.iterrows():
                    e = Event(trans_type="Trade",
                              buy_amt=row["Final Amount"].split(" ")[0],
                              buy_cur=row["Final Amount"].split(" ")[1],
                              sell_amt=row["Amount"].split(" ")[0],
                              sell_cur=row["Amount"].split(" ")[1],
                              fee_amt=row["Fees"].split(" ")[0],
                              fee_cur=row["Fees"].split(" ")[1],
                              comment="Binance Buy",
                              effective_date=parse_date(
                                  row["Date(UTC)"], '%Y-%m-%d %H:%M:%S'),
                              exchange="Binance")
                    list_events.append(e)
        if "DEPOSIT_HISTORY_FIAT" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                df = pd.read_excel(filename, sheet_name="sheet1")
                df = df[df["Status"] == "Succesfull"]
                for index, row in df.iterrows():
                    e = Event(trans_type="Deposit",
                              buy_amt=row["Amount"],
                              buy_cur=row["Coin"],
                              fee_amt=row["Fee"],
                              fee_cur=row["Coin"],
                              comment="Binance Deposit Fiat",
                              effective_date=parse_date(
                                  row["Date(UTC)"], '%Y-%m-%d %H:%M:%S'),
                              exchange="Binance")
                    list_events.append(e)
        if "DEPOSIT_HISTORY_CRYPTO" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                df = pd.read_excel(filename, sheet_name="sheet1")
                df = df[df["Status"] == "Completed"]
                for index, row in df.iterrows():
                    e = Event(trans_type="Deposit",
                              buy_amt=row["Amount"],
                              buy_cur=row["Coin"],
                              comment="Binance Deposit Fiat",
                              effective_date=parse_date(
                                  row["Date(UTC)"], '%Y-%m-%d %H:%M:%S'),
                              exchange="Binance")
                    list_events.append(e)
        if "part" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                df = pd.read_csv(filename)
                for index, row in df.iterrows():
                    row["BuyCoin"] = row["Executed"]
                    row["PayCoin"] = row["Amount"]
                    row["FeeCoin"] = row["Fee"]
                    row["Executed"] = row["Executed"][0:len(row["Executed"]) -
                                                      3]
                    row["Amount"] = row["Amount"][0:len(row["Amount"]) - 3]
                    row["Fee"] = row["Fee"][0:len(row["Fee"]) - 3]
                    row["BuyCoin"] = row["BuyCoin"].replace(
                        row["Executed"], "")
                    row["PayCoin"] = row["PayCoin"].replace(row["Amount"], "")
                    row["FeeCoin"] = row["FeeCoin"].replace(row["Fee"], "")
                    e = Event(trans_type="Trade",
                              buy_amt=row["Executed"],
                              buy_cur=row["BuyCoin"],
                              fee_amt=row["Fee"],
                              fee_cur=row["FeeCoin"],
                              sell_amt=row["Amount"],
                              sell_cur=row["PayCoin"],
                              comment="Binance Buy History",
                              effective_date=parse_date(
                                  row["Date(UTC)"], '%Y-%m-%d %H:%M:%S'),
                              exchange="Binance")
                    list_events.append(e)
        if "CONVERSIONS_BNB" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                df = pd.read_csv(filename)
                for index, row in df.iterrows():
                    e = Event(trans_type="Trade",
                              buy_amt=row["Converted BNB"],
                              buy_cur="BNB",
                              fee_amt="BNB",
                              fee_cur=row["Fee (BNB)"],
                              sell_amt=row["Amount"],
                              sell_cur=row["Coin"],
                              comment="Binance BNB Conversion low capitals",
                              effective_date=parse_date(
                                  row["Date"], '%Y-%m-%d %H:%M:%S'),
                              exchange="Binance")
                    list_events.append(e)
        if "AIRDROPS" in filename:
            filename = os.path.join(folder, filename)
            with open(filename, "r") as a_file:
                df = pd.read_csv(filename)
                for index, row in df.iterrows():
                    e = Event(trans_type="Airdrop",
                              buy_amt=row["Amount"],
                              buy_cur=row["Coin"],
                              comment="Binance Airdrop " + row["Note"],
                              effective_date=parse_date(
                                  row["Time"], '%Y-%m-%d %H:%M:%S'),
                              exchange="Binance")
                    list_events.append(e)

    return list_events