Installing Bitcoin trading robot Gekko on Ubuntu 12.04 LTS


Gekko is a Bitcoin trading robot written in Node.js (Bitcointalk thread, Github). This post will cover installation of Gekko on a fresh Ubuntu 12.04 LTS system.

 

Installation

First, install the system level dependency, Node.js:
sudo apt-get install nodejs

Check out the Gekko code from Github:
cd $home
git clone git://github.com/askmike/gekko.git

Install more dependencies through the  Node.js package manager:
cd gekko
npm install

Finally you can test the installation by running pre-configuration:
node gekko

You should see output like this as the bot begins to calculate:

2014-01-20 23:21:24 (INFO):     I'm gonna make you rich, Bud Fox.
2014-01-20 23:21:24 (INFO):     Let me show you some Exponential Moving Averages.


2014-01-20 23:21:24 (INFO):     Using normal settings to monitor the live market
2014-01-20 23:21:24 (INFO):     NOT trading with real money
2014-01-20 23:21:27 (INFO):     Profit reporter active on simulated balance
2014-01-20 23:21:27 (INFO):     Calculating EMA on historical data...
2014-01-20 23:23:28 (INFO):     ADVICE is to BUY @ 952.688 (0.335)

 

Live trading

The next step is to configure the bot for live trading.  Lines 28 through 38 of the configuration file contain this stanza by default:
// Monitor the live market
config.normal = {
  enabled: true,
  exchange: 'MtGox', // 'MtGox', 'BTCe', 'Bitstamp' or 'cexio'
  currency: 'USD',
  asset: 'BTC',
  tradingEnabled: false,
  key: 'your-key',
  secret: 'your-secret',
  username: 0, // your username, only fill in when using bitstamp or cexio
}


You can edit this file:
cd $home/gekko/config.js


Then modify the defaults as follows in order to enable live trading:
  • Optionally change the exchange to one of the commented choices
  • Optionally change asset to a different cryptocurrency
  • Set tradingEnabled to true
  • Set key and secret from the exchange's account/API page
  • Set username if applicable.

 

Further configuration

One important parameter to change from default will be the timeframe, EMA weight, candles and thresholds. These are found at "Exponential Moving Average settings" just above the account info section. Changing these settings helps prevent your bot being farmed by clever traders who know its default moves and set traps in the markets.

There are many other options such as email on buy or sell advice (free alerts!), profit calculation for advice, and even a backtesting feature (currently in alpha). And the authors of Gekko, led by lead developer "askmike" have plans for many new features in the latest development version, like a web interface and a local datastore for better support of alternate cryptocurrencies.

Self-Regulating Markets in Cryptocurrency


McKinley is still paying for this mistake.

This is where we find out that the people who said we couldn't have self-regulating markets were wrong.



Well, maybe they were right in a way. We couldn't have them in traditional economic structures, bound by complex webs of debt and top-down regulation. But we've been thrown into a new paradigm, the paradigm of Bitcoin and cryptocurrency. We, the participants in the many cryptocurrency exchanges and brokered markets, have, by all appearances, found ourselves forced by necessity to recreate sensible market forces.


Here are some examples of forex market action totally initially absent from Bitcoin and cryptocurrency instruments, and the equivalent or present day situation with regards to those actions. I'll give some pros and cons according to my understanding of the differences between regulated forex markets and unregulated cryptocurrency markets.


Market makers


Regulated forex markets generally employ market makers for each currency pair, or each trading instrument. The market maker accepts a lower trading fee in exchange for promising to buy or sell within a certain spread at all times. This results in a steadier price for the trading instrument, with smaller variations and shorter candle wicks and bodies.






In cryptocurrency, we see the "Evil Market Maker" at work in many brokerages: the spread on manipulated pairs will move vast distances up and down within short periods of time, making last hour's great buy a large loss as often as not. Automated trading systems are working these spreads, painting the tape, drawing the candles onto the chart to draw in unsuspecting marks.


To my knowledge, no public cryptocurrency exchange/broker employs official market makers, although some exchanges such as Cryptsy have expressed interest to casual inquiries from would-be straight market makers.


