
Show HN: 400-Line Binance CryptoCurrency Bot - klhugo
https://github.com/khstangherlin/monker
======
klhugo
The Money Maker Machine - Monker

This was a hobby project of myself to create the simplest Cryptocurrency bot
possible. It was written in Python, operates on Binance, and stores all
logging and trading information into a MongoDB database. The trading strategy
is extremely simple:

\- Assume that crypto prices will fluctuate, but eventually be restored to its
original quote \- Buy small quantities every time the price falls below a
threshold, keeping track of the amount purchased and the price payed \- Sell
those exact quantities when the price is above what was payed for it

It was a lot of fun developing it, and I guess I made something around 3
dollars before shutting it down. It is my first contribution to opensource
world, and I hope others can benefit from it :)

~~~
eerikkivistik
Hi

So first of all, thank you for sharing your work, I'm sure it was a lot of fun
building it and making it work!

If you'll indulge me, I'll point out a few thoughts about application logic
that handles money.

First of all, money related logic should be using fixed point mathematics in
all places. In the case of EUR/USD fixed to 2 points behind the decimal point
and in case of BTC and others, somewhere around 9-16 (can't be bothered to
look it up atm). There is a cumulative error that is produced when using
floating point variables. I'll be happy to share a link to a discussion, if
you want!

The second thought I had was about using MongoDB for this use case. While it
is great for getting started and MongoDB has made great strides at improving
safety, it is still a suboptimal choice for handling financial transactions
(logs or otherwise). I will also be happy to clarify why, if someone wants to
discuss the matter further.

~~~
nayuki
Bitcoin has exactly 8 decimal places. The terminology is 0.00000001 BTC = 1
satoshi.

~~~
eerikkivistik
Right you are, consider me corrected.

------
haolez
Nice! It's very simple, but has a few interesting qualities, like not using
any third-party library to interact with Binance, giving the bot more
flexibility to make use of Binance-specific features in a future extension of
this work. For example: Binance's margin trading works a little different from
other exchanges.

I would use order book data instead of ticker data, though, since you have
more control of your risks regarding the exchange's liquidity.

Well done!

~~~
1996
Orderbook can be tricky. Also third party libraries are dangerous.

If all you need is ticker data, but you want separate bid/ask, and do not want
3rd party library, you can augment your results with market average from
[http://cmplot.com/api.json](http://cmplot.com/api.json)

It also come with all the fiat pairs. No TOS, no login, no nothing, it lives
on XMR donation.

~~~
justaguyhere
This site's FAQ is a charming and a delightful read! Thanks for sharing

~~~
1996
Share the goodness!

------
glofish
I have a feeling that the vast majority of transactions are from bots like
this, from the naive "moneymakers" (like this one with a $3 return) to ones
with extreme sophistication.

The naivete here is that it only makes money if the market is rising long
term. If it is falling over the long term then you'll get stuck with a bunch
of losses.

The results it generates are no different than buying at random times and
selling random bets at random times.

~~~
1996
I think you are mistaken- the bots is based on means reverting. Rising or
failing will not work. Oscillations will work.

------
studio816
If you like crypto bots, check out our project called
[https://quadency.com](https://quadency.com) We have common strategies you can
deploy to all major exchanges. You can also code your own real-time strategy
in python using [https://support.quadency.com/en/articles/3459678-strategy-
co...](https://support.quadency.com/en/articles/3459678-strategy-coder)

~~~
zigzaggy
Very cool. I’ll have to check this out.

Do you know of any stock trading sites that have bots?

~~~
studio816
Crypto is a little different as you have direct access to exchanges whereas in
stocks typically you’re trading with a broker. This opens up a lot of
opportunities for individual traders that traditionally are only available to
institutions, such as strategies based on order book (market making, arbitrage
etc)

------
csomar
I think there should be a big (maybe red?) disclaimer at the very top
explaining that this should only be used for fun, experimental and learning
purposes. No real money should be invested into it too.

Just in case somebody thinks it's real and go full retard with it.

~~~
mmanfrin
> and go full retard with it.

Please don't use language like this.

~~~
cmcd
That is the accepted terminology for wallstreetbets style trading, is it not?

~~~
itake
wallstreetbets would say "full autist"

------
Akababa
Very cool! I might try to pick this up later and test some stuff out. Why did
you choose to stop it? Did you find a more profitable algorithm ;)

I wonder how much of the volume on cryptocurrency exchanges are due to bots.

~~~
klhugo
A lot is due to bots.

I stoped mainly because I need to work on my PhD. But the code there was very
solid on my tests. I hope I can get back at it early next year :)

~~~
pearjuice
Your code doesn't seem to have any tests?

~~~
alimbada
I assumed he was talking about his manual tests.

------
gmm1990
Looks pretty cool! I'm always unsure of separating my buy and sell side logic.
Was there a deliberate decision to separate those functions, rather than
passing the side as an argument?

------
shelune
How much did you put in the bot initially and how long have you kept it
running before shutting it down?

------
mocha_nate
Great idea. Thank you for sharing! I’ve had this same thought with Tesla’s
stock

