Qt Bitcoin Trader - program for trading Bitcoin under Windows, Mac and Linux
In this article, I will show you how the Qt Bitcoin Trader program works, and tell the story of its development. This open source program allows you to quickly place bets on BTC-e and Mt.Gox, set rules for automated trading. It is written on pure Qt 4 using OpenSSL, and, in my opinion, it has interesting features from the development side, which I also want to talk about.
Prehistory
During the April jumps of the Bitcoin course, I, and my friend Dybik , like many in the field, became interested in this wonderful cryptocurrency. We, like, I think, many of those who read this article, decided to try themselves on the stock exchange. As it turned out, the most popular exchange for trading Bitcoin is Mt.Gox. We checked in and started making first bets.
The course is constantly growing, the hype has increased. The whole Internet was buzzing about it, and I remember, even on TV then they talked about Bitcoin. We traded on the site Mt.Gox, and the site is often podlagival. Annoyed when you put orders, but can not be canceled. Rather, it turns out, but the “cancel” button did not give any confirmations or responses. It was not clear if the order was canceled or not. ')
Even then, I thought: “Why is there no possibility on the site to set the rules for creating orders?”. It is impossible to follow the course around the clock, it would be good to leave the rules for the night. I looked for programs and found python bots and some kind of paid clients for the desktop then incomprehensible to me. "Edit the file to correct the rule? This is inconvenient, ”I thought. Need a program that does not allow to make mechanical errors, skip a zero or a comma.
The course is constantly jumping, and we had time to buy and sell profitable. I tried to get the benefit on small jumps. In the order log of Mt.Gox, a separate item was clearly displayed by the amount of the purchase commission, but there was no item for sale. “Purchase commission only,” I thought. And when I counted, I realized that I was losing. Commission for the sale too, it is built into the amount. In my opinion, it would be more logical to do the same display commission and for sale and for purchase. But maybe Mt.Gox specifically wants to confuse us? I do not know. I found this out and began to trade further.
It turned out a good amount and we realized that it was not for nothing that we spent so much time. And then, well, you yourself remember, then came the complete collapse of the course and we also came under attack. The site was hanging out, it was impossible to sell Bitcoin, and then Mt.Gox froze the day trading at all. The course plummeted. So I lost half the amount invested.
What to do next? Surrender and withdraw the balance amount? I did not doubt for a minute and began to think about strategy; it did not go out of my head. Search for bots in python? No, it became interesting to me to realize something of my own. When I first started trading on Mt.Gox, I already had a simple program that I could not find anywhere, and then I started developing Qt Bitcoin Trader.
Meet - Qt Bitcoin Trader
After the first launch, you will be greeted with a profile creation window. You have to choose a stock exchange, get an API key with Info and Trade parameters, enter it into the program, then create a strong password. All data is stored in the user profile folder, encrypted using OpenSSL with AES256 encryption.
In the login window, you can enable check for updates. For Mac and Windows users, there is an automatic update. New versions are checked by downloading a file from GitHub , in which the checksum of a binary file encrypted with RSA2048 is saved. Therefore, there is no risk of spoofing the file with malware.
When the new version is released, you will see the following window:
I tried to develop the interface simple, and so that everything was in sight. No offense to users with low screen resolutions, but I will optimize the interface for them later. On the left you see a list of open orders that are updated in real time. You can create buy and sell orders, but so that the amount does not exceed your balance. Recently, Mt.Gox immediately removes orders that exceed the balance. Finally, you can cancel the order, and immediately see its status “Canceled”, even if it still hangs on the site, the API receives delivery confirmation.
All market data is updated in one request, except for the latest price. It is also updated from the prices of recent transactions.
The commission calculator is available on the small button on the left above. I received feedback, and I made it the way users of online calculators used to use. It works the same, except that the balance and the latest prices are automatically loaded, which is convenient. You can open as many calculators as you like.
You can easily create a rule to automatically create orders: Now you can create rules in two modes: “By turns” and in “Parallel”. In parallel mode, when values ​​change, all rules are checked for similarity, and any of them can be executed. In the “By Turn” mode, the second rule line will be checked only if the first one is executed. You can change the order of the rules and edit them.
For some values ​​there is a sound alert. The speaker icon is a push button switch.
It is possible to unhook group boxes, making them separate windows, which is undoubtedly convenient using multiple monitors.
For Windows users, it is possible to enable portable mode. You need to create a QtBitcoinTrader folder in the same folder as the exe file, and all encrypted data will be stored in it.
What is expected in the next versions of Qt Bitcoin Trader?
BTC-e and Mt.Gox are currently supported. If possible, free time, I will finish the support of the other most popular exchanges in turn. It is possible that websocket api and http api work simultaneously. Next - the display of graphs in real time. It will be possible to add API of different exchanges and different currencies to one profile, for simultaneous monitoring. A scripting language, as an addition to the rules, which can write a strategy analyzing prices on different exchanges in a few lines.
How can you help me improve Qt Bitcoin Trader?
At the moment, the program is translated into English, German, Russian, Ukrainian, Spanish, Dutch and Norwegian. You can help translate the program to your native language. The program has a built-in translation engine. Click "About the program" and you will see the instruction:
Click the "Translate Program" button and you will see the dialog:
There are all the fields that need to be translated. Fields with red text are fields that match the English translation. By pressing the "Apply" button, you will immediately see your translation in the program and you will be able to correct too long texts. When you finish the translation, save the file and send it to the email address specified in the instructions. After checking the translation, I will add it to the next version of Qt Bitcoin Trader. And do not forget to leave your contact information and address Bitcoin for donates in the field "Translator:".
You can also help develop the program financially, since the program lives only on donates. Bitcoin address for support: 1d6iMwjjNo8ZGYeJBZKXgcgVk9o7fXcjc
As soon as my program appeared on the Internet, duplicates with the description of my program immediately began to appear. But, instead of links to the Qt Bitcoin Trader download, it’s suggested to download a virus. I was surprised why there are so many Qt Bitcoin Trader fakes on the Internet. And even qtbitsointrdr.m - this is a fake with a link to the virus, and www. qt-tradar.ru also fake. If I knew that the program would be so popular, I would immediately have scored these domains. I think this is a lesson for me and for all who read this article. Be careful, if you do not know whether the link is reliable, then google by name. I recommend using the built-in safe update program.
Qt Bitcoin Trader development features
Embedded translator mechanism
Maybe you are wondering why I didn’t choose the standard Qt Linguist for translating the program? I don’t like it, it can be convenient to edit the form, but to translate a file, Qt Linguist itself is needed, and probably only 5% of all users of the program have it. Therefore, I decided to write my own engine, and make it convenient not only for developers, but also for all users of the program. You can see the JulyTranslator class source on GitHub. This is the base class in which all word associations in QHash are saved. This class can load and save translation files, as well as translate individual interface objects and load text from the interface into a file. For each interface object that needs to be translated, I set a unique text identifier via setAccessibleName (). The translateUi function (QWidget * parent) of JulyTranslator class bypasses all the child widgets of the parent from the function parameter. Each widget that needs to be translated, need to call translateUi () in the constructor or by a signal. For example, we go around all QPushButton buttons, check if there is an accessibleName () value, and, if so, get the association of this value from the QHash class JulyTranslator
The result is a class that loads the language from the file and applies it to the interface.
Since I don’t always like the way QLayout works, then after applying the translation, I go through each widget, calculate the minimum size to provide a proper kind of widget, and ask it the minimum width.
As a result, we save space in the interface, and at the same time the text does not go beyond the widgets.
The second stage is to make the creation of the translation user-friendly. The TranslationDialog class is designed to generate a list of fields. It pulls out the entire array of texts from JulyTranslator and generates QTextEdit for each field. Since I don’t always like what the layout does with QTextEdit, I wrote the TranslationLine widget, which, when changed, wraps around the text perfectly to save space. You can watch it in the translator when you write something or put enterters in text fields. The field automatically increases and decreases.
Safe auto update only with GitHub and SourceForge
The principle of updating is simple: the program loads the file raw.github.com/JulyIGHOR/QtBitcoinTrader/master/versions.txt , which lies on the GitHub in the open form, when it starts up. The checksum of the SH1 binary encrypted with RSA2048 is saved in the file. Public.key is sewn into the program resource, and Private.key is securely stored and password protected, and only I have. When checking for updates, the program downloads the file from the specified link from the file to the RAM, if the file is more than 15 MB, the download is canceled. Next, the checksum SH1 of the downloaded data is calculated, and compared with the decrypted information from the update file. If the checksum matches, the program saves the file from the RAM to a disk called QtBitcoinTrader.upd. After the check check it reads it back, and checks if the file is well preserved. After successful verification, renames itself to * .bkp, and the * .upd file to the original file name. After restarting, extra files will be deleted. This principle works the same for both Windows and Mac OS X.
Afterword
Remember, the program does not trade for you, it is just a tool to help you trade. I hope I didn’t get too long and the article was interesting for you. I would be happy to support, feedback and recommendations.