Convert Excel macros to run with LibreOffice Calc?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Convert Excel macros to run with LibreOffice Calc?
I would like to bulk download historical stock data, for example for the constituents of the FTSE100 - 100 different stocks. There are a great many webpages that suggest ways of doing bulk downloads, but Yahoo and Google keep changing and updating things, so only the most recent are likely to work, and they also require a lot of knowledge of Matlab or Python for example, so would be very difficult to use for someone unfamiliar with those languages.
Except that the macros give an error message when the spreadsheet is run in LibreOffice Calc 5.
Does anyone know how to get it working please?
Incidently, LibreOffice Calc 5 will not or cannot allow me to save the spreadsheet with macros.
Thanks.
ps. I would be willing to pay a smallish amount to bulk download historical stock data for British stocks with a capital value down to say £50million if anyone knows of a company that offers such a service. That would be many hundreds of stocks I expect.
Last edited by grumpyskeptic; 09-16-2018 at 12:48 PM.
The error message is the same in both spreadsheets. After doing nothing except clicking on the "bulk download" button on the spreadsheet, I get an error message saying -
It seems like something merely cosmetic, which I do not care about.
Looking through the code I see that it refers to the "crumb" thing, so with Excel it probably works.
Edit: So would it work if I just deleted every reference to "TintAndShade"?
I would be happy to just have some bare-bones BASIC code without any spreadsheet that saved the .csv files to HD, but do not know what to cut away to get this. The "crumb" problem is the difficult thing.
Thanks.
Last edited by grumpyskeptic; 09-17-2018 at 01:36 PM.
The Open/LibreOffice API is a development which aims at providing functionality in these office-packages similar to the Microsoft®-suites. I am not aware of any incompatibilities between OpenOffice and LibreOffice, so the current API-descriptions and tutorials should be okay: http://www.pitonyak.org/oo.php, for example. But there is more.
Do not expect something which is not Microsoft® to work like what is Microsoft®, OLE, COM or other stuff which does not exist in Linux!
I tried running both the 32bit and 64bit .exe programs with Wine, but after installation nothing happened and I could not see the installed programs on the menu anywhere, including not under Wine. I see that the Windows .exe files are actually compressed files consisting of various things such as dlls.
How difficult would it be to compile the C++ code under Linux? I imagine it may need some tweaking for Linux. I am not a programmer.
As of v0.6.0 Yahoo!, Google Options, Google Quotes and EDGAR have been immediately deprecated due to large changes in their API and no stable replacement.
Reason for mention that specific tool is because it's recently updated and saying that it's not working.
So other older tools that may of depended on similar methods may be broken (possibly including this excel script)
EDIT:
It seems yahoo may be working.
I wrote up something but I'm not sure if the output is what you're looking for?
I am principally interested in British stocks. There are designated for example as TSCO.L for Yahoo Finance, and LON:TSCO for Google Finance. MRW.L and LON:MRW are two other examples.
It seems that Google are no longer providing historical stock data (or with great regret any stock screening), but the British Yahoo webpage for historical data for TSCO.L is https://uk.finance.yahoo.com/quote/T...y&frequency=1d
It may be possible to copy the URL for the .csv file and replace the details. The "crumb" at the end might not be a problem if you are already viewing the webpage and hence have the cookie that it apparently checks for.
The tinkering I have done so far with the .csv file URL indicates that the period1 and period2 numbers are in seconds with a start date of the first of January 1970. I tried replacing the period1 number with 864000, which corresponds to the 11th. of January 1970, and it did successfully download a csv file starting from the earliest dates it had available.
I have begun trying to learn Python, but do not know how to use URLS within it yet.
Edit/update: The bare-bones program I have in mind would involve going to a webpage like the link above, copying the link for the .csv file download, and then entering this URL string into the program. The program then replaces the period1 number with 0 and then replaces the stock code with a list I have in a text file, saving the downloaded .csv files to hard-disk. It does this slowly, to avoid upsetting the server.
Last edited by grumpyskeptic; 09-22-2018 at 05:56 AM.
Doing this "correctly" might not be worth the effort in python due to the frequent changes of the api. Unless you use pandas-datareader
Here's a "hack" you can try.
On the finanical page with the "download csv" buttom, hit F12 for web developer tools (Firefox)
Go to the network tab, then click on download csv on the actual website
Right click on the top request which should have a "200" (valid) response on it in the web developer tools. Copy the request as a curl command and copy it in a similar fashion to the below script. The \ and newlines before every -H isn't needed, but helps with readability. Copy and paste all on one line in fine for the curl command.
Thank you greatly, Field95, very good of you to write the code.
I have not tried it yet, and know nothing about Bash nor have I ever used it.
What book that would provide just enough knowledge to use the code above would anyone recommend?
Thanks.
You can always look at man bash. There are many guides on the internet If you've ever used the terminal, it's likely you've used bash. This is just a bit of looping structure.
There's very little actual bash code here so I'll break it down
This tells the file that it is a bash script so that you can run it like "./file" instead of "bash file"
Code:
#!/bin/bash
A typical for loop. Note the "$@" Not positive the quotes are needed here.
If you were to run a program like ./file a b c the $@ would contain "a b c" and the for loop would iterate
like
Code:
./file a b c
for i in $@
do
echo "$i"
done
a
b
c
Code:
for stock in "$@";
do
This is the copied command from web developer tools.
A few changes are made, where it will output (instead of to the screen), usage of "$stock" for the for loop so that you can quickly download each one. Note I didn't write this part. It was just copied from the browser
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.