INNER CODE UNIT · Python

get_current_pnl

jptsantossilva/BEC · bec/main.py:284

def get_current_pnl(symbol, current_price, timeframe, position_id=None):

    try:
        # get buy price
        if position_id is not None:
            df_buy_price = database.get_position_by_id(position_id)
        else:
            df_buy_price = database.get_positions_by_bot_symbol_position(
                bot=timeframe, symbol=symbol, position=1
            )
        buy_price = 0
        pnl_perc = 0

        if not df_buy_price.empty:
            # get buy price
            buy_price = df_buy_price["Buy_Price"].iloc[0]
            # check if buy price is fulfilled
            if not math.isnan(buy_price) and buy_price > 0:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…