
Algo trading digital assets - mthwsjc_
http://johnmathews.eu/algo-trading.html
======
tlb
Although simulations will predict good profits, you will probably lose your
money doing this due to counterparty risk. Counterparty risk is the risk that,
between the time you click the 'sell' button and the time you actually get the
money deposited in your bank account a few days later, the exchange goes
insolvent.

When a given coin trades at different prices on two exchanges (which is what
these arbitrage algorithms look for), it will try to buy that currency on the
cheap one and sell on the expensive one.

The main reason coins have different prices (more than a few cents) on
different exchanges is that people are worried about the exchange being
insolvent.

For instance, during MtGox's slide into doom, Bitcoin was cheap there. So this
algorithm would have been busily buying Bitcoin with USD on MtGox, then
transferring the Bitcoin to another exchange to sell, so it could pump the USD
back into MtGox. Since withdrawals from MtGox were throttled, you would have
built up a large balance there. When they shut down, you would have lost
bigly.

People do make money doing arbitrage between exchanges, but you need a
sophisticated model that considers counterparty risk, which isn't something
you can read from a price sheet.

~~~
wc-
This comment is almost like a copy-paste every time some kind of crypto
trading article is submitted. I might have missed something in the article /
code but this isn't an arb strat? It is just using some moving averages to try
to follow a perceived trend in different trading pairs on a single exchange.

Counterparty risk definitely still exists, but it is getting better very
quickly with the growth of regulated US-based exchanges like gdax, gemini, and
ledger x. In the altcoin world, Bittrex is in the process of fulfilling state-
by-state requirements for regulatory approval. The crypto world is very
different today from when MtGox dominated and getting even better.

