Market stats update

Time for my yearly update on where we are in the markets … and computer says “fairly priced”, believe it or not. Median PE is 15.9, which looks “pretty average” to me.

So we’re probably not in bubble territory.

Stats are based on those with a market cap of at least £100m, and where PE and PBV data are not null.

You can see a historical list here .

stats.png

Advertisements
Posted in Uncategorized | Leave a comment

Timing my #RaspberryPi 3

I noticed that mu RPi 3 seems rather faster than I expected originally. I have a home-brew accounting package, and I decided to run it through the “time” command. Here are the results:

       RPi   Vivo Vostro
real 0.279  0.236  0.127
user 0.220  0.200  0.133
sys  0.080  0.060  0.026

The machines involved where an RPi3 (Raspberry Pi 3), an ASUS VivoPC (possibly ~ 2013 vintage) and a Dell Vostro (2010). The timings are in seconds. Lower values imply faster processing.

Raspbian is lightning fast at booting and shutting down, and I get the impression that they must have done some proper optimisation to make the system so responsive.

My Vostro is my “proper desktop” machine. It cost £515. That did include keyboard, mouse, and monitor.

I can’t find the invoice for my Vivo, but I reckon is was about £150, and came without peripherals. I use it as a cheapo server computer. It has been running Arch Linux since 2015. The Vivo uses Intel architecture. If my main computer ever went kaput, I would probably use my Vivo as my main machine. I would probably stick to Arch, although I might consider ReactOS.

Because it’s only a cheapo machine, I am not that surprised to learn that the Vivo runs at about half the speed of my Vostro. I love the small form-factor of the ASUS, even more that my Vivo, which is a slimline. I like the slimline, too. It’s just small enough to be elegant. I hate the “box of bricks” look to regular-sized computers.

The real surprise here is just how fast the RPi is. It is running at a similar speed as my Vivo, and only about half to a third of the speed of my regular PC.

I continue to be amazed at the RPi, and I am tempted to try to put together some goofy electronics project, just because I can.

Posted in Uncategorized | Leave a comment

Lessons learned from #plaintextaccounting in UNIX

I have been using UNIX to keep track of my finances for a long time. I have written quite a few packages over the years in C, C++, Haskell, Python, Tcl and Lisp.

I have used a number of publicly-available applications, including clacct, beancount and the ever-popular ledger, by John Wiegley.

The problem I have found with programs like ledger (and all due to respect to John, who holds the prestigious position of maintaining Emacs!) is that they don’t do everything I want, has quite a steep learning curve, and it’s particularly difficult to compose in a pipeline. Ledger likes to be the final output, which makes it difficult to do stuff for further processing.

Ledger is written in C++ and, according to cloc, is 34k lines long. That is a big program! I think that ledger is being re-written in Haskell. I have enjoyed (and rued) programming in Haskell. Nowadays, I do nearly all of my programming in C++, though. At the end of the day, C++ gets the job done, is close to the level of Python (esp. now with C++17 ), and it’s one less dependency to install. I use Arch Linux, so I’m keen to keep stuff off my system.

In contrast, my own effort in C++ weighed in at about 3000 lines of code. It’s functionality is quite good; it even downloaded share prices, for example.

But I’ve basically abandoned all that in favour of bash/awk/sed scripts. The scripts weigh in at about 350 lines of code. I’m sure you’ll agree, that’s quite a reduction.

So the first lesson might be: roll your own system.

Create a “DSL” (doman-specific language) using tab-separated delimiters

The thing you definitely don’t want to do is create a parser. That will require code, code, and more code.  Also, anything that might potentially want to process your input has to be able to understand the input. That means that you have a parser for each program.

If, instead, you create your input data in a textual form, using tabs to separate fields, you have a trivially-parseable input source. It plays well with UNIX tools, especially awk. Your commands can be quite simple. For example, I have a “command” called “ntran”, which specifies a date, a debit account, a credit account, and amount, and a description.

I also have “etran”, which is similar, but works with shares.

If you need fancier (which I don’t use), for example being able to group a set of transactions together and have a balance be set to an account, then you can still do that. I had invented three names for grouping: trn-start (start a transaction), trn (add a transaction line) and trn-end (end a transaction). trn-end takes the running balance as the contra to a specified account.

I can do this via the magic of …

awk is awesome

