Cryptocurrency mining auto-exchanger

How to convert mining pool proceeds to bitcoin

I haven’t done much programming lately, at least rather I haven’t written much code lately. I still rely on some things that I’ve written; my value average programs for my self-directed IRA is something I use every day. But I’ve been so tied up with other projects lately that yesterday was the first time I’d really sat down and started writing a program from scratch in a very long time.

It’s amazing how much I’d forgotten.

I’m writing a new Python program, this one to do some automatic selling of cryptocurrency mining proceeds. My little six-GPU mining rig has been chugging along for some two years now, and has yet to turn a profit, so I’ve decided that if I’m going to keep doing it I need to at least cover my electricity costs. I’ll be exchanging the proceeds for bitcoin, not fiat, of course. Plus it seems that market pressure is building toward another parabolic run, so I think it prudent to start converting some percentage of my proceeds that I’ve mined over the years so that I don’t wind up holding another dead bag. I guess I’ve moved out of the spec mining phase for the time being, and need to start making some real money.

So I sat down last night to start designing a system. I had already set up my environment during a previous session, and got started with my usual project flow, setting up dotenv files, a new git repo on my home lab, TDD with pytest. It was slow going, and felt like I had to do Google searches for every line of code I wrote. I caught myself dealing with premature optimization several times and had to stop myself from over complicating things. I was just building an API call using requests.

All I managed to do last night was get the rewards statistics from the mining pool that I’m using. It’s a list of dicts, and I’m not sure how I want to do my calculations, a percentage of rewards, or something based off of power consumption. I need to at least cover my rig’s 0.9Kw/h power consumption. I can’t get that from Simplemining since they don’t seem to have an API, so for now I’ll just have to go off that estimate, or plug in my Kill-o-watt. I killed the last one with a power surge over eleven hundred watts, so I can either run a test or just use SMOS’s estimate.

Either way, I can use my mining rewards for our preferred mining interval, get price data off Binance using the CCXT library, and then send a transaction to the exchange using the wallet API. Then I’ll have another call to the exchange, after the deposit has cleared, to initiate a market order. And then a final call to move the proceeds to my hard wallet.

Several of these components are going to be rather straightforward, but putting them all together is going to be a bit of a challenge. I could run this as a simple script as a cron job, but I could also leave this running as a service, with various components running in different threads. I’ve obviously got some design decisions to make.

I have decided that I want to move my blockchain nodes out of my house. I’ve got several of them that I need to have online, including ARW, XHV, RVN, and BEAM. Running all of them at the same time is a bit too taxing for the machines that I have scattered around the house, so I’m going to try and put my AWS training to work and setup various nodes in the cloud.

My XDNA node that is currently running in an EC2 instance is using less than 5% CPU as all of the work for Ethereum has been handed off to Infura. When I tried to put the BEAM node on this same instance it couldn’t handle it, so I’ve got to figure out what the actual requirements are for it. I’m hoping that it’s not going to be cost prohibitive.

I’m envisioning several instances with various blockchains stored on S3 volumes, nodes running on their own small instances as needed. My wallet files can either remain at my home lab or consolidated in another, secured instance. Cost will be a factor of course, but maintaining copies of several different blockchains locally is proving difficult to manage. And several of my wallets have been untouched for over a year or more.

I’m hoping I can build everything out in config files, Docker builds for the nodes, and the AWS configuration itself setup using Elastic files. I envision that some of the programs, like the one that I’ve described here, could even be run as Lambda functions.

Of course, a lot of this sounds like premature optimization. We shall see.

Leave a Reply

Your email address will not be published. Required fields are marked *