Informations
Jump to content

Lorem Ipsum...

Click to Dismiss this Notification
Ładowanie danych...

CryptoBot v1.0: Automated High-Frequency Trading Bot


100%

Recommended Posts

  • Administrator

Overview

CryptoBot is an automated trading bot designed for high-frequency transactions in the cryptocurrency space. Utilizing Machine Learning, it determines the optimal times to execute trades. Currently, it focuses exclusively on Bitcoin trading on the BTCC exchange, with plans to incorporate additional currencies and exchanges in the future.

This project represents a significant modification of Christopher Bynum's BitPredict, available at:

This is the hidden content, please
. While the foundational code and concepts derive from BitPredict, CryptoBot has undergone extensive development and has diverged considerably from the original project.

Written entirely in Python, the project does include some accompanying shell scripts.

Detailed Functionality

Data acquisition occurs from BTCC through their JSON RPC API and is stored in MongoDB, utilizing scripts found in the app/collect_data directory:

  • A snapshot of the order books is collected every second.
  • Recent trades are collected every second.
  • Ticks are gathered every second.
  • The run_collect_scripts.sh script launches the data collection process.

Features are generated and saved to disk with the create_live_features.py script. The Machine Learning features include:

  • Width
  • Power Imbalance
  • Power Adjusted Price
  • Trade Count
  • Trade Average
  • Aggressor
  • Trend
  • These features are adapted from Christopher Bynum's BitPredict project. More information is available at:
    This is the hidden content, please
    . Suggestions for additional features are welcome!

A target variable, termed "final," is formulated using future midpoint prices (for 5, 10, 15, 20, 25, and 30 seconds ahead) of the midpoint between bids and asks at those times:

  • -1 indicates the future midpoint average price dropped below a specific threshold percentage after 15 seconds.
  • +1 indicates the future midpoint average price rose above a specific threshold percentage after 15 seconds.
  • 0 means the future midpoint average price stayed within the threshold percentage after 15 seconds.

Leveraging these features, we train a Machine Learning classifier model (via the strategy.py script) against the target value to predict one of three potential outcomes:

  • -1 indicates a predicted price drop, suggesting to trade accordingly.
  • +1 indicates a predicted price increase, suggesting to trade accordingly.
  • 0 suggests no trade.

I've experimented with the following classifiers:

  • XGBClassifier from the XGBoost library:
    This is the hidden content, please
  • RandomForestClassifier from the scikit-learn library:
    This is the hidden content, please
  • GradientBoostingClassifier from the scikit-learn library.
  • Your mileage may vary; test different classifiers to discover which yields the best outcomes (the strategy.py script supports backtesting and model creation).

The predict.py script handles live trading functionality.

Inner Workings

  • A trade is executed (position taken) and reversed after 15 seconds.
  • The trading balance maintains a 50/50 split, with half held in Bitcoin and half in cash (fiat).
  • When the price is predicted to decline, Bitcoin is exchanged for cash, then re-purchased at a potentially lower rate, generating profit in Bitcoin.
  • Conversely, when the price is predicted to rise, cash is exchanged for Bitcoin, which is then sold back at a higher price, generating profit in cash.
  • Remember that orders do not always execute immediately, so we consider the average price midpoints over +/- 15 seconds. This accounts for trades that may occur and reverse within a 15-second timeframe.
  • Expect to gather several weeks' worth of data to effectively train a classifier capable of producing meaningful results.

Disclaimer

While the bot is fully operational, it primarily serves as a learning exercise for Machine Learning. I have not achieved consistent profitability, and you should not expect to either. Exercise caution when using this bot, and assume all responsibility for its use. Never trade with money you cannot afford to lose; utilize this bot primarily for experimentation and fun.

Additional Remarks

This project is very much a work in progress. Contributions are welcome! If you are able to achieve consistent profitability, please share your findings!

License

This project is licensed under the Apache License.


Feel free to modify anything further if necessary!

 

This is the hidden content, please

This is the hidden content, please

This is the hidden content, please

This is the hidden content, please

This is the hidden content, please

Spoiler

Author - AdeelMufti

 

Link to comment
Share on other sites


  • 100% changed the title to CryptoBot v1.0: Automated High-Frequency Trading Bot

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

spacer.png

Disable AdBlock
The popup will be closed in 5 seconds...