Morphex's blogologue (Life, technology, music, politics, business, mental health and more)

This is the blog of Morten W. Petersen, aka. morphex in various places. I blog about my life, and what I find interesting and/or important. This is a personal blog without any editor or a lot of oversight so treat it as such. :)

My email is morphex@gmail.com.

I am leavingnorway.info.

An OGG/Vorbis player, implemented in Javascript.

My Kiva bragging page
My shared (open source) code on GitHub

Morphex's Blogodex

News
Me on Instagram
Slashdot

Zope hosting by Nidelven IT

Morten Petersen on Linkedin

Morten Petersen on Facebook

Morten Petersen on SoundCloud

Morten Petersen on MixCloud

Blogologue on Twitter



Older entries



Atom - Subscribe - Categories

Facebook icon Share on Facebook Google+ icon Share on Google+ Twitter icon Share on Twitter LinkedIn icon Share on LinkedIn

Some more easy sunday accounting hacks

I added some code to the ravencoin-taxman tool today:

https://github.com/morphex/ravencoin-taxman/commit/55f47b67f...

which enables the calculation of earnings in a local currency. So if you're mining for example, it is possible to get the entire earnings in a year, into the local currency, which should be sufficient for accounting and tax purposes for that year.

The commit also included a bit of refactoring, of I guess you can call it standard debug stuff, to lessen the amount of code necessary to write later. Support for CSV files using ; as a separator was also added, the Norwegian bank uses that as a separator in its datafiles, as , is the decimal separator in the Norwegian locale.

I also added a test, to illustrate the command line and how to operate it:

https://github.com/morphex/ravencoin-taxman/commit/e08301ba0...



[Permalink] [By morphex] [Ravencoin and ethereum (classic) accounting tools (Atom feed)] [19 Jun 20:46 Europe/Oslo]

Comparing apples and oranges

So finally for this sunday hacking, I added some tests for the ravencoin-taxman project, and before that, I added RVN-USD calculation for transactions; giving (an acceptable) USD valuation of any given transaction:

https://github.com/morphex/ravencoin-taxman/commit/170f2167b...

The code of this project looks cleaner than then one for the ethereum-classic-taxman project; probably because I'm getting back into the groove of programming, but also because they are fairly similar, and this could be called a re-write of sorts.

Refactoring seems to be a key part of productive programming, and necessary to manage any software project with more than a few pages of code. I see now that there will be at least a 3rd project between ethereum-classic-taxman and ravencoin-taxman, with code utilized by both.

[Permalink] [By morphex] [Ravencoin and ethereum (classic) accounting tools (Atom feed)] [05 Jun 19:46 Europe/Oslo]

A little sunday refactoring

Making a little progress in the ravencoin-taxman accounting script today, refactored date parsing into its own function in this commit:

https://github.com/morphex/ravencoin-taxman/commit/a6b8089cd...

There are some that might argue that a function (in any programming language) shouldn't take up more than one console window - if it's bigger than that it should be broken up.

I kind of agree, it's a good guiding principle. In this case, the function was reduced to less than half the size, and in the process, I guess you can say it become better documented as well, because the old function is easier to read and the new parse_date function also has a docstring with a little information.

[Permalink] [By morphex] [Ravencoin and ethereum (classic) accounting tools (Atom feed)] [05 Jun 11:00 Europe/Oslo]

Exchange rate file parsing for ravencoin taxman

I hacked a little more on the

https://github.com/morphex/ravencoin-taxman/

Ravencoin accounting tool today, it takes a lighter approach than ethereum-classic-taxman, downloading a CSV file of transactions instead of running through all the blocks in a blockchain node to find relevant transactions.

Since it does that, it makes things a bit less mentally demanding to work with, and I need to get FIFO sorted out for accounting purposes, so that it is possible to calculate loss and gains for capital tax.

Ravencoin-taxman works with data from different sources, one part is the Ravencoin transactions, another is the rate in USD for RVN at any given time (day) and finally a local currency is often necessary, in my case NOK, Norwegian kroner, to calculate things correctly for accounting and tax purposes.

Working a bit with CSV files, it is easy to appreciate their simplicity, on the other hand, they're not what you can call "well-defined" formats, for example the date fields in them can have different meanings based on where the CSV file is generated. YY/MM/DD or YY/DD/MM or even DD/MM/YY.

So I worked on that today. I think there is a little CSV tool that can be refactored into a separate Python package for working with CSV files, or data that isn't strictly declared or formatted.

CSV files are great in their simplicity and utility, but as this code shows:

https://github.com/morphex/ravencoin-taxman/commit/62fe3c364...

It takes quite a bit of work to make sure that data from CSV files is interpreted correctly, and if you're working with a limited amount of data, it is possible for that code to interpret a date wrong, switching the month and day fields the wrong way around.

[Permalink] [By morphex] [Ravencoin and ethereum (classic) accounting tools (Atom feed)] [29 May 14:40 Europe/Oslo]

JSON viewer for JSON database

I was looking to get a little done on the ethereum-classic-taxman accounting tool today, and thought a bit outside-the-box, what could I need in there that isn't a direct priority.

The tool uses JSON databases, I switched a little while back because there could be security issues related to using a Python pickle database as the database backend.

An added benefit of using JSON is that its content is easy to view, and for example for debugging purposes, I thought it could be a good thing to have a tool that creates a view of the data that is easy to navigate and view. For example for debug purposes.

So I created this little script:

https://github.com/morphex/ethereum-classic-taxman/blob/main...

There are graphical JSON viewers on Ubuntu for example, but this little script can also have its output piped into a file, so that a database can be edited by hand in an editor. Or it could be piped to less on Linux/UNIX for viewing and searching.

On a related note, I saw some people lost their savings on the recent Luna/Terra crash. On the upside, I guess now is a chance to make a bet that the new variant with a massively higher amount of coins minted will succeed.

[Permalink] [By morphex] [Python and web (Atom feed)] [15 May 21:33 Europe/Oslo]