
Show HN: Pytrader – trade cryoptocurrencies automatically with machine learning - ksowocki
https://github.com/owocki/pytrader
======
dikaiosune
"My test portfolio was initialized with a 1 BTC deposit, and after 2 months
and 23,413 trades, exited with 0.955 BTC. The system paid 2.486 BTC in fees to
poloniex."

I wonder whether a different trading strategy would decrease the fee overhead.
Or perhaps the cryptocurrency exchanges are not setup for short-run trading? I
know very little about the exchanges, but this does seem curious to me.

~~~
ksowocki
> I wonder whether a different trading strategy would decrease the fee
> overhead. Or perhaps the cryptocurrency exchanges are not setup for short-
> run trading? I know very little about the exchanges, but this does seem
> curious to me.

OP here.

One could presumably increase the margin for a classifier such that, to
classify a sequence of price movements as a BUY or SELL, the predicted
movement must be _higher_ than what it is now (0.002% increase/decrease
threshold)

~~~
densmirnov
Some chinese exchanges such as btcchina or huobi have very low trading fee or
eventually doesn't take fee at all. Maybe one of the solutions will be just
another exchange?

~~~
densmirnov
Just checked - yeah, on huobi.com it's possible to trade BTC against CNY
without any fees. Is it possible to adapt pytrader to huobi?

------
n_mca
Hm, not really convinced by the "just classify buy/hold/sell based on an
n-lookback" strategy -> Maybe read Ernie Chan's book on algo-trading, or use a
more traditional method trying to predict volatility instead of movement.

~~~
ksowocki
Thanks for the book recc. You are absolutely right that those are important
metrics to feed into the system.

Note I'm not really trying to 'convince' anyone of anything. I shared this on
HN was to show off a fun problem domain I've been playing with. If you're
looking for an end-game, you got me: Maybe I'll pick up a collaborator or two
and get to profitability faster that way. Worst case, I get some resume fodder
and an anecdote about machine learning to share at my next cocktail party.
Best case: Eventually when cryptocurrencies are everywhere, long after this
repo mints it's first millionaire, Hollywood will make a movie where I'm
played by Johnny Depp. A haxxor can dream, can't I? ;)

The database model already supports the following inputs: price, volume,
bid/ask spread. If a potential future contributor to this repo wanted to run a
classifier or NN on this data, they could do so with significantly less time,
using this repo's code.

