AmiQuote Poland does not work with OLE automation. My AmiBroker db has symbols such as BHW.PL which needs to be translated to BHW at Stooq.pl Symbol translation table DOES NOT seem to be loaded, although it exists at C:\Program Files (x86)\AmiBroker\AmiQuote\yahooi.translations :
AmiQuote Poland works manually, without automation, using same AmiQuote 3.27 32 bit:
AmiQuote Hungary works with OLE automation, as no symbol translation is needed, both my db and Stooq.pl have symbols in Symbol.HU format:
My ruby automation does:
ab = WIN32OLE.new("Broker.Application") # C:\Program Files (x86)\AmiBroker\Broker.exe
ab.LoadDatabase( dirAB + db )
stks = ab.Stocks()
qty = stks.Count
puts "Opening #{db} database with #{qty} pre-existing symbols"
puts "Starting AmiQuote 32-bit"
aq = WIN32OLE.new("AmiQuote.Document") # C:\Program Files (x86)\AmiBroker\AmiQuote\Quote.exe
if @country == "PL"
tickerList = plTickers # 90 symbols
elsif @country == "HU"
tickerList = huTickers # 38 symbols
elsif
..
end
if @source == "StooqHistorical"
aq.Source = 7
puts "Using Stooq Historical as the source of data"
..
end
toDate = (d + 0).strftime("%m/%d/%Y") #date in 02/16/2016 format
puts "From: " + fromDate
puts "To: " + toDate
aq.From = fromDate
aq.To = toDate
aq.AutoImport = true #import automatically
dst = Time.now
dstTimeZone = dst.strftime("%Z")
dstFormatted = dst.strftime("%m-%d-%Y %H:%M:%S")
puts "#{comp} Time Zone is #{dstTimeZone}"
puts "Download started at #{dstFormatted}"
aq.Download() #starts download
#wait until download is finished
while aq.DownloadInProgress || aq.ImportInProgress
sleep 1 #check InProgress every x seconds
end
det = Time.now
detFromatted = det.strftime("%m-%d-%Y %H:%M:%S")
download_took = (det - dst)/60
puts "Download completed at #{detFromatted}"
puts "Download took #{download_took.round} minutes"
I suspect that there is something wrong with my Symbol Translation file, but do not know why it would work properly when done manually, but not read the symbol translation table via OLE automation.
5) Symbol Translation table seems to display correctly through AmiQuote / Tools / Symbol Translation table menu for Stooq.pl.
6) C:\Program Files (x86)\AmiBroker\AmiQuote\yahooi.translations is not read-only or hidden.
7) It is a bit odd that the symbol paris for Stooq.pl are saved as yahooi.translations as opposed to say stooqpl.translations but it matches entries in AmiQuote / Tools / Symbol Translation table menu for Stooq.pl
You are starting AmiQuote in WRONG directory. You should start AmiQuote so CURRENT WORKING DIRECTORY is set properly to where it is located. Otherwise it won’t find translation files because it refers to them using CURRENT WORKING DIRECTORY instead of absolute path. You should start it explicit in correct folder. Otherwise if you run it from your “ruby” it would very likely have wrong working directory (such as where your ruby file is or in C:\Windows or some other random place).
Originally I started my ruby file AmiQuote6.rb which opens AmiQuote from C:\Dropbox\Trading where
C:\Dropbox\Trading\AmiQuote6.rb
C:\Program Files (x86)\AmiBroker\AmiQuote\Quote.exe
C:\Program Files (x86)\AmiBroker\AmiQuote\yahooi.translations
Next I copied my rb code file to C:\Program Files (x86)\AmiBroker\AmiQuote\ and kicked off rb from that directory, all imports still failed
C:\Program Files (x86)\AmiBroker\AmiQuote\AmiQuote6.rb
C:\Program Files (x86)\AmiBroker\AmiQuote\Quote.exe
C:\Program Files (x86)\AmiBroker\AmiQuote\yahooi.translations
Next I copied my translations file to C:\Dropbox\Trading\ and kicked off rb from that directory, all imports still failed
C:\Dropbox\Trading\AmiQuote6.rb
C:\Program Files (x86)\AmiBroker\AmiQuote\Quote.exe
C:\Dropbox\Trading\yahooi.translations
Next I copied my translations and rb files to c:\ruby\bin\ and kicked off rb from that directory, all imports still failed
c:\ruby\bin\AmiQuote6.rb
C:\Program Files (x86)\AmiBroker\AmiQuote\Quote.exe
c:\ruby\bin\yahooi.translations
I'm also attaching a screenshot of how yahooi.translations file looks like with all characters showing, in case there is something wrong with it, note that it has my db file symbol such as BHW.PL comma space and symbol at Stooq.pl such as BHW, then it is followed by CR CR LF and then the next pair of translation symbols.
Copying files is useless excercise. OLE does not work that way. OLE server is registered with path in the Windows REGISTRY, and no amount of copying would ever fix that.
Again I can only repeat what I wrote already: you need to START (launch) AmiQuote with proper current working directory.
Current working directory is set when you create PROGRAM SHORTCUT and set “Start In” field properly and run program from that shortcut. If you run program in any other way than properly created shortcut, it will get working directory of parent or in case of script the location of CSCRIPT/WSCRIPT which is typically C:\Windows\System32 folder.
Would you please point out the discepency between what you said:
TomaszOwner3d You are starting AmiQuote in WRONG directory. You should start AmiQuote so CURRENT WORKING DIRECTORY is set properly to where it is located. Otherwise it won’t find translation files because it refers to them using CURRENT WORKING DIRECTORY instead of absolute path. You should start it explicit in correct folder. Otherwise if you run it from your “ruby” it would very likely have wrong working directory (such as where your ruby file is or in C:\Windows or some other random place).
and what I said? :
9. Next I copied my rb code file to *C:\Program Files (x86)\AmiBroker\AmiQuote* and kicked off rb from that directory, all imports still failed C:\Program Files (x86)\AmiBroker\AmiQuote\AmiQuote6.rb C:\Program Files (x86)\AmiBroker\AmiQuote\Quote.exe C:\Program Files (x86)\AmiBroker\AmiQuote\yahooi.translations
If you launch it before invoking the script, you can see where the different processes are running (in this case you are interested in Quote.exe).
I modified your .rb script to use a database of mine and found that to use the translation tables - on my machine/configuration - I had to copy them in the C:\Windows\System32 folder since the Quote (64bit) instance launched by the Ruby script "Current directory" was there:
Thank you for pitching in, beppe. Just like in your env, ruby invoked Quote.exe current directory is C:\Windows\System32\ but copying translation files ( C:\Windows\System32\yahooi.translations ) there does not help, all imports still fail.
I don’t know how to “start AmiQuote so CURRENT WORKING DIRECTORY is set properly to where it is located” in ruby…