-2

it goes true the list and every time deletes on from the list and last one it gets the list back and starts all over again. I am just an amateur that try to run my trading bot. it's running for few hours and looping already for over a 1000 times than sometimes this gets triggered. when I restart the entire script manually the problem is gone. under except can I make a command that would just restart reset the entire script again?? or is there a better way

Any ideas are welcome

all = ['ETH/EUR', 'BTC/EUR', 'ADA/EUR', 'XRP/EUR', 'ETH/EUR', 'SOL/EUR', 'MANA/EUR',]
symbol = all[0]


def getsignals():
    '''
    # this function checks the symbols or tickers one by one for buying or 
    #selling triggers
    '''

def runbot(): 
    getsignals()
    time.sleep(2)


while True:
    try:
        del all[0]          
        symbol = all[0]
        print(F'-- The new symbol is now -- {symbol}')
        runbot()


        del all[0]
        symbol = all[0]
        print(F'-- The new symbol is now -- {symbol}')
        runbot()


        del all[0]
        symbol = all[0]
        print(F'-- The new symbol is now -- {symbol}')
        runbot()`


        del all[0]
        symbol = all[0]
        print(F'-- The new symbol is now -- {symbol}')
        runbot()


        del all[0]
        symbol = all[0]
        print(F'-- The new symbol is now -- {symbol}')
        runbot()


        del all[0]
        symbol = all[0]
        print(F'-- The new symbol is now -- {symbol}')
        runbot()
        all = ['ETH/EUR', 'BTC/EUR', 'ADA/EUR', 'XRP/EUR', 'ETH/EUR', 'SOL/EUR', 'MANA/EUR',] 
        print('------that was all of them------new round------')


    except Exception as e:
        print(e)
        print('-----error terror-----')
        playsound('problem.wav') 
          
        
    time.sleep(5
  • 1
    What exactly your code should do? And `all` is a builtin function so you should not assign anything to it. – Avad Jan 21 '23 at 13:25
  • All is a list of tickers from the crypto markets, in while true try it goes get the data from the first in the list 'ETH/EUR 'than delete that one and goes to the next 'BTC/EUR' than deletes that one and moves on to the next. when the last one is done it gets the whole list back and it starts over again. this is working fine for a while but than fails to run with the List assignment index out of range error and i can not find what causes this. – Wim Kraatz Jan 21 '23 at 15:07

1 Answers1

0

Ended up with a solution myself, created a main function and put the entire script in this function then on the bottom added another while True loop.

def main():
    all = ['ETH/EUR', 'BTC/EUR', 'ADA/EUR', 'XRP/EUR', 'ETH/EUR']
    symbol = all[0]


    def getsignals():
    '''
    # this function checks the symbols or tickers one by one for buying 
    #and/or selling triggers
    '''

    def runbot(): 
        getsignals()
        time.sleep(2)


    while True:
        try:
            del all[0]          
            symbol = all[0]
            print(F'-- The new symbol is now -- {symbol}')
            runbot()


            del all[0]
            symbol = all[0]
            print(F'-- The new symbol is now -- {symbol}')
            runbot()


            del all[0]
            symbol = all[0]
            print(F'-- The new symbol is now -- {symbol}')
            runbot()`


            del all[0]
            symbol = all[0]
            print(F'-- The new symbol is now -- {symbol}')
            runbot()
            all = ['ETH/EUR', 'BTC/EUR', 'ADA/EUR', 'XRP/EUR', 'ETH/EUR'] 
           print('------that was all of them------new round------')


        except Exception as e:
            print(e)
            print('-----error terror-----') 
            main()


while True:
    try:
        main()

    except Exception as e:
        print('still problems')

this way the bot starts again and the error is reset. works fine for me.