~~~
nosuchthing
You forgot the most infuential (and unscrupulous) crypto exchange in the
cyptocoin ecosystem: Bitfinex.
[https://medium.com/@bitfinexed/latest](https://medium.com/@bitfinexed/latest)

~~~
wc-
Yes, very familiar with finex and the bitfinexed guy's warnings / rants /
whatever you want to call them.

If counterparty risk is a top concern (and it probably should be) then don't
trade on unlicensed exchanges... That rule is great to follow and I haven't
even gotten into any usdt tether issues...

~~~
dharma1
couldn't you trade on decentralised exchanges where counterparty risk isn't a
thing? at least if you're only trading between crypto pairs

~~~
wc-
Yes, decentralized exchanges (dex) are coming and I'm very hopeful.

However, the ones I have looked at / tested so far just aren't ready for
primetime. Slow transaction times, lackluster user experience, no liquidity.

But those are all problems that are to be expected for what are basically
beta-status projects (at best) and I am excited to see where things go from
here.

------
blunte
Since the history of markets there have been people who believed they could
define a set of rules that would allow them to win more than they lose
(reliably enough to make it worth the gamble).

There are many reasons why this is a fool's belief, at least with one strategy
over a long term. As many people pointed out already, properly calculating
risk is the usual failure. But even if you properly calculate risk, there are
still possibilities (which you may deem unreasonably small to consider) which
can happen. This is was the final straw that caused the 2007/8 failures. Any
possibility greater than zero can happen. It doesn't matter what your models
prepare you for. If that "virtually impossible" scenario occurs, you lose.

The more commonly successful approach to algo trading is to identify an
inefficiency in the market and capitalize on that. But that is a limited time
opportunity. You either eat up all the inefficiency yourself (if you're
lucky), or other people catch on and help you make the market properly
efficient. Then you're on to the next game. And in many cases, the
inefficiency you are capitalizing on is due to a lack of capability of your
broker(s). And brokers don't like when you cost them money repeatedly.
Eventually they catch on, and they shut you down. So you trade your time for
money by way of constantly searching for new brokers and gaining access to a
market only so you can profit your way right out of that market.

Summary: create value to win. Any other method of profit is an eventual
failure.

~~~
askmike
You mean how companies like Renaissance Technologies are obviously flawed
since they only rely on mathematical models and are thus doomed to fail?

~~~
dajohnson89
it's ok, it was amusing to see the Nassim taleb meme still going strong.

------
wc-
This is a decent first-steps guide into analyzing historical trading data.
With resources like Quandl, QuantConnect, etc continuing to improve, hopefully
we will see more and more people diving into the data.

That being said, the "todos" at the end of this article kind of understate
just how much work is left to be done before a strategy like this could be put
into production. Ignoring the actual viability of a simple moving average
cross signal, you could have the best strategy out there but would never stand
a chance without significant time and effort committed to the execution and
risk management sides of automated trading.

If building trading systems in the crypto world is something that interests
you feel free to reach out to me, company / contact info is in my HN profile.

~~~
nxsynonym
Here's a question I've had for a while regarding trading systems in the
cryptocurrency world --

What's the end goal? Would a perfect trading system fully automate the trading
process to maximize returns, or is the goal to develop the best tool to assist
a trader?

I'm curious what you, as someone in the field of developing these systems, see
as the "ideal product".

As a follow up question, what would happen to a market that is 100% traded
automatically (assuming thats possible and the end-goal) - would become
stagnant?

Forgive my ignorance if any of this is obvious, my econ/trading knowledge is
next to 0.

~~~
gricardo99
I'm not exactly sure what you're asking. What's the goal of building a trading
system?

As someone who's worked on trading systems in a professional setting I'll give
some thoughts.

First and foremost the goal is to make money. I guess some people build these
systems for fun/hobby or for the challenge/educational value. But huge amounts
of money are spent on trading systems, with the goal that they increase
profitability. Sometimes that means maximizing returns, sometimes that means
assisting traders. This is a very large market, with very diverse types of
end-users. I believe crypto is similar, but a microcosm of the broader trading
environment (with some of its own cyrpto-specific idiosyncrasies). You have
some "HFT" traders, "institutional", HODLERs, etc... Each has different
objectives and skill sets. A trading system has a different value proposition
for each trader's needs and objectives.

In terms of a 100% automated market, that's an interesting question. The
biggest world markets are very highly automated, such as the equities market.
Google "hft percentage of volume" and you'll find various sources claiming up
to 70% of the equities volume is HFT. Since HFT trades complete in micro-
seconds, this is fully automated trading. The Flash crash was partially blamed
on a high-level of automation, were a trader was trying to game the response
to large orders[1]. I think a 100% automated market would collapse. Even the
70% automated market of equities has shown some scary positive feedback loops
that need human intervention.

1 - [https://www.bloomberg.com/view/articles/2015-04-21/guy-
tradi...](https://www.bloomberg.com/view/articles/2015-04-21/guy-trading-at-
home-caused-the-flash-crash)

~~~
dpweb
HFT strategies are of course secret but aren't they really taking advantage
of:

1\. Faster speed to market. Basically, front running 2\. Extremely low
transaction costs. Not available to the retail trader or even electronic mkt
makers. 3\. Extremely low time in each trade - when you dispense with bell
curve predicting - risk becomes only the time you are not flat.

These are NOT prediction of future price. HFT don't make money 'predicting'
the market - they are too sophisticated as traders to believe that's reliably
possible. It is to some extent, but its very hard and theirs is a better play.

~~~
physguy1123
1 - being faster isn't front running. Nobody can hop in front of orders that
are already visible on the lit market.

2 - The electronic market makers ARE mostly hft and generally get the best
transaction costs and other privileges excluding taker-maker exchanges. Take
NYSE parity or CME mass quotes for example

3 - Somewhat true but not in general. Becomes a murkier quality when hft is
combined with longer term signals

> These are NOT prediction of future price. HFT don't make money 'predicting'
> the market - they are too sophisticated as traders to believe that's
> reliably possible. It is to some extent, but its very hard and theirs is a
> better play.

This is completely wrong. Plenty of HFTs do prediction to varying degrees, one
of the biggest HFTs almost exclusively trades on price prediction. Other don't
very much but hedge in very sophisticated manners. The smallest group is those
who just use speed and fee structure to make money. There are certainly
benefits to speed however (fill rate at the very least) and the market leaders
are both intelligent AND fast.

~~~
kayhi
1) yes, if a large order has to be fulfilled across multiple exchanges then
there’s a race which HF can win

