[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Script to automate exporting of EOD quotes and importing into Another DB - Need Help with the oAB.Import.


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: RE: [amibroker] Script to automate exporting of EOD quotes and importing into Another DB - Need Help with the oAB.Import.
  • From: "Herman van den Bergen" <psytek@xxxxxxxx>
  • Date: Tue, 13 Apr 2004 04:10:07 -0700

PureBytes Links

Trading Reference Links




Thank 
you very much for the script d,
<FONT face=Arial color=#0000ff 
size=2> 
A few 
questions... where do we run this code? In the AA? Scan? From an RT or EOD 
instance?
Could 
it be that you need double backslashes in your path?
<FONT face=Arial color=#0000ff 
size=2> 
did 
you cc your email to AB support?
<FONT face=Arial color=#0000ff 
size=2> 
thanks 
for the effort!
<FONT face=Arial color=#0000ff 
size=2>herman

  <FONT face=Arial 
  size=2>-----Original Message-----From: dingo 
  [mailto:dingo@xxxxxxxxxxxx]Sent: Tuesday, April 13, 2004 12:37 
  AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] 
  Script to automate exporting of EOD quotes and importing into Another DB - 
  Need Help with the oAB.Import.Importance: High
  <SPAN 
  class=364573004-13042004>Herman:
  <SPAN 
  class=364573004-13042004> 
  <SPAN 
  class=364573004-13042004>Here's a script I put together to do what's in the 
  subject line. BUT I'm getting an error on the import and haven't been able to 
  figure out why.
  <SPAN 
  class=364573004-13042004> 
  <SPAN 
  class=364573004-13042004>'************************************''Purpose: 
  Run A Procedure in 
  Amibroker'         that will 
  export EOD quotes'         to a 
  CSV file and then import'         
  them into the RT database.'Created By: 
  dingo'************************************'
   
  <SPAN 
  class=364573004-13042004>Dim oABDim oAADim fsoDim fldrDim 
  flsDim fleDim flenamDim result
   
  <SPAN 
  class=364573004-13042004>dim RT_DB_Pathdim EOD_DB_Pathdim 
  Frmla_Pathdim CSV_Dirdim CSV_FleNamdim 
  FmtFleNam
   
  <SPAN 
  class=364573004-13042004>' change the following paths to suit your 
  configuration
   
  <SPAN 
  class=364573004-13042004>RT_DB_Path = "C:\Program 
  Files\Amibroker\Data"EOD_DB_Path = "C:\Program 
  Files\Amibroker\TC2000"Frmla_Path = "C:\Program Files\Amibroker\AFL\EOD 
  Export.Afl"CSV_Dir = "C:\Program Files\Amibroker\Output"FmtFleNam = 
  "C:\Program Files\Amibroker\EOD_To_RT.Format"
   
  <SPAN 
  class=364573004-13042004>set oAB = CreateObject("Broker.Application")Set 
  oAA = oAB.Analysisset fso = 
  CreateObject("Scripting.FileSystemObject")
   
  <SPAN 
  class=364573004-13042004>' Set from and to dateoAA.RangeFromDate = 
  "01/01/2001"oAA.RangeToDate = "12/31/2002"
   
  <SPAN 
  class=364573004-13042004>' Load EOD Data BaseIf 
  oAB.LoadDatabase(EOD_DB_Path) Then    ' Load the AFL for 
  Building the CSV File    if oAA.LoadFormula(Frmla_Path) 
  Then        ' Run The 
  Scan        result = oAA.Scan 
          ' now load the RT 
  Database        If 
  oAB.LoadDatabase(RT_DB_Path) 
  Then            ' 
  import each csv file in the EODexports folder 
              ' set 
  the folder 
  object            
  Set fldr = 
  fso.GetFolder(CSV_Dir)            
  ' set the files 
  object            
  Set fls  = fldr.Files
  <SPAN 
  class=364573004-13042004>            ' 
  this will import every file in 
  <SPAN 
  class=364573004-13042004>            
  ' the directory so be careful<SPAN 
  class=364573004-13042004><FONT face=Arial 
  size=2>            For 
  Each fle in 
  fls                
  flenam = 
  fle.name                
  ' Import the CSV File using the correct 
  format                
  CSV_FleNam = CSV_Dir + "\" + 
  flenam                
  wscript.echo "Importing " + 
  CSV_FleNam                
  if not oAB.Import(0, CSV_FleNam, FmtFleNam) 
  Then                    
  msgbox "Error Running 
  Import"                    
  Exit 
  For                
  end if            
  Next    
              
  oAB.RefreshAll()            
  oAB.SaveDataBase            
  MsgBox "Finished"        
  Else            
  msgbox "Can't Load RT Database"        
  End IF    
  else        msgbox "Can't Load EOD 
  Export.Afl"    End If    
  Else    MsgBox "Cant Load EOD Database"End 
  If
   
  <SPAN 
  class=364573004-13042004>Set oAA = Nothingset oAB = 
  nothing
   
  <SPAN 
  class=364573004-13042004>Here's the contents of the format 
  file:
  <SPAN 
  class=364573004-13042004> 
  <SPAN 
  class=364573004-13042004>$FORMAT Date_YMD, Open, High, Low, Close, 
  Volume$SKIPLINES 0$SEPARATOR ,$CONT 1$GROUP 255$AUTOADD 
  1$DEBUG 1$NOQUOTES 1BREAKONERR 1
  <SPAN 
  class=364573004-13042004> 
  <SPAN 
  class=364573004-13042004>Maybe TJ will see this and 
  straighten me out.
  <SPAN 
  class=364573004-13042004><FONT face=Arial 
  size=2> 
  <SPAN 
  class=364573004-13042004>BTW the formula mentioned is the one you submitted 
  previously
  <SPAN 
  class=364573004-13042004> 
  <SPAN 
  class=364573004-13042004>d
  <SPAN 
  class=364573004-13042004> 
  <SPAN 
  class=364573004-13042004> 
  
    <FONT 
    face=Arial size=2>
    
    From: Herman van den Bergen 
    [mailto:psytek@xxxxxxxx] Sent: Monday, April 12, 2004 3:22 
    PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: 
    [amibroker] Re: Real-Time Trading System 
Examples
    
    <FONT face=Arial color=#0000ff 
    size=2>for example?
    <FONT face=Arial color=#0000ff 
    size=2> 
    <FONT face=Arial color=#0000ff 
    size=2>herman
    
      <FONT face=Arial 
      size=2>-----Original Message-----From: dingo 
      [mailto:dingo@xxxxxxxxxxxx]Sent: Monday, April 12, 2004 1:51 
      PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: 
      [amibroker] Re: Real-Time Trading System ExamplesImportance: 
      High
      <FONT face=Arial 
      color=#0000ff size=2>Better yet - use a small script to do the importing. 
      That way you specify the name of the format file.
      <FONT face=Arial 
      color=#0000ff size=2> 
      <FONT face=Arial 
      color=#0000ff size=2>d
      
        <FONT 
        face=Arial size=2>
        
        From: Herman van den Bergen 
        [mailto:psytek@xxxxxxxx] Sent: Monday, April 12, 2004 1:41 
        PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: 
        [amibroker] Re: Real-Time Trading System 
        Examples
        
        Here is the procedure I used, if it can be 
        improved please let me know. Edit the path, filename and name of your 
        EOD database and Scan this code (based on that in the AB Help) on the 
        Watchlist you want to import  into your RT database. So far so good 
        :-) not too much work, since it has to be done only once a 
        day.
        
        if(GetDatabaseName() == "EOD-QP2-31MAR04") // This prevents me from 
        Scanning the RT DB by 
        accident{Buy=Sell=Short=Cover=0;Filter=Status("LastBarInTest");// 
        The following code exports quotes of current stock to 
        quotes.csv comma separated filePath = "C:\\Program 
        Files\\AmiBroker\\EODexports\\";fh = fopen( Path+Name()+"-EOD.csv", 
        "w");if( fh )        
        {//      fputs( 
        "Date,Open,High,Low,Close,Volume\n", fh 
        );        y = 
        Year();        m = 
        Month();        d = 
        Day();        for( i = 0; i 
        < BarCount; i++ )        
                
        {        
                ds = 
        StrFormat("%02.0f-%02.0f-%02.0f,", y[ i ], m[ i ], d[ i ] 
        );        
                fputs( ds, fh 
        );        
                qs = StrFormat("%.4f, %.4f, 
        %.4f, %.4f, %.0f\n", O[ i ], H[ i ], L[ i ], C[ i ], V[ i ] 
        );        
                fputs( qs, fh 
        );        
                
        }        fclose( fh 
        );        }} 
        
        
        
        Here are the import settings I used... does anybody know how to make 
        this setting default? It keeps reverting back to its original setting. 
        
        
        <IMG alt="" hspace=0 
        src="jpg00055.jpg" align=baseline 
        border=0>Send BUG 
        REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
        suggest@xxxxxxxxxxxxx-----------------------------------------Post 
        AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web 
        page: <A 
        href=""><FONT 
        face=Arial 
        size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
        face=Arial size=2>--------------------------------------------Check 
        group FAQ at: <A 
        href=""><FONT 
        face=Arial 
        size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
        face=Arial size=2> <FONT face=Arial 
        size=2>Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
        suggest@xxxxxxxxxxxxx-----------------------------------------Post 
        AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web 
        page: <A 
        href=""><FONT 
        face=Arial 
        size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
        face=Arial size=2>--------------------------------------------Check 
        group FAQ at: <A 
        href=""><FONT 
        face=Arial 
        size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
        face=Arial size=2> 
    <FONT face=Arial 
    size=2>Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <FONT 
    face=Arial 
    size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
    face=Arial size=2>--------------------------------------------Check 
    group FAQ at: <A 
    href=""><FONT 
    face=Arial 
    size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
    face=Arial size=2> Send 
    BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <FONT 
    face=Arial 
    size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
    face=Arial size=2>--------------------------------------------Check 
    group FAQ at: <A 
    href=""><FONT 
    face=Arial 
    size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
    face=Arial size=2> 
    


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.






Attachment: Description: ""