Deleting RT ticks

mastermind007

Well-Known Member
#1
Today RT Feeder that switched value of mm and dd in date so it was pushing data for 7th Jan instead of 1st July into the Amibroker.

By the time, I spotted and discovered the root cause and fixed the live feed, it was 10:30, so 7 Jan is wrongly populated.

How do I delete all ticks for all scrips for a particular date efficiently? I do have backup of 7th Jan in csv format so I will be able to re-add clean data but I need to wipe out old values first.
 

trash

Well-Known Member
#2
Not sure you can delete a special date of all tickers for i.e. 700 symbols but you can create a copy of each symbol via AddToComposite with custom start and end date via Analysis window. After copy created you delete old tickers and rename copied tickers that have composite name like ~Copy of YM to just YM by using

Code:
if ( Status( "action" ) == actionScan )
{
    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, "~Copy of " ) )
                st.Ticker = StrReplace( ticker, "~Copy of ", "" );
        }
    }
}

Buy = 0;
SetOption( "RefreshWhenCompleted", True );
Before doing all that make a backup of your data base!


BTW what is RT feeder? Is that a 3rd party tool?
 

trash

Well-Known Member
#3
Next time you have similar problem don't save your data base but re-open that data base by a starting a second instance of AmiBroker. It will open the previous state of that data base.
 

trash

Well-Known Member
#4
Not sure you can delete a special date of all tickers for i.e. 700 symbols but you can create a copy of each symbol via AddToComposite with custom start and end date via Analysis window. After copy created you delete old tickers and rename copied tickers that have composite name like ~Copy of YM to just YM by using
I think you need to forget about using AddTocomposite for that issue as I just realized if using a code like this

Code:
atcmode = atcFlagDefaults | atcFlagEnableInExplore;
CloneNameStart = "~Copy of ";
indexname = CloneNameStart + Name();
Filter = Status( "barinrange" );

// As for setting composite name don't forget starting indexname with tilde!
if ( Status( "action" ) == actionExplore )
{ 
    AddToComposite( IIf( Filter, Open, Null ), indexname, "O", atcmode );
    AddToComposite( IIf( Filter, High, Null ), indexname, "H", atcmode );
    AddToComposite( IIf( Filter, Low, Null ), indexname, "L", atcmode );
    AddToComposite( IIf( Filter, Close, Null ), indexname, "C", atcmode );
    AddToComposite( IIf( Filter, Volume, Null ), indexname, "V", atcmode );
}

SetOption("RefreshWhenCompleted", True);

and setting range From-To in analysis then it will fill all barindexes outside of that range with NULL instead of removing them.

So AFAIK, the only solution is using export and Filter = Status( "barinrange" ). Otherwise contact support. Maybe they have a better solution.
 

mastermind007

Well-Known Member
#5
Not sure you can delete a special date of all tickers for i.e. 700 symbols but you can create a copy of each symbol via AddToComposite with custom start and end date via Analysis window. After copy created you delete old tickers and rename copied tickers that have composite name like ~Copy of YM to just YM by using

Code:
if ( Status( "action" ) == actionScan )
{
    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, "~Copy of " ) )
                st.Ticker = StrReplace( ticker, "~Copy of ", "" );
        }
    }
}

Buy = 0;
SetOption( "RefreshWhenCompleted", True );
Before doing all that make a backup of your data base!


BTW what is RT feeder? Is that a 3rd party tool?
Naah!! It is the one that I wrote last week :rofl:
 

mastermind007

Well-Known Member
#6
Next time you have similar problem don't save your data base but re-open that data base by a starting a second instance of AmiBroker. It will open the previous state of that data base.
Hmmm .... my experience with Ami is that everytime you close it and if any data was changed, it will save any unsaved data without prompting you ... Maybe there will be a preference setting somewhere to auto-save that I am yet to uncover.
 

trash

Well-Known Member
#7
Naah!! It is the one that I wrote last week :rofl:
???

It is the scan code I have posted on the AB yahoo list months ago! And even that one is an adjusted code provided by AB themselves on the knowledge base website.

Or do you mean the RT feeder?
 
Last edited:

trash

Well-Known Member
#8
Hmmm .... my experience with Ami is that everytime you close it and if any data was changed, it will save any unsaved data without prompting you ... Maybe there will be a preference setting somewhere to auto-save that I am yet to uncover.
That's why I have written to keep both instances open! Start a second AmiBroker instance while the first one is still open and open the DB in that second instance again then if the DB is started in that second instance close the first instance. then in the second instance that now is the first instance click save data base. This procedure is only for next issue not for current one where it is too late.

There is an auto save option at preferences-miscellaneous to save layouts, preferences templates. But AFAIK DB auto-save un-/check option is not available.
 
Last edited:

mastermind007

Well-Known Member
#9
As luck would have it, my machine was backed up by my brother two days ago

(I did not know about it until today evening)

so all I had to do was refresh from backup and roll two days forward.. Easy ...
 

mastermind007

Well-Known Member
#10
That's why I have written to keep both instances open! Start a second AmiBroker instance while the first one is still open and open the DB in that second instance again then if the DB is started in that second instance close the first instance. then in the second instance that now is the first instance click save data base. This procedure is only for next issue not for current one where it is too late.

There is an auto save option at preferences-miscellaneous to save layouts, preferences templates. But AFAIK DB auto-save un-/check option is not available.
OK OK !!! Now I understand. Neat work around!!!
 

Similar threads