Bulk Update of Category in Existing DB

radiosilk

Active Member
#1
Anyone knows how to update "Market" category for all stocks in existing db?

Tried updating using a csv which has 2 columns (a.)TICKER (b.)MARKET

I tried using the format to import :
-------------
$FORMAT TICKER,MARKET

$SEPARATOR ,
$SKIPLINES 1
$NOQUOTES 1
-------------

But the Market remains "NYSE".

I do not have it in me to update "Market" for 100's of scrips, individually.

Could someone please inform or point in the right direction?

Very much appreciate any help!

Thanks
 

trash

Well-Known Member
#2
You can do it via AFL OLE code if the symbols are already in your database.

In analysis set "Apply to:" -> Current

Code:
// set Information window infos via Explore
// In analysis set "Apply to:" -> Current
// by trash

mktID = 3; // set current market ID here
newMktID = 2; // new mktid here

Filter = Status( "lastbarinrange" );
SetOption( "RefreshWhenCompleted", True );
SetOption( "NoDefaultColumns", 1 );
AddTextColumn( CategoryGetName( categoryMarket, mktID ), "OLD Market ID", 1, colorLightYellow, colorDarkRed, 80 );
AddTextColumn( CategoryGetName( categoryMarket, newmktID ), "NEW Market ID", 1, colorLightYellow, colorDarkGreen, 80 );
AddTextColumn( "New Market Set", "Status", 1, colorLightYellow, colorDarkGreen, 150 );

if ( Status( "actionex" ) == actionExplore AND Status( "stocknum" ) == 0 ) 
{ 
	AB = CreateObject( "Broker.Application" );
     
	list = CategoryGetSymbols( categoryMarket, mktID );
	// iterate through set market
	for ( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
	{
		SetForeign( sym );
			nm = Name(); 			
			st = AB.Stocks( nm ); 		
			st.MarketID = newMktID; // sets different market ID than original one
		RestorePriceArrays();
	}
}
 

mastermind007

Well-Known Member
#3
Anyone knows how to update "Market" category for all stocks in existing db?

Tried updating using a csv which has 2 columns (a.)TICKER (b.)MARKET

I tried using the format to import :
-------------
$FORMAT TICKER,MARKET

$SEPARATOR ,
$SKIPLINES 1
$NOQUOTES 1
-------------

But the Market remains "NYSE".

I do not have it in me to update "Market" for 100's of scrips, individually.

Could someone please inform or point in the right direction?

Very much appreciate any help!

Thanks
You do not have to manage markets one by one

Symbol->Organize assignments allows you to define market id for many stocks at once.
 
#4
You can do it via AFL OLE code if the symbols are already in your database.

In analysis set "Apply to:" -> Current
What you told me went beyond me :(

Tried to run a scan and an explore but got error. Do we run OLE code like any normal afl scan ?

What i am trying to achieve is to segregate NSE EOD scrips into different markets (not watchlist or industry etc).

Currently, all are showing in NYSE.
 
#5
You do not have to manage markets one by one

Symbol->Organize assignments allows you to define market id for many stocks at once.
Sure, i understand that process. But won't that be tedious ? I have a db of all nse eod scrips and need to segregate these names in different "Markets" (not watchlists or industries etc). Currently, all show up in NYSE.

If there was a way to import a csv which would update Market for say 100 scrips in one import, that would be much more easy. Difficult to select 100 scrips out of thousands that are in db.

Hope i was able to clear my predicament.
 

trash

Well-Known Member
#6
What you told me went beyond me :(

Tried to run a scan and an explore but got error. Do we run OLE code like any normal afl scan ?

What i am trying to achieve is to segregate NSE EOD scrips into different markets (not watchlist or industry etc).

Currently, all are showing in NYSE.

If you get an error then you use a VERY VERY OLD version of AmiBroker! What version number do you use? You don't even tell the error!

EDIT: You run a version equal or prior to AmiBroker 5.10!!! That's a version of six to seven years ago or worse! SetOption( "RefreshWhenCompleted", True ) was not present there. That's why the error.


If there was a way to import a csv which would update Market for say 100 scrips in one import, that would be much more easy. Difficult to select 100 scrips out of thousands that are in db.
Yes you can do that too but OLE method of example in second post is better as you can change IDs for ALL SYMBOLS of a market in one run anytime.
 
Last edited:
#7
If you get an error then you use a VERY VERY OLD version of AmiBroker! What version number do you use? You don't even tell the error!

EDIT: You run a version equal or prior to AmiBroker 5.10!!! That's a version of six to seven years ago or worse! SetOption( "RefreshWhenCompleted", True ) was not present there. That's why the error.




Yes you can do that too but OLE method of example in second post is better as you can change IDs for ALL SYMBOLS of a market in one run anytime.
Thanks a lot !!

It worked !
:clapping:
:thumb:
 

mastermind007

Well-Known Member
#8
Sure, i understand that process. But won't that be tedious ? I have a db of all nse eod scrips and need to segregate these names in different "Markets" (not watchlists or industries etc). Currently, all show up in NYSE.

If there was a way to import a csv which would update Market for say 100 scrips in one import, that would be much more easy. Difficult to select 100 scrips out of thousands that are in db.

Hope i was able to clear my predicament.
And the CSV file you want to import is going to fall on your computer from clear blue sky?
 

trash

Well-Known Member
#10
If you want to assign all symbols to the same market and you wanna assign them during ASCII import already then you just need to add following line to your import format file of Formats folder

$MARKET X

Where you have to replace X with your preferred market ID.
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?