I have a database of price, volume, bid/ask spread history for the entire
poloniex index, at a minute-by-minute- granularity, for the last 2 months. I
will post if there is enough interest. Vote here if interested =>
[https://github.com/owocki/pytrader/issues](https://github.com/owocki/pytrader/issues)

~~~
usmannk
I would love to be able to see that data, if you don't mind.

~~~
ksowocki
Please comment on this thread and I will notify you when it is posted.
[https://github.com/owocki/pytrader/issues/2](https://github.com/owocki/pytrader/issues/2)

------
Animats
It's a velocity-based system, one that looks at recent change history and
tries to project into the near future. Those only work in markets where nobody
else is doing that. You could make money in the US stock market doing that 30
years ago. Sometimes.

It doesn't look at the exchange's order book at all. Or use any outside data.

~~~
ksowocki
Hi, thanks for the comment.

You are correct that the cryptocurrency trading market is in it's infancy,
like the stock market 30 years ago.

The database model already supports the following inputs: price, volume,
bid/ask spread. If a potential future contributor to this repo wanted to build
a classifier or NN on this data, they could do so with significantly less
time, using this repo's code.

I have a database of price, volume, bid/ask spread history for the entire
poloniex index, at a minute-by-minute- granularity, for the last 2 months. I
will post if there is enough interest. Vote here if interested =>
[https://github.com/owocki/pytrader/issues/3](https://github.com/owocki/pytrader/issues/3)

------
npx
I can't imagine why anyone would actually want to release a profitable trader.
Isn't this kind of a tautologically dumb thing to do?

~~~
ksowocki
Read the readme. Trader is not profitable (yet). Unless if you don't include
fees in profitability calculation, which is clearly not a calculation based in
a real use case.

~~~
npx
Right, I saw that, I just can't see any motivation to make it profitable and
then issue a pull request. Maybe I'm missing something?

~~~
ksowocki
You posit an interesting question about human nature, and about motivations in
open source software.

If someone gave you an half-written instruction manual and a toolkit that
could turn an ordinary goose into a golden goose,

(1) Would you have a go at it?

(2) Would you share or hoard the golden eggs if you figured out the rest of
the instructions?

(3) If you did share them, would the sum of the contributions compound and
create more profit for everyone? Would the global markets for golden eggs come
crashing down due to increased supply? And if so, how soon until that happens?

I do not presume to know the answer, but the undergraduate anthropology minor
in me says that watching the 'pull requests' tab of this repo will yield some
interesting clues.

~~~
ben_che
I'm sorry but that's a terrible analogy. The whole point of open-source
software is aligning the interests of individual developers and groups to
create something that can be shared and add value to anyone who uses it.
Currency trading is a zero-sum game. You have winners and losers on each
transaction. No new value is being created. There's no altruistic reason that
would justify someone with a profitable strategy, ML or otherwise, to share
their approach with others (fellow contributing developers, ostensibly, but we
all know any shared profitable method is going to be exploited by leechers).
You could argue that the process of trying to make a profit here advances the
field of ML, and I'll grant you that, it might. But beyond that, there's no
"profit for everyone" angle here - that's just human nature.

------
lordnacho
This is quite interesting. Why trade BTC though, when you can just open an
Interactive Brokers account and have access to a bunch of cheap assets?

~~~
ksowocki
Less competition for profits vs. other algorithmic traders.

~~~
wslh
But except for BTC, and probably Ethereum, other cryptocurrencies have
insignificant liquidity and volume.

------
languagehacker
Just thinking out loud here, but I'm wondering if using integer linear
programming (e.g. branch and bound) to introduce constraints to the decision-
making part of the engine might reduce the amount of fees the author incurred.

------
maxander
There's going to be a problem with any Bitcoin-style currency once
sophisticated algorithmic trading becomes widespread enough that compute time
is always more profitably spent day-trading than mining.

~~~
AgentME
Bitcoin's automatically adjusting difficulty rate means that if fewer people
are mining, then it becomes more profitable for them, which guides the system
into an equilibrium.

Also, mining profitably requires special hardware built specifically for
Bitcoin mining.

~~~
ksowocki
> Also, mining profitably requires special hardware built specifically for
> Bitcoin mining.

For bitcoin yes, but there are proof of work cryptocurrency systems out there
that use CPU. And there are proof of stake systems out there that neither cpu
or gpu intensive.

For a lot of people, cryptocurrency = bitcoin. But there's a _growing_ number
of crypto enthusiasts who see crypto as an constellation of cryptocurrencies,
each with their own unique attributes and fundamentals, that complement (as
well as compete with) bitcoin.

------
627467
Uphold.com is not exactly an exchange but has 0-fees for member trades for
most exchange pairs. Wonder is this could be hooked to it.

------
grigio
I appreciate this.. but why do you do it with real money? Shouldn't be better
to allow a "simulation mode" ?

~~~
ksowocki
OP here.

You could. For me, 1 BTC is a negligible amount that was worth not having to
manage the abstraction overhead of a simulation mode.

~~~
ksowocki
But if you wanted to add a simulation mode, I'd certainly welcome the PR :)

~~~
gst
A simulation sounds simpler than having to declare 23,413 trades on a tax
form.

~~~
mdip
Ah, yikes! Good point. One has to factor in not only the trading fees but the
potential fees incurred in preparing ones taxes (or having them prepared by a
third-party as many in the US usually do -- I wouldn't even want to know what
my tax guy would charge for that kind of volume!)

------
radicalman
What are the commission costs? I always thought switching from cash to btc
cost money regardless.

