Hi All,

I have a similar problem with Binance futures and “many” assets.

The code below works fine (-at least it runs for a few hours...) using 3 assets but it breaks quite quickly with 8!

I worked with the latest Zorro Beta (2.55.6b) and the Binance Futures plugin version is 1.0.3.1.

The code

Code
-----------------------------------------------------------------------------------------------------------------------------
#include <profile.c>

#define MAX_ACTIVE_SYMBOLS 50
string ActiveSymbols[MAX_ACTIVE_SYMBOLS];

#define SYMBOLS_TEST_WORKS "BTCUSDT","ETHUSDT","BNBUSDT"
#define SYMBOLS_TEST_FAILS "BTCUSDT","ETHUSDT","BNBUSDT","XRPUSDT","LINKUSDT","DOTUSDT","LTCUSDT","ADAUSDT"
#define SYMBOLS SYMBOLS_TEST_FAILS

static int NUM_SYMBOLS = 0;

function tock()
{
	if (!is(LOOKBACK))
	{
	    string tdate = strf("%04i-%02i-%02i %02i:%02i", year(), month(), day(), hour(), minute());
	    printf("\n\n[%i - %s] Checking the Bin-sever %f ... \n", Bar, tdate, brokerCommand(2002,0) );
    
	    if(brokerCommand(2002,0) > 90000.0)
		{
			printf("\n\n[%i - %s] ------------ fixing connection \n", Bar, tdate );
                        brokerCommand(2001,0);
		} 
	}

	return;
}


function run()
{
	set(TICKS, LOGFILE, NFA);

	resf(BarMode, BR_WEEKEND);
	setf(BarMode, BR_FLAT);

	StartDate = 2021;
	EndDate = 2023;

    BarPeriod = 1440;
        
	LookBack = 50; 
	
	TickTime = 500;
	TockTime = 60000;

	Verbose = 3;

    Capital = 1000 * 1000;


	// History = "C:\\co\\adata\\crypto_daily\\binance\\spot\\*.t6";
	// History = "C:\\co\\adata\\crypto_daily\\binance\\um\\*.t6";
	History = "C:\\co\\adata\\crypto_futures\\binance\\um\\*.t6";
	
	
	if (is(FIRSTINITRUN)) {
		
		assetList("AssetsBinanceFutUM");
		
		NUM_SYMBOLS = 0;
		string temp_str;
		while( temp_str = of(SYMBOLS) ){

		    ActiveSymbols[NUM_SYMBOLS] = temp_str;

		    ++NUM_SYMBOLS;

		    if (NUM_SYMBOLS > MAX_ACTIVE_SYMBOLS)
                       quit("Error - array index value !");			
		}
		
		printf("\nFIRSTINITRUN: %d active symbols\n", NUM_SYMBOLS);
	}


    if (is(TRADEMODE))
	{
	    string tdate = strf("%04i-%02i-%02i %02i:%02i", year(), month(), day(), hour(), minute());
	    if (is(LOOKBACK))
		    printf("\n\n[%i - %s] New day in LOOKBACK\n", Bar, tdate );
	    else
		    printf("\n\n[%i - %s] New day in trading\n", Bar, tdate );
	}

    int i = 0;
    int longs = 0;
	int shorts = 0;
	for (i = 0; i < NUM_SYMBOLS; i++) {
		asset(ActiveSymbols[i]);

		if(is(INITRUN)) 
	    { 
            if (is(TRADEMODE))
		    {
                printf("\nTaking a nap for a minute... ");
                Sleep(1000 * 30);
                printf("waking up!\n");	
		    }
		}		
		vars myclose = series(priceClose());
	}
}
-----------------------------------------------------------------------------------------------------------------------------


The log file:
-----------------------------------------------------------------------------------------------------------------------------

...

[0 - 0000-00-00 00:00] New day in LOOKBACK

!BTCUSDT: Subscribing...
Warning 054: BTCUSDT LotAmount 1.0 -> 0.0010
Warning 054: BTCUSDT PIP 0.000001000 -> 0.1000
!BTCUSDT 12-04 00:11:51 to 03-04 12:11:51
!=> 03-03 11:13:00 to 03-04 12:12:00, 1500 ticks
Load BTCUSDT prices..
!BTCUSDT 12-04 00:11:51 to 03-03 11:12:30
!=> 03-02 10:14:00 to 03-03 11:13:00, 1500 ticks 110927 min
BTCUSDT 110927 ticks read
76(111292) bars 2022-12-19..2023-03-04 generated
BTCUSDT: 0..111291
Taking a nap for a minute... waking up!

!ETHUSDT: Subscribing...
Warning 054: ETHUSDT LotAmount 1.0 -> 0.0010
Warning 054: ETHUSDT PIP 0.000001000 -> 0.01000
Load ETHUSDT prices.. 110927 min
ETHUSDT 110927 ticks read
ETHUSDT: 0..111291
Taking a nap for a minute... waking up!

...

!ADAUSDT: Subscribing...
Warning 054: ADAUSDT PIP 0.000001000 -> 0.0001000
Load ADAUSDT prices.. 110926 min
ADAUSDT 110926 ticks read
ADAUSDT: 0..111291
Taking a nap for a minute... waking up!

V 2.556 on Sat 23-03-04 04:33:47

LookBack set to 50 bars

...

Lookback 50 bars, 2023-01-14..2023-03-04

[26: Sat 23-01-14 15:40] 1418.40/1644.92\1406.29/1525.33 -0.01

[26 - 2023-01-14 15:40] New day in LOOKBACK
.
[27: Sun 23-01-15 15:40] 1525.33/1564.00\1516.02/1545.63 -0.01

...

[73 - 2023-03-02 15:40] New day in LOOKBACK

[74: Fri 23-03-03 15:40] 1626.89/1657.76\1534.85/1566.33 -0.01

[74 - 2023-03-03 15:40] New day in LOOKBACK

Bar 75 continued until 15:40:00 Sat

End of lookback period at 12:33:54 Sat

[75 - 2023-03-04 12:34] Checking the Bin-sever 8.793820...


[75 - 2023-03-04 12:35] Checking the Bin-sever 1.727340...


[75 - 2023-03-04 12:36] Checking the Bin-sever 1.709770...


[75 - 2023-03-04 12:37] Checking the Bin-sever 11.141770...


[75 - 2023-03-04 12:38] Checking the Bin-sever 19.492480...

...


[75 - 2023-03-04 13:03] Checking the Bin-sever 10.628200...


[75 - 2023-03-04 13:04] Checking the Bin-sever 1.831130...


[75 - 2023-03-04 13:05] Checking the Bin-sever 7.644880...


[75 - 2023-03-04 13:06] Checking the Bin-sever 1.552680...

!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!BrokerAsset: stopped
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints

[75 - 2023-03-04 13:07] Checking the Bin-sever 19.044920...

!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
!FEED_WS: readloop_handler: The WebSocket stream was gracefully closed at both endpoints
...
-----------------------------------------------------------------------------------------------------------------------------


It looks like that the solution "if(brokerCommand(2002,0) > 120000.) brokerCommand(2001,0); " is not catching the problem ???

Have I missed something?

Thank you for your comments!