~~~
physguy1123
Nobody knows about a large order being filled cross multiple exchanges, at
most they see a price level get filled at one exchange and take from that what
they want. The majority of large cross-exchange orders are done via ISO orders
which bypass routing mechanisms and exist for the sole purpose of executing
large cross-exchange orders. Even if one doesn't want to lift the price,
people trying to fill a large order generally route multiple orders to
different exchanges.

An HFT might see one price level go away before another even with the ISO
mechanism, but it's far too late to act on that information by the time it's
visible on the lit markets.

------
dogruck
Summary: some code to calculate moving averages of crypto currency prices.

------
nmca
I am unable to see the charts.

~~~
Drdrdrq
Had the same problem, they showed up later. I guess HN effect is to blame.

~~~
vertis
I would guess using a charting SaaS that charges based on views is to blame

------
Vanclief
During this summer I performed a similar analysis with SMA and variations from
it. My initial explorations looked very promising so I started saving market
data and build a Python back-tester to test it. Once I applied exchange fees,
slippage and simulated over longer periods things changed. I was no longer
able to create a profitable strategy that performed well in longer time-frames
over multiple markets. However its something I still want to work with.

------
mosselman
"Hello Hacker News! Thanks for all the views. Due to increased traffic,
Plot.ly won’t serve any more plots until tomorrow. Come back then?"

A bit off-topic, but it teaches us a lesson about avoiding getting locked-in
by too many services. If I'd use a plot in my blog post I'd like it to keep
working even when I get more traffic than usual. Especially if my whole blog
post is useless without it.

------
AbenezerMamo
This is cool. If you want to go further, checkout a small tool I made that
automates technical analysis for crypto markets with major price signals:
[https://github.com/AbenezerMamo/crypto-
signal](https://github.com/AbenezerMamo/crypto-signal)

------
meesterdude
I'm building a trading bot (ruby) that uses a collection of signals to trade.
I have been working on the backtesting to do validation of different
strategies across different pairs and intervals. The highest i've gotten it so
far is 120X from start of LTC/BTC, but thats also on a fairly aggressive
setting (and obviously idealistic);

SMA can work, but it can also bite you. I think using only 1 technical
indicator is asking for trouble when determining entry. Use at least 2, but no
more than 5 or 6.

As a software developer, its a cool field to tinker in. But theres lots of
ignorance, hype, and crap.

For anyone who wants to build a simple bot, checkout gekko
[https://gekko.wizb.it](https://gekko.wizb.it)

~~~
tobltobs
> The highest i've gotten it so far is 120X from start of LTC/BTC

120x sounds impressive (and overfitted), but if you compare this to a simple
buy-and-hold strategy it is a rather depressing result.

~~~
marcell
Indeed; for crypto trading, your unit of account matters a lot. I'd recommend
using BTC as the unit of account, so you aren't counting 100x+ USD increases.

------
brndnmtthws
Time in the market beats timing the market.

------
georgeglue1
Can someone summarize the returns and risk-level of his strategy?

~~~
joshvm
Trying to trade purely off technical analysis is a disaster waiting to happen.
Have a look at the technical analysis of ETH/USD, for instance, they have
absolutely no clue what's going on:

[https://www.ethnews.com/analysis/10-30-2017-ethereum-
forecas...](https://www.ethnews.com/analysis/10-30-2017-ethereum-forecast-
ethusd-facing-key-resistance)

As to the linked article, the idea of SMA crossovers is nothing special:
[https://www.babypips.com/learn/forex/moving-average-
crossove...](https://www.babypips.com/learn/forex/moving-average-crossover-
trading)

Take a look at their example. Say you sold at the peak, great. Then the
currency drops and you buy at the bottom, great. But then the SMA crosses
again and you sell - oops, look where the graph is going. You can't predict
this stuff with technical indicators.

~~~
AznHisoka
My opinion is that technical indicators can work well... when it's clearly a
bull market (but then, so can every other strategy). They absolutely suck and
can't predict when it's clearly going to crash. Which make technical
indicators pretty much useless because you can easily lose all your gains when
that happens.

------
itodd
I'm unable to see the charts:

    
    
        Refused to display 'https://plot.ly/~mthwsjc/69.embed' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

~~~
sne11ius
Me too :/

~~~
hxegon
me three

~~~
dblboy
me fourth. See devTools console. Usual chrome on mac