This is a situation where regulation in the absence of action from the brokers/exchange operators, could actually be to the benefit of the markets. If the participants in the market wish to avoid outside regulation, eventually imposed with the intent of avoiding widespread chaos and market manipulation, and its spillover to the traditional financial realm, they would do well to acknowledge the existing problems with manipulative market making, and demand the installation of proper market makers along the lines of traditional forex brokerages.


Arbitrage


Arbitrage is the practice of taking advantage of inefficiencies in currency pairs trading, such that one can simultaneously execute trades in three or more related pairs (triangular arbitrage) and realize a risk-free profit. In practice, slippage, liquidity, and competition place serious limits on the potential gains from arbitrage from new traders - not to mention the costs of fees eating into net margins. And forex brokers don't allow it within their systems - banks and brokers make a lot of money cornering the market on arbitrage in forex. Forex brokers also typically require traders exit trades on the same instrument they entered on, which makes inter-exchange arbitrage the only feasible option for retail forex traders (the little folks who are day trading through a broker).


Ancient Egyptian klutzes



Manual arbitrage almost certainly arose immediately as soon as Bitcoin was traded against multiple counter currencies, such as the US dollar (USD), Euro (EUR) and Russian Ruble (RUR). It's still possible to profit from arbitrage during periods of extreme volatility, but the unwary crypto trader is more likely to lose their shirt to slippage than to score a few satoshi. However, the established cryptocurrency market arbitrageurs perform an important role in the
markets by ensuring that no one ever overpays for a currency by buying
it through a certain pair or market, rather than another. These days they use automated solutions to the problem, and no inefficiencies exist for long.


In contrast to the aforementioned market making situation, there is no way to perform 'unfair' arbitrage, and therefore no government enforced regulation has been necessary in the traditional markets. Instead, there is merely ever-swifter arbitrage via better software and hardware - the regular customers of the exchange can only benefit from more competition at arbitrage, by being less likely to overpay for a currency.


Consumer protection


In the traditional finance world, Chuck Ponzi is infamous for starting an scheme that paid early investors with the proceeds from later investment. This is also known as a pyramid scheme, presumably where all the money accumulates at the top of the pyramid. In cryptocurrency, the rapid deflation of Bitcoin during its initial uptake (which continues to accelerate, with various deleterious effects to its economy) has been unfairly compared to such a scheme in the past.



The true comparison is to "premines", or cryptocurrencies where a large portion of the total coin base is reserved to the coin's founders. Those stakes are worthless until many people have contributed much hashpower in the mining of the coin, at which point the holders of the premined portion are in possession of much value that they did not have to mine for at all.








Premined currencies are rather commonplace in cryptocurrency, although only a few of them have managed to become accepted by Bitcoin exchanges. A common criteria for acceptance for trading instruments on the exchanges is that a currency not have been premined. Some exchanges do not differentiate between premined and non premined currencies, and list them next to coins which were 100% fairly mined. This could be construed as disingenous, perhaps.


The thing about open source and cryptocurrency is that it's a meritocracy of sorts. Everyone is free to choose the currency with the best fundamental features. Premining is a giant Black Spot on the hand of a currency. Naturally, most of the premines don't advertise the fact of their fundamental dilution as a feature- but you can read a partial list of coins noted as premines at https://bitcointalk.org/index.php?topic=134179.0. This list is now slightly out of date, but is still one of our first stops for researching up and coming coins.


In addition to premines, there are several out-and-out pyramid schemes which have been successful in separating many people from their hard earned Bitcoin. These schemes, exactly as in the equivalent illegal fiat currency con jobs, masquerade as legitimate investment or 'games', and promise lavish returns...just as soon as your investment 'matures' or is 'bought'. You'll never see the words 'pyramid schemes' on these websites, but that's all they are.



Promotion of these pyramid scheme websites, including cross-promotion with legitimate services, should be seen as a red flag for trustworthiness when choosing a vendor for Bitcoin or other cryptocurrency-related products or services. And if an investment looks too good to be true, or doesn't offer any stop loss/money back guarantee (that you can verify other people have had
honored), simply don't touch it.


Fair spreads (employing market makers) also falls broadly under the spectrum of consumer protection.

Conclusions


Market making has emerged for cryptocurrency markets. But it is prone to abuse in the current environment. Arbitrage is functioning adequately. And as with market making, consumer protection is an area where much is lacking in the way of self-regulation. Awareness of premines and pyramid schemes is growing, although more people still need to be warned about the nature of the scams. Fortunately most exchanges will not promote or trade premined currencies.



That leaves us with a dismal current score of 1 for 3 for deregulation, frankly. Perhaps a 1.5 if you count the Evil Market Makers providing some broad measure of stability, even as they generate a measure of whipsaw all day, grinding Jack and Jane into flour for their bread.


Can you attribute part of your trading experiences to these market forces? Do you have a special insight into some of the areas discussed? Let us know in the comments area.

This article was originally published in slightly different form under the title "The People Who Said We Can't Have Self Regulating Markets Were Wrong...Maybe" at Wall Street Crypto (http://www.wallstreetcrypto.com/2013/12/the-people-who-said-we-cant-have-self-regulating-markets-were-wrong-maybe.html).

Distributed Anonymous Government - A Fourth Stage in Peer to Peer Technologies?

With my deepest apologies to Trumbull

Consider this progression in technologies:


Stage One: BitTorrent is a distributed anonymous communication system. It proved itself in the minds of many as an idea by making all information, as well as entertainment, available to those who wanted it, if those who had it wanted to share. BitTorrent's success was largely founded on the widespread availability of high speed, always-on networking - witness the multitude of how-to guides and videos about maximizing your BitTorrent connection speeds, especially early on in the growth of use of the protocol.

BitTorrent's free, open source underpinnings meant it could not be easily stamped out. It was first ignored, then fought, then acknowledged as an inevitable force by media corporations who now themselves use the protocol for its advantages in content delivery.

Stage Two: Bitcoin is a distributed anonymous currency system. It proved itself as an idea by allowing easy and secure global transfers of wealth, while resisting efforts to destroy the perceived value of the blockchain. Although not sharing code with BitTorrent, it did share peer to peer networking ideas, and ideals of openness.

The Rise of the Distributed Anonymous Corporation

Stage Three: More recently, as Bitcoin's model has been proven useful enough to spawn numerous clones and experimental attempts at improving its protocol, concepts such as peer-to-peer anonymous trading systems relying on TOR - Decentralized Anonymous Marketplace (DAM) and peer-to-peer structured investments - Distributed Anonymous Corporations (DAC) have appeared. These DAC systems may operate on similar models of "trust-less trust" and openness as the first two stages, as well as near identical technical underpinnings. DAC... or "corp"? Sounds familiar...in any case, our word comes from a Latin root meaning "body".

The distributed anonymous corporation can keep public records of its meetings, has a transaction history, and even a company coin. In keeping with historical precedent, the corp probably operates a company store, too - but unlike back in the glory days of company towns, the DAC is distributed. They can't force anyone to shop at their store - it just might be advantageous. In fact, many cryptocurrencies do already operate in a similar fashion to corporations, by necessity - hiring developers, maintaining various public functions and so forth. And of course that old stand-by, T-shirt sales. However most of those functions are performed outside the blockchain, again by necessity.

One issue with making so many additions to the original purpose of the Bitcoin technology (commonly referred to as "stuffing things into the blockchain"), is that many desirable features require centralization and trust in a single individual or organization ("party"). This applies doubly for ideas such as ProtoShares, where the entire value of the instrument is predicated on future ventures to be launched by the controlling organization - this would be similar to investing in a company with no product or monetization plan. It may well turn out that contenders in the DAC market will need to conform to strict best practices and endure a period of low investment prior to showing real results.

Systems of Distributed Anonymous Government

Stage Four: I propose that another concept, Distributed Anonymous Governments (DAG) will eventually appear, in order to protect the interests of the corps and their members. A government for the purposes of this idea can be thought of as a corporation with a remarkably diverse shareholder base and the primary purpose of guaranteeing their ... well, whatever the government decides to do based on its noisiest and most powerful constituents, in practice. Which brings us to one of the first interesting points about taking government virtual:

The distributed anonymous government is by nature voluntary, and therefore participation in it must be useful. Else it will cease to exist with the proverbial quickness. No threat of imminent bodily harm can be used to coerce participation in the schemes and machinations of the DAG. At least, until roving bands of mercenaries with tablet computers begin to enforce its provisions. Oversight is already built into the Bitcoin protocol via multisignature transactions, and can provide a mechanism for jury and court systems, even very large juries.

The distributed anonymous government will save a lot of money on real estate. No more lines at benefit offices, and no spending on roads. Instead, the distributed anonymous government's budget in meatspace will mostly revolve around computing hardware and payroll costs, while its citizens will tend to favor investment in high speed internet systems, in traditional politics. It would be easy to imagine pork barrel projects being added to a DAG's budget eventually, but that's where the next part of the process comes into play. Pork will have to earn its place - and then it wouldn't be pork, would it?

The distributed anonymous government's taxes, expenses, currency issuance, and election records will be public, and totally malleable given a consensus of constituents. Instead of voting with your dollars or your feet (gosh, remember when there were other ways to vote for most of us?), you can vote with your fork - by running a different version of the DAG's software. True direct democracy will be not only possible and efficient, but actually necessary for functioning. As a result, only popular policies will be implemented (for long!). This will produce an interesting dichotomy in some geographical nation-states where the tyranny of the few is contrasted with the tyranny of the majority in a DAG. Many may prefer the latter if given an option.

Of course, with current  blockchain models, one's personal democracy in the DAG would be direct in relation to hashpower. There are obviously some fine details left to work out in that aspect. One is reminded of A. Solzhenitsyn's descriptions of the Soviet elite's holiday dachas, better grocery stores, etc. Technology updates such as the SCRYPT algorithm and even more restrictive mining algorithms such as Sifcoin's CPU-only mining, are intended to mitigate this problem by keeping participation accessible to the masses without special hardware, although hordes of VPS systems can still tackle CPU mining to great effect - anyone can rent a VPS to do this.

This idea of a distributed anonymous government, or more generally "how would an internet government function?" has been percolating in my mind for some time, and it occured to me more recently that the blockchain will be the place it happens. Comments about why this is the best idea ever, totally impossible, already in fact happening, or a just plain terrible idea are welcome.  

This article was originally published by the author on the Wall Street Crypto blog (http://www.wallstreetcrypto.com/2013/12/distributed-anonymous-government-fourth.html).

Updating a self-signed SSL certificate for Apache on Ubuntu 12.04


I had to update a self-signed SSL certificate for Apache today on an Ubuntu 12.04 server, as the old certificate had expired. I found a recipe for Debian which explained the process in a way that I was able to adapt to Ubuntu. Here is the complete process to renew your cert for another 365 days:


Change directories to the certificate location:

cd /etc/apache2/ssl

Generate a new key:
sudo openssl genrsa -out example.com.key 1024 

Generate a certificate signing request:

sudo openssl req -new -key example.com.key -out example.com.csr 
 
Generate a new certificate, by signing the CSR with the key:

sudo openssl x509 -req -days 365 -in example.com.csr \
  -signkey example.com.key -out example.com.crt 

 
Move the old key and certificate away, and copy the new key and certificate in: 

sudo mv apache.key apache.key.old
sudo cp example.com.key apache.key
sudo mv apache.crt apache.crt.old
sudo cp example.com.crt apache.crt 
 

Restart the webserver:

sudo service apache2 restart

Now, load your website via SSL.  You should be prompted to accept the untrusted certificate (not expired). Add the permanent exception, and you're good to go for another 365 days.

Cloning Scrapy scrapers easily with django-dynamic-scraper

Scraping requires some flexible tools.

The backstory


I have a Django project which uses django-dynamic-scraper, a scrapy wrapper, to gather data from various websites. I found myself creating a series of nearly identical scrapers to get data from different parts of these sites. This was rather inefficient since each scraper had a dozen fields or so, and there is no built in solution for copying a scraper.

I explored form autofill solutions before realizing I was overthinking the problem. All I needed to do was create a small script taking advantage of Django model access. This could probably be worked into manage.py, but I just wanted something to run in a hurry.

The script


clone-scraper.py:

import sys
from dynamic_scraper.models import Scraper, ScraperElem

s = Scraper.objects.get(name='My Template')
s.name=sys.argv[1]
s.id = None
s.pk = None
s.save()

se = ScraperElem.objects.filter(scraper__name='My Template')

for item in se:
    item.scraper = s
    item.id = None
    item.pk = None
    item.save()

Usage


python clone-scraper.py "New Scraper Name"

I run this script from within my virtualenv where Django lives. That gives it access to the models in my apps. If you're not sure which python executable you're using, run "which python" to find out. You want the one from the virtualenv.


How it works


The script first accesses the django-dynamic-scraper models to work with. Then it gets the "template" Scraper to be copied from, which has already been created. This working copy of a Scraper has its name set to the first command line argument. It also has its keys reset so that a new Scraper can be saved and given a new ID.

Then, the different ScraperElem fields from the new scraper are called and given the values of the fields from the template. Finally, those ScraperElem objects are saved.

This is tested on Django 1.5 and 1.5.2, but the technique should work with older versions.

Homework


Add a second argument for template name.

Checking Python style with pep8

A solid foundation in Python Style



If you've been coding with the Python language for a while, you have probably heard of PEP 8, the authoritative Python coding style guide authored by Guido van Rossum. While PEP 8 makes for a thrilling and inspiring read, something like a cross between Uncle John's Bathroom Reader and the US Constitution, it never occurred to me that there was a living application of the principles embodied in its chapters.

Today I learned that 'pep8' is a Python app! If you have pip installed, you can just 'pip install pep8'. If you don't have pip installed, install pip first with 'sudo apt-get install python-pip'. Pip is like apt-get, but for Python.

Pay attention, because this is the cool part. Now that you have pep8 you can use it to check your actual code against the actual PEP 8! It's like Guido himself was standing next to your desk, calmly eating canteloupe and critiquing your code for Pythonicity.

Here is the actual output I got from pep8 when I ran it for the first time on my Django project's settings.py:

$ pep8 cpi/settings.py
myproject/settings.py:6:80: E501 line too long (82 > 79 characters)
myproject/settings.py:110:1: E122 continuation line missing indentation or outdented
myproject/settings.py:133:1: W293 blank line contains whitespace
myproject/settings.py:138:1: W293 blank line contains whitespace
myproject/settings.py:143:13: W291 trailing whitespace
myproject/settings.py:156:80: E501 line too long (90 > 79 characters)
myproject/settings.py:130:1: E122 continuation line missing indentation or outdented
myproject/settings.py:151:14: E261 at least two spaces before inline comment
myproject/settings.py:152:22: E261 at least two spaces before inline comment
myproject/settings.py:153:16: E261 at least two spaces before inline comment
myproject/settings.py:231:1: E303 too many blank lines (3)
Ouch, that's a lot of errors! These are all the blunders in Python style which don't actually prevent execution of the code when it's run through the interpreter.

I was able to clear up all the errors, after which pep8 will run with no output:

$ pep8 cpi/settings.py

Joy!

Upgrading Kubuntu 12.04 to 12.10 Beta 1 "Quantal Quetzal"

Softpedia screenshot of the Kubuntu 12.10 Beta 1 default desktop
As noted on the official Kubuntu site http://www.kubuntu.org/news/12.10-beta-1) site, Kubuntu 12.10 beta 1 has been released. Here's how I upgraded my Ubuntu 12.04 system with KDE desktop to 12.10:

Bitcoin Mining on Ubuntu 11.04 "Natty" with poclbm and ATI


Updated 6/19/2011 - updated bitcoin app version to 0.3.23, simplified bitcoin setup directions

Updated 6/8/2011 - updated example app versions, clarified use of pools, clarified use of bitcoin standalone app, path cleanup, added link to headless mining guide

1. Introduction


Recently, I got interested in the new peer-to-peer digital currency, Bitcoin (read about it all about it at bitcoin.org if you're not familiar with it yet). Having decided to make use of my idling ATI graphics card for some bitcoin mining, I was able to cobble together a mining setup on Ubuntu 11.04 "Natty Narwhal" without too much trouble. It uses a standard miner app "poclbm", the Python OpenCL Bitminer.

Ubuntu 11.04 "Natty" release


The new Ubuntu 11.04, codenamed "Natty" has been released today! You can get it via Update Manager if you're already running Ubuntu 10.10. If you're new to Ubuntu, you'll want to visit the download page and get your Ubuntu installer CD image. You can also visit the main Ubuntu site to learn more about this release.

2 High Quality Free GPL Licensed Wordpress Themes

I found these two free Wordpress media-targeted themes while building a Wordpress site and thought I'd share them.

The first theme is called "Magazeen", and it's released by smashingmagazine.com under the GPLv2 license. Here's a screenshot:


I like this theme because it's got large thumbnails, good for those high quality images you need to feature.

Recent Posts