Suppress not possible for: Failed to get symbol "XXXXXX": Symbol has no quotes.

Created at 19 Feb 2020, 12:35
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
SH

Shares4UsDevelopment

Joined 14.10.2018

Suppress not possible for: Failed to get symbol "XXXXXX": Symbol has no quotes.
19 Feb 2020, 12:35


     Symbol symbol = thisAlgo.Symbols.GetSymbol(SymName);

will throw a message in the log like :  Failed to get symbol "XXXXXX": symbol has no quotes.

Even when in a try{}catch{} block.
Please throw an error instead of filling the log.


@Shares4UsDevelopment
Replies

HichemMhamed
19 Feb 2020, 14:05

You can test if the symbol exist: thisAlgo.Symbols.Exists(SymName);


@HichemMhamed

Shares4UsDevelopment
20 Feb 2020, 13:01

RE:

mr.hichem+ctrader1 said:

You can test if the symbol exist: thisAlgo.Symbols.Exists(SymName);

Thanks for thinking with me.

But the problem is 'not throwing an exception'  which is more fitting to the way cTrader automate works than a log entry.

Also you solution will not always work. If the symbol is there but has no data the log still gets filled.:-(
Check the little test down here:

protected override void OnStart()
{
    Print("Loading " + Symbols.Count);
    foreach (string Pair in Symbols)
    {
        try
        {
            if (Symbols.Exists(Pair))
            {
                Symbol symbol = Symbols.GetSymbol(Pair);
                if (symbol != null)
                    Print(Pair , "  ", symbol.PipValue);
            }
        }
        catch(Exception ex)
        {
            Print(Pair , "  ", ex.Message);
        }
    }
}

that wil give the following output:
 

20/02/2020 10:54:29.177 | cBot "New cBot" was started successfully for EURUSD.spa, h1.
20/02/2020 10:54:29.177 | Loading 67
20/02/2020 10:54:29.192 | AUDCAD.spa  0.754068 0.754068 40000
20/02/2020 10:54:29.661 | AUDCHF.spa  1.017139 1.017139 40000
20/02/2020 10:54:33.083 | Failed to get symbol 'AUDDKK.spa': symbol has no quotes.
20/02/2020 10:54:33.208 | AUDJPY.spa  0.008916 0.008916 40000
20/02/2020 10:54:33.411 | AUDNZD.spa  0.633590 0.633590 40000
20/02/2020 10:54:33.427 | cBot "New cBot" was stopped for EURUSD.spa, h1.

So I'm still in developer-Darkness

 


@Shares4UsDevelopment

srubtsov
21 Feb 2020, 15:30

Also possible to use method to get only symbol settings without any "live" data

var symbolInfo = Symbols.GetSymbolInfo("AUDDKK.spa");
if (symbolInfo != null)
    Print(string.Format("{0}, PipValue: {1}", symbolInfo.Name, symbolInfo.PipValue.ToString("F" + symbolInfo.Digits)));

@srubtsov

Shares4UsDevelopment
21 Feb 2020, 18:10

RE:

srubtsov said:

Also possible to use method to get only symbol settings without any "live" data

var symbolInfo = Symbols.GetSymbolInfo("AUDDKK.spa");
if (symbolInfo != null)
    Print(string.Format("{0}, PipValue: {1}", symbolInfo.Name, symbolInfo.PipValue.ToString("F" + symbolInfo.Digits)));

I know, but that's not what i mean! 
the problem is 'not throwing an exception'  which is more fitting to the way cTrader automate works than a log entry.


@Shares4UsDevelopment