Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Pytrader – trade cryoptocurrencies automatically with machine learning (github.com)
103 points by ksowocki on Mar 26, 2016 | hide | past | web | favorite | 41 comments



"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.


> 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)


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?


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?


Fees on crypto-currency trading platforms are typically a % of the value of the trade and the % you pay is determined by your trading volume over the prior month. The fact that the thing was tested with such a small amount of BTC means they were probably paying the highest fee tier.


You are close. This is poloniex exchange's new fee model. https://poloniex.com/fees/


So I see it says that the bot made 23k trades. What kind of volume did it reach with only 1BTC? When it made a trade did it always go all in?


nope, only small trades to start. average trade was 0.05 BTC, total volume was 1200 BTC


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.


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


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


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


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.


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


And it only lost 0.05btc in the span of 2 months.


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?


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.


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?


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.


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.


Even if it were currently profitable (after transaction fees), it may be more profitable to release it as a way to introduce new customers to a particular exchange (i.e. Poloniex). I'm not assuming this took place, but if the developer wanted maximum yield, working out some sort of incentive plan:

Flat free to release with "Built to work with Poloniex". Similar to "Click to deploy to Heroku" buttons.

Affiliate link /discount code to track conversions or reward accordingly


If you don't expect it to remain profitable for very long (you might know other people working on the same thing), and isn't profitable enough in the short amount of time you have to make a large amount, I could see it looking excellent on a resume.


It's not dumb... if you have a pump and dump scheme for example, having more people do it with you actually increases your take-home results.


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?


Less competition for profits vs. other algorithmic traders.


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


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.


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.


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.


> 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.


OP here.

I'd presume that someone who is better versed in wall-street style algorithmic trading could speculate better than i what a mature cryptocurrency trading market would look like.

I'm curious to see what a mature market in this space looks like. It'll surely be different on a currency-by-currency basis, because volume, market depth, and fundamentals matter greatly and are unique on a per-currency basis. Time will tell.

As to whether profitable automatic currency trading competes with mining for compute time, I posit the following question to you: Are the two mutually exclusive? In a world with (1) scalable compute power via AWS, Digital Ocean, etc, and (2) both are profitable, why not do both instead of one?


If it was profitable to mine with AWS, why wouldn't amazon be doing it themselves?


If I had to speculate, I'd hypothesize that there are lower hanging fruit with respect to profit opportunities at Amazon than cryptocurrency mining.


Think about it this way though. If it was profitable to pay amazon to do it even with them taking their cut, it would be much more profitable for them to do it themselves. If it was more profitable than renting out the performance to other people, it would be the lowest hanging fruit by default.

This isn't hypothetical, the CPU mined coins aren't close to profitable with web services. And the people making profitable ASICs are using them rather than selling them because it's intrinsically more profitable.


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.


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


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.


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


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


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!)


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




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: