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

[amibroker] Understanding the Harmonic Mean, II


  • 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: "Tomasz Janeczko" <amibroker@xxxxxx>
  • Date: Tue, 13 Apr 2004 06:32:59 -0700

PureBytes Links

Trading Reference Links




Dale,
 
You are not getting error message, but just using reverse 
logic in this:
 
if not oAB.Import(0, 
CSV_FleNam, FmtFleNam) 
Then                    
msgbox "Error Running 
Import"                    
Exit 
For                
end if
Note that Import function returns not BOOLEAN but 
integer.
And ZERO means SUCCESS. Non-zero value are various 
error codes.
Your code interprets return value of zero as failure which is 
wrong.
 
So you should write this instead:
 
errCode = oAB.Import(0, 
CSV_FleNam, FmtFleNam);
if errCode <> 0 
Then                    
msgbox "Error Running Import, Code:" + 
errCode                    
Exit 
For                
end if
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE dir=ltr 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  dingo 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Tuesday, April 13, 2004 6:36 
  AM
  Subject: [amibroker] Script to automate 
  exporting of EOD quotes and importing into Another DB - Need Help with the 
  oAB.Import.
  
  <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<FONT face="Courier New" 
  color=#0000ff size=1><SPAN 
  class=364573004-13042004>            
  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> 
  
    
    
    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=Tahoma 
      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
      
        
        
        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="jpg00056.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="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
        group FAQ at: <A 
        href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
        Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
        SUGGESTIONS to 
        suggest@xxxxxxxxxxxxx-----------------------------------------Post 
        AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web 
        page: <A 
        href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
        group FAQ at: <A 
        href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
        Send BUG REPORTS to 
    bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
    SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    


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: ""