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

Re: [amibroker] File I/O within AFL code.


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: RE: [amibroker] Re: 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: Wed, 14 Apr 2004 18:51:29 -0700

PureBytes Links

Trading Reference Links




Thanks 
a lot d and tj!
<FONT face=Arial color=#0000ff 
size=2> 
d... 
how do i run this? You wrote earlier to run the code in the AmiBroker directory 
while an EOD instance is Open. But "how" do I run it, I know nothing about 
scripts ... Do I give it a filename and extension (?) and run it from my 
desktop?
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>thanks,
<FONT face=Arial color=#0000ff 
size=2>herman.

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: dingo 
  [mailto:dingo@xxxxxxxxxxxx]Sent: Wednesday, April 14, 2004 9:11 
  PMTo: amibroker@xxxxxxxxxxxxxxxCc: 
  HermanSubject: RE: [amibroker] Re: Script to automate exporting of 
  EOD quotes and importing into Another DB - Need Help with the 
  oAB.Import.Importance: High
  <SPAN 
  class=015180801-15042004>After getting straightened out by TJ the script now 
  works.
  <SPAN 
  class=015180801-15042004> 
  <SPAN 
  class=015180801-15042004>'**************************************'Purpose: 
  Run A Procedure in 
  Amibroker'         that will 
  export quotes from'         one 
  database into CSV files '         
  and then import them into 
  '         another 
  database.''Created By: 
  dingo'**************************************
   
  <SPAN 
  class=015180801-15042004>Dim oABDim oAADim fsoDim fldrDim 
  flsDim fleDim flenamDim result
   
  <SPAN 
  class=015180801-15042004>dim RT_DB_Pathdim EOD_DB_Pathdim 
  Frmla_Pathdim CSV_Dirdim CSV_FleNamdim 
  FmtFleNam
   
  <SPAN 
  class=015180801-15042004>'-------------------------------------------------------' 
  change the following paths to suit your 
  configuration'-------------------------------------------------------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 = 
  "EOD_To_RT.Format"
   
  <SPAN 
  class=015180801-15042004>' declare object for Amibroker and the file system 
  objectset oAB = CreateObject("Broker.Application")Set oAA = 
  oAB.Analysisset fso = 
  CreateObject("Scripting.FileSystemObject")
   
  <SPAN 
  class=015180801-15042004>'------------------------------------------' 
  Delete all csv files in the CSV folder' so that we don't import any old 
  ones' that may still be 
  there'------------------------------------------'wscript.echo 
  "Cleaning Out " + CSV_Dir' set the folder objectSet fldr = 
  fso.GetFolder(CSV_Dir)' set the files objectSet fls  = 
  fldr.FilesFor Each fle in fls    flenam = 
  fle.name    ' make sure its a csv 
  file    if right(ucase(flenam), 4) = ".CSV" 
  then        ' Import the CSV File using 
  the correct format        
  fle.Delete    end ifNext' destroy the folder and 
  file objectsset fle = nothingset fls = 
  nothing '------------------------------------------' Set from 
  and to dates, and the 
  watchlist'------------------------------------------with 
  oAA    .RangeMode = 3    .RangeFromDate 
  = "01/01/2001"    .RangeToDate = 
  "12/31/2002"    .ClearFilters    
  .ApplyTo = 2    .Filter(0, "watchlist") = 29end 
  with '------------------------------------------' The 
  following is the "main" code for the' exporting and importing of the 
  data'------------------------------------------' Load EOD Data 
  Base'wscript.echo "Loading EOD Database: " + EOD_DB_PathIf 
  oAB.LoadDatabase(cstr(EOD_DB_Path)) Then    ' Load the AFL 
  for Building the CSV File    'wscript.echo "Loading AFL: " 
  + Frmla_Path    if oAA.LoadFormula(cstr(Frmla_Path)) 
  Then        ' Run The 
  Scan        'wscript.echo "Running 
  Scan"        result = oAA.Scan 
          ' now load the RT 
  Database        'wscript.echo "Loading 
  RT Database: " + RT_DB_Path        If 
  oAB.LoadDatabase(cstr(RT_DB_Path)) 
  Then            ' 
  import each csv file in the EODexports folder 
              ' set 
  the files 
  object            
  Set fls  = 
  fldr.Files            
  For Each fle in 
  fls                
  flenam = 
  fle.name                
  ' make sure its a csv 
  file                
  if right(ucase(flenam), 4) = ".CSV" 
  then                    
  ' Import the CSV File using the correct 
  format                    
  CSV_FleNam = CSV_Dir + "\" + 
  flenam                    
  'wscript.echo "Importing " + 
  CSV_FleNam                    
  result = oAB.Import(0, cstr(CSV_FleNam), cstr(FmtFleNam)) 
                      
  if result <> 0 
  Then                        
  msgbox "Error Running 
  Import"                        
  Exit 
  For                    
  end 
  if                
  end if            
  Next    
              
  oAB.RefreshAll()            
  'wscript.echo "Saving RT 
  Database"            
  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=015180801-15042004>' destroy all objectsset fle = nothingset fls 
  = nothingset fldr = nothingset fso = nothing
   
  <FONT face="Courier New" 
  size=1>Set oAA = Nothingset oAB = 
  nothing<SPAN 
  class=015180801-15042004>
  <FONT face="Courier New" 
  size=1><FONT face=Arial 
  size=2>------------------------------------------------
  <FONT face="Courier New" 
  size=1> here is 
  the format file 
  <FONT face="Courier New" 
  size=1><FONT face=Arial 
  size=2> 
  <FONT face="Courier New" 
  size=1>$FORMAT 
  Date_YMD, Open, High, Low, Close, Volume, Skip$SKIPLINES 0$SEPARATOR 
  ,$CONT 1$GROUP 255$AUTOADD 1$DEBUG 1$BREAKONERR 
  1
  <FONT 
  face=Arial>Thanks TJ!
   
  d<SPAN 
  class=015180801-15042004>
  
  
    
    
    From: Herman van den Bergen 
    [mailto:psytek@xxxxxxxx] Sent: Tuesday, April 13, 2004 5:11 
    PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: 
    [amibroker] Re: Script to automate exporting of EOD quotes and importing 
    into Another DB - Need Help with the oAB.Import.
    
    <FONT face=Arial color=#0000ff 
    size=2>OK, thanks d, i understand. Probably not worth the effort because it 
    doesn't take very long to do the N100 and needs to be done only once a 
    day.
    <FONT face=Arial color=#0000ff 
    size=2> 
    <FONT face=Arial color=#0000ff 
    size=2>h
    <FONT face=Arial color=#0000ff 
  size=2> 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.