awk really is a programming language all to itself. My scripts now use it ubiquitously. awk has dictionaries, pattern matching, arithmetic and logical operators. That’s the bulk of what you need. And, if you had used tabs to separate fields within records, it is very easy to process records that your script is interested in.

sed, tee, pee and pipes

awk doesn’t solve everything, of course. sed has its uses, too.

I am leaning away from using intermediate files to store data for later processing. I am leaning more towards a “pure pipe” solution. You may need tee (which can store data in a file as well as printing to stdout) and pee (which passes stdin to several processes).

What’s interesting here is that you can insert data capture in a pipe stream. I wrote a very small util called “teet”. teet takes two arguments, a capture flag, and an output file. If the capture flag is set to 0, it just passes stdin to stdout. If it is set to  something else, it copies stdin to the file as well as stdout (using tee).

Consider how neat that is. If I need to debug stuff in C++, I have to start my debugger and set my breakpoint at  a suitable point to see what state the data is in. But if I use my teet command, I can capture state directly to an output file. Or, if I don’t want to debug, I just set the flag to 0. Very convenient. And I can give the debug files meaningful names.

Don’t forget sort

My inputs are not in date order. I want it sorted in date order primarily, but then in input order secondarily. I achieve this using awk. I create a sort field as the first record, consisting of two parts: the date, and a line number. The line number is obtained by using a counter in awk.

When I do this, I can redirect the output to the sort command, and then remove the index I created using sed.

Aggregating

One thing that I found difficult to get to grips with in John’s ledger program is in the aggregation of accounts into “meta accounts”.

One approach is to use its nesting ability. That’s quite cumbersome, though, even with the aliasing facility.

Another approach is to using tagging. That’s kinda OK, but sometimes I just want a grand total.

My own approach using shell scripts is to create a text driver file. Here’s some of what it looks like:

gaap inc div
gaap inc int
gaap inc wag
gaap inc = ordinary-income

gaap exp amz
gaap exp car
gaap exp chr
gaap exp cmp
gaap exp hol
gaap exp isp
gaap exp msc
gaap exp = ordinary-expenses

gaap ordpr inc
gaap ordpr exp
gaap ordpr = ordinary-profit
...

What happens is that it prints out the balances for any accounts it sees (third column), whilst accumulating the balance for that account in the dictionary var it sees in the second column. When it sees an “=” sign in the third column, it prints the balance. Simples.

If wanted to keep a daily track of net assets, I could grep for that particular field.

In conclusion

There are so many things you can achieve, often quite simply, by adhering to the UNIX philosophy.

 

Posted in Uncategorized | Leave a comment

Going green on #vim

Since reading Stop the Vim Configuration Madness , I decided to have a review of my vimrc file.

I decided to ditch my colour schemes as an experiment and just use monotone. I could have been lazy and just ditched everything, but I decided to go for a green-on-black retro/Matrix type feel:

hi Normal ctermfg=DarkGreen ctermbg=Black

That’s my colour scheme now. Since starting the experiment, I can’t say that readability has gone down, so I am inclined to keep the setup I aready have.

In my view, colour schemes always get something wrong. It is usually with comments or strings. Somewhere, wherever, colour contrast is poor, and it is difficult to read the text. Always! The fix is to abandon all attempts to find the perfect colour scheme, and just use monotone.

I have been much of a fan of plugins, but I do use two:

  • plug – a simple plugin manager. It is arguable if this counts as a plugin, and may even be obsoleted by the latest version of vim
  • emmet – an html extension. I would be loathe to give this the boot, as it is very convenient for adding html tags.

Another benefit of cutting out the clutter is that it simplifies your configuration, takes up less disk space, there’s less you need to store in your git dotfiles repo, and it is easier to migrate to new machines.

So there we have it. Less is more.

vim.png

Posted in Uncategorized | Leave a comment

Magic Hat – SOM stays in

The MHP (Magic Hat Portfolio) on Stockopedia (http://www.stockopedia.com/fantasy-funds/magic-hat-463/) is an experiment by me to see if a human can improve on a mechanical Greeblatt Magic Formula screen. I am trying to weed out “mistakes” that I feel the screening commits: unseasoned companies, scams, foreign companies (particularly Chinese), fishy accounting, and statistical quirks. Apart from that, I am agnostic as to the sector the company operates in, although I will try to avoid heavy concentration in any one sector. I will mostly apply “Strategic Ignorance”, by which I mean that I wont try to be clever in my stockpicking. My picking will be mostly mechanical. A summary of most of my Magic Hat articles can be found on the web page http://www.markcarter.me.uk/money/greenblatt.htm This will allow you to see, at a glance, what shares have been bought and sold in the past, as well as what shares have been rejected from consideration and why.

SOM (Somero Enterprises) is due to exit the portfolio by rotation. It is up 65% since its introduction, which is nice to see. Since it has a Stockopedia StockRank in the 90’s and still passes the Magic Formula Screen, it stays in.

On a semi-related note, I shall be working on some tools to help with creation of Stockopedia portfolios. Stockopedia has some useful facilities for uploading and downloading your portfolio, and it seems like a good idea to use them. I was originally going to write it as some UNIXy shell scripts, but I think I will use python instead. That way, they will work on any platform.

Posted in Uncategorized | Leave a comment

Taking #reactos for a spin

ReactOs 0.4.6 is pretty impressive. I tried using it in the past, and it was hellishly buggy and unusable. The latest incarnation seems a lot more stable, and hasn’t crashed on me.

I am using it in VirtualBox. It was lightning-quick to install, and it runs fast as an OS, too. Internet worked out of the box. I loved the repos. You can add free software with a few clicks of the button. There’s things like GIMP, Inkscape, LibreOffice and a whole host of other packages. For the geekier types there’s Midnight Commander. I installed the K-Meleon web browser. It worked well, although Youtube was not supported.

It would make a great test platform.

Well done, chaps.

ros.jpg

Posted in Uncategorized | Leave a comment

I am very impressed by the #raspberrypi 3

After losing patience with my cubietruck, I decided to buy an RPi 3 (Raspberry Pi 3). I bought the “official” kit, which included a nice sleek black case, the RPi 3 itself, a power adapter and the noobs uSD (micro SD card) installer. On Amazon, people had reported problems with the uSD card. I did not have any problems, so I assume that they have ironed them all out. The kit cost £47 altogether. Try buying an Intel PC for anything like that price!

I noticed that the RPi 3 is dramatically faster than the RPi 2. The performance enhancements seems to go far beyond what a comparison of the raw specs of the machines might imply.

My comments on the hardware:

  • power adapter. Yes! Finally! We now no longer have to mess around with using a powered USB hub and attaching devices to it. That’s a messy solution. The RPi 2 could not even handle a pen drive plugged into its USB ports, making it considerably inconvenient. RPi 3 fixes that issue.
  • 4 USB ports. This enables me to use a laptop SATA drive as a root partition, using 2 USB ports (one for power, one for data), with spare ports for the keyboard and mouse, should I want to use it that way.
  • HDMI. OK, that was in the RPi 2, too. HDMI is better than DVi because I can get the audio coming out of my telly, rather than have to attach separate speakers.
  • Wifi on board. I would not say this is a “fantastic” feature, but it did allow me to ditch the requirement of an ethernet cable. So, again, one less item of clutter. Setting up Wifi was trivial, too. I just typed in my Wifi password, and I’m good to go.

It should also be noted that Raspberry Pi has considerable momentum and a large developer community behind it. This is important, because it means that things just work better, support is wider, and you have more community backup if you run into problems; which happens less often anyway because of the extra design work.

The thing about the RPi compared to potentially competing products is that the former is more “thought through”. Other products, which typically come from China, seems to be a bit “wobbly”. The cubietruck, for example, has a SATA drive, but the power draw means that you have to start hooking extra sources to the board. The latest kernel doesn’t support the NAND device, which is a considerable inconvenience. Booting is a bit of a mess, too. For some reason, I couldn’t get network working when I booted from SATA, even though it seemed to be OK from the uSD card. You run into a lot of these kinds of “chicken and egg” scenarios when you opt for less popular boards.

So I would definitely recommend the RPi over similar solutions. That’s not to say that you should never consider other vendors, Perhaps a Beagleboard, or whatever, which costs less, is more of an appropriate solution for your particular project. The point being is that they don’t occupy the same “solution space”.

I notice the noob card comes with Windows 10 IoT. It’s something I might have a play with. I would be interested in seeing if I could set up a media centre using it. If memory serves,  Windows 10 does not include a media player, though. If so, then Microsoft should probably rethink that one.

So basically, the RPi 3 gets 5 out of 5 stars from me. It is British engineering should be about! Well done to the team that designed it.

 

rpi.JPG

Posted in Uncategorized | Leave a comment