def get_pnl(df, max_position=1, comission=0):
    deals = []
    pnl = 0
    position = 0
    df_with_signals = df[(df['sell'] != 0) | (df['buy'] != 0)]

    for idx, row in df_with_signals.iterrows():
        if row['buy'] == 1 and position < max_position:
            print(row)
            current_trade = -row['buy'] * row["askpx_"]
            position += 1
            pnl = pnl + current_trade - comission
            deals.append(current_trade)
            print("Running PnL: {}, position: {}".format(pnl, position))
        elif row['sell'] == 1 and position > -max_position:
            print(row)
            current_trade = row['sell'] * row["bidpx_"]
            position -= 1
            pnl = pnl + current_trade - comission
            deals.append(current_trade)
            print("Running PnL: {}, position: {}".format(pnl, position))

    if position == 1:
        day_closing_trade = df.iloc[-1]["bidpx_"]
        pnl = pnl + day_closing_trade - comission
        deals.append(day_closing_trade)
        print("Close last hanging deal on the end of the day, PnL: {}, position: {}".format(pnl, position))
    elif position == -1:
        day_closing_trade = -df.iloc[-1]["askpx_"]
        pnl = pnl + day_closing_trade - comission
        deals.append(day_closing_trade)
        print("Close last hanging deal on the end of the day, PnL: {}, position: {}".format(pnl, position))

    print("Check PnL: {} vs {}".format(pnl, np.sum(deals)))
    return pnl, len(deals)