Topics
14 Sep 2023, 18:14
 608
 2
Replies

Sjored
10 Oct 2023, 21:09 ( Updated at: 11 Oct 2023, 06:33 )

RE: OpenApi Python SDK message queue

Thanks a lot the.innovative214 !

I really appreciate that you shared your knowledge and experience. And indeed, it doesn't seem to go well when I use a loop. So I'll try the recursive thing :-).

Kind regards,

Sjored.

 

 

 

the.innovative214 said: 

Not really am expert. I'm new to this myself but I learned due to the asynchronous nature of the connection, it doesn't seem to like typical loops… I have used recursion instead such as if I had a list of forex pairs for example I would pop off the first one in the list, do whatever work I wanted on it and then call the original definition again until I had popped off all the forex_pairs and then once the list is empty I stop the reactor. Example…

def define forex_pairs

    forex_pairs = [some list here]

     process_forex_pairs()

def Process_forex_pairs

     forex_pair = next popped off from the list of forex_pairs

     if forex_pairs not empty

            execute_trade(forex_pair)

      else

             reactor.stop

def execute_trade(forex_pair)

    do stufff here

     when finished..

    process_forex_pairs()

 

This is a pseudo idea of the  recursion I am using. Anyone else feel free to chime in and correct.

    

 

 


@Sjored