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


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]

Ravencoin and ethereum (classic) accounting tools

So I've been hacking away at the accounting tool for ethereum (classic) today, adding support for converting the USD rate for ETH/ETC to another currency, based on data provided in the CSV format.

It's mostly here:

https://github.com/morphex/ethereum-classic-taxman/commit/08...

I had to code my way around one thing in that respect, and that's because the USD-NOK rate for example is provided by the central bank, and they don't provide rates for Saturday, Sunday etc. So when transactions are made on days like that, the nearest, previous USD-NOK rate is used.

It seems reasonable to solve it that way, because something tangible (known) is better and more logical that whatever rate might come the day or even days after the transaction.

I also started work on another crypto currency accounting tool today

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

Ravencoin Taxman. This takes a different approach from ethereum-classic-taxman, as it works with CSV data retrieved from a block explorer service. It doesn't download transactions and blocks from a node.

It takes much less (programming) time and (computer) resources to do it that way, but I also noticed that it was difficult to get CSV exports of ETC transactions on major / well known ETC block explorers today. This shows that it is useful to have a tool that is independent of for example block explorers, something that will work with just a node available.

The ravencoin-taxman code will need to have some crypto (RVN-USD) rate and fiat rates databases as well, I think I might just copy over most of the code for that from the ethereum-classic-taxman project. It doesn't seem like there will be much if any changes to those code bits in the future, and I don't see any obvious way now of making a package that will fit for both projects.

So I guess the only major bit left for both projects is getting the valuation (crypto currency * crypto currency rate in USD) combined with FIFO correct. That would pave the way later for example for tax reduction later, choosing the crypto-currency with the highest value when received for outgoing transactions. Which leads to less taxes due.

[Permalink] [By morphex] [Python and web (Atom feed)] [07 May 23:56 Europe/Oslo]