Bitcoin Forum
April 26, 2024, 11:45:10 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to make your own trading bot  (Read 134 times)
henrythebest (OP)
Jr. Member
*
Offline Offline

Activity: 109
Merit: 7

Perseverance pays... a lot!


View Profile
March 16, 2019, 02:50:47 AM
 #1

article originally from FMZ.COM ( A place you can create your own trading bot by Python, JavaScript and C++)

i can't post pics here because of my rank on bitcointalk. for more information, please check here: https://www.fmz.com/bbs-topic/2884

Foreword
I’m certainly not a great programmer, but writing this project taught me a lot (and kept me occupied). Most of my code were done on FMZ.COM, and if I were to refactor the python code I would use a more object orientated model. Nonetheless, I was pleasantly surprised with the results I got and the bot has made almost 100% ether profit so far.

What does it do?
It is an arbitrage bot. That means that it earns money from trading the difference between prices on two (or more) exchanges. As of now it is unidirectional and only trades between Etherdelta and Bittrex: they share approximately twenty eth/token pairs. Here’s a diagram to illustrate how it works:

Words followed by parenthesis are ethereum transactions that invoke a smart contract function call.

The Code
I could have used fmz.com platform python editor to create the transactions and function calls and it would have been fairly straightforward. I needed something more reliable; a failed transaction means losing money. Every single one my GET requests needed a reply, even if the TCP packet got lost or the webserver on the other end was temporarily down. Therefore I decided to implement my own python etherscan API wrapper and used pythereum to create the transactions and etherscan to publish them. I also wrote my own requests.get decorator that is a while loop that only exits once the reply is satisfactory.

Here is the code I used to encode the etherdelta json API responses as hexadecimal, rlp encoded, ethereum transactions (not for the faint hearted):


The raw hexadecimal values in the closure at the bottom are the function signatures that correspond to each function. A function signature is derived from the keccak of the function and its arguments. It must be appended to the data parameter of a transaction followed by the data that makes up the arguments. In total my code is around 400 lines long and contained in 5 different files.

The Outcome
I made a couple of graphs from the data I logged using pymatplotlib.
 

Conclusion
Overall the entire project took me around two weeks during my spare time at school and it was a blast all round. I’ve taken a break from coding vigorously and am currently in the process of planning arbitrage bot v2. The next version is going to include 86 different exchanges and a whole lot of trading pairs.

To the moon!

article originally from FMZ.COM ( A place you can create your own trading bot by Python, JavaScript and C++)

In Bitcoin We Trust
1714131910
Hero Member
*
Offline Offline

Posts: 1714131910

View Profile Personal Message (Offline)

Ignore
1714131910
Reply with quote  #2

1714131910
Report to moderator
Once a transaction has 6 confirmations, it is extremely unlikely that an attacker without at least 50% of the network's computation power would be able to reverse it.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714131910
Hero Member
*
Offline Offline

Posts: 1714131910

View Profile Personal Message (Offline)

Ignore
1714131910
Reply with quote  #2

1714131910
Report to moderator
wuvdoll
Legendary
*
Offline Offline

Activity: 1442
Merit: 1025



View Profile
March 16, 2019, 07:56:32 AM
 #2

This seems to be an useful stuff for those geek turned traders to automate their trading strategies. I keep on getting various tutorials on python programming but unfortunately my hectic schedules never allow me to check with them for at least once. After youtube and various trading/investment related sites like investopedia, these types of creating our own bots is gaining momentum but not sure about the final results with trader's performances.

I believe using bots to save time by automatizing our routine works will definitely lead to significant improvements in our overall performances.

For traders, bots will be useful and risk-free up to the point of filtering out trading pairs based on their certain selection criteria but opening a new trade should be manual and highly recommended. Never rush to use bots with your "actual capital". Test multiple times in demo accounts or with least capital before touching the "actual".
henrythebest (OP)
Jr. Member
*
Offline Offline

Activity: 109
Merit: 7

Perseverance pays... a lot!


View Profile
March 18, 2019, 02:12:36 AM
 #3

This seems to be an useful stuff for those geek turned traders to automate their trading strategies. I keep on getting various tutorials on python programming but unfortunately my hectic schedules never allow me to check with them for at least once. After youtube and various trading/investment related sites like investopedia, these types of creating our own bots is gaining momentum but not sure about the final results with trader's performances.

I believe using bots to save time by automatizing our routine works will definitely lead to significant improvements in our overall performances.

For traders, bots will be useful and risk-free up to the point of filtering out trading pairs based on their certain selection criteria but opening a new trade should be manual and highly recommended. Never rush to use bots with your "actual capital". Test multiple times in demo accounts or with least capital before touching the "actual".

i think you just point out the truth about trading bot, lots parameter need adjust according to the market changes, trading bot isn't about just let it run by itself, people should treat it like treating subjective trading.

In Bitcoin We Trust
Tytanowy Janusz
Legendary
*
Offline Offline

Activity: 2142
Merit: 1622


View Profile
March 18, 2019, 08:59:03 AM
 #4

This seems to be an useful stuff for those geek turned traders to automate their trading strategies. I keep on getting various tutorials on python programming but unfortunately my hectic schedules never allow me to check with them for at least once. After youtube and various trading/investment related sites like investopedia, these types of creating our own bots is gaining momentum but not sure about the final results with trader's performances.

I believe using bots to save time by automatizing our routine works will definitely lead to significant improvements in our overall performances.

For traders, bots will be useful and risk-free up to the point of filtering out trading pairs based on their certain selection criteria but opening a new trade should be manual and highly recommended. Never rush to use bots with your "actual capital". Test multiple times in demo accounts or with least capital before touching the "actual".

I think that none from us is able to code and run bot that will automatically daytrade (buy + sell day by day). That's too hard. But we can try to code and run bot that will:
1 - autotrade by arbitrage strategy - low risk, easy to code, low profit
2 - autotrade by scalping strategy (adding liquidity to exchange, just trying to be at first position at bids and asks when good spread appear with low bet on various coins) - low risk, medium to code, low profit
3 - manual trader help by enabling more advance buy/sell orders. For example - create order at price : highest ask+1 sat update every time someone gives better price - that way you can add even 0.5% to your profit form trade (same with sell). - decrease manual trader risk, easy to code, increase manual trader profit
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!