Bulk Edit Symbol Information to update Market

Hi,

I am trying to iterate through list of all stocks, and editing Market Symbol information.
I need help to find the element/member name & hierarchy for setting Market Symbol information ; i get compile issue at st.Ticker.Market, ( i searched all possible list of values in drop down list for st. below, but could not figure out).

AB = CreateObject( "Broker.Application" );
sts = AB.Stocks();
Qty = sts.Count;

for( i = Qty - 1; i >= 0; i = i - 1 )
{
    st = sts.Item( i );
    Ticker = st.Ticker;
    printf( "changing " + ticker + "\n" );

    if( StrFind( ticker, ".BO" ) )
        st.Ticker.Market = "BSE";

   if( StrFind( ticker, ".NS" ) )
        st.Ticker.Market = "NSE";
}

Thanks
harsha

@rharsha

please, review the AmiBroker Object Model documentation.

MarketID is a property of the Stock object and is a "Long", so you should assign to it a number (not a string).
Choose the appropriate MarketIDs from your "Markets" tree view (I suppose you have already named both your 2 main markets).

image

Then, try this modified snippet (after changing the MarketIDs as per your configuration):

AB = CreateObject( "Broker.Application" );
sts = AB.Stocks();
Qty = sts.Count;

for( i = Qty - 1; i >= 0; i-- )
{
    st = sts.Item( i );
    Ticker = st.Ticker;
    // printf( "changing " + ticker + "\n" );
    _TRACEF( "Processing " + Ticker );

    if( StrFind( ticker, ".BO" ) )
        st.MarketID = 201; // Choose the numeric ID of the BSE Market

	else if( StrFind( ticker, ".NS" ) )
        st.MarketID = 202; // Choose the numeric ID of the NSE Market
}

Thank you @beppe . This solution works.
Also the hint on the (long) numeric id for Markets - how to find them, was useful and prescient.

@Tomasz , I was also wondering if AFL Formula editor, when using OLE model , should provide hints based on OLE attributes/members/functions? (ideally MarketID being an attribute of Stock , should have drop down helpers like MarketID etc)

image

1 Like

At this moment hints on dynamic function names are only supported for ADK / plugin supplied functions not for OLE. Displaying OLE members would require constant re-evaluation of the formula while you are typing and querying underlying OLE objects after evaluation.
I am currently trying to go away from OLE as it is old tech, that is not really multi-threading friendly and not planing any OLE-related new features.