Trading bot exploiting the time lagged correllation between BTC and other cryptocurrencies

I’m currently trying to do a trading bot that try to exploit the time-lagged correllation between cryptocurrencies but I’am encountering a problem with the definfion of the function of my strategy:
I’ll post here my function:

def botstrat(symbol,qty, open_position=False):
    while True:
        df= getsecondsdata(symbol)
        if not open_position:
            if close_conca_data.iat[-1,6]>=0.000752 \
            and  df_btc_largest.iloc[0:8]>=0.8:
                order = client.create_order(symbol=symbol,
                                            side="BUY",
                                            type="Market",quantity=qty)
                print(order)
                open_position=True
                buyprice = float(order["fills"][0]["price"])
                break
    if open_position:
        while True:
            df=getsecondsdata(symbol)
            if close_conca_data.iat[-1,6]<=-0.00035 \
            and  df_btc_largest.iloc[0:8]<=0.8:
                
                order = client.create_order(symbol=symbol,
                                           side='SELL',
                                           type='MARKET', quantity=qty)
                print(order)
                sellprice = float(order['fills'][0]['price'])
                print(f'profit = {(sellprice - buyprice)/buyprice}')
                open_position = False
                break

I’am new to programming, if someone can help me, i’'ll be very thankful.¨
Thanks in advance

what is this?