Skip to content

The Python code employs historical Bitcoin and Ethereum prices to train a neural network model for cryptocurrency trading, executing buy or sell decisions based on predicted spreads. It evaluates the strategy's performance, visualizes training progress, and prints executed trades with associated probabilities.

Notifications You must be signed in to change notification settings

Ayushsaini20/Pair_trading_in_cryptocurrency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

Pair Trading

The provided Python code orchestrates a comprehensive analysis and implementation of a cryptocurrency trading strategy. Leveraging historical price data for Bitcoin and Ethereum, the code commences by merging datasets and imputing missing values to ensure a robust foundation for subsequent analysis. Subsequently, the script engages in feature engineering, calculating the spread between Bitcoin and Ethereum prices and computing statistical measures such as mean and standard deviation. It also introduces a dynamic indicator, signaling spread narrowing based on predefined conditions. Moving forward, the code delves into machine learning, employing a neural network model implemented with TensorFlow and Keras. The model is trained on a split dataset, undergoes preprocessing via a pipeline, and incorporates callback mechanisms for learning rate reduction and early stopping during training. The resultant model is then applied to predict trading signals on a testing set. An integral aspect of the trading strategy lies in the translation of predicted probabilities into actionable buy or sell decisions. A threshold is established to determine the strength of these signals, with the code printing executed trades, their sizes, and corresponding predicted probabilities. Additionally, the code assesses the strategy's performance by computing transaction costs and slippage, ultimately calculating daily returns and evaluating key financial metrics, such as the Sharpe and Sortino ratios. The script doesn't merely conclude with model training and evaluation; it further extends into visualization, plotting the training progress in terms of accuracy over epochs. This visual representation aids in understanding the model's learning trajectory. Importantly, the code emphasizes adaptability by including a note about a missing function (calculate_transaction_costs), which is expected to be provided separately. This ensures that users can integrate custom transaction cost logic tailored to their specific requirements. In essence, the code encapsulates a sophisticated yet adaptable approach to cryptocurrency trading, seamlessly integrating machine learning, financial metrics, and visualization for a comprehensive analysis of historical data and the implementation of a robust trading strategy.

Screenshot 2024-01-14 at 5 23 08 PM Screenshot 2024-01-14 at 5 23 15 PM Screenshot 2024-01-14 at 5 23 01 PM

About

The Python code employs historical Bitcoin and Ethereum prices to train a neural network model for cryptocurrency trading, executing buy or sell decisions based on predicted spreads. It evaluates the strategy's performance, visualizes training progress, and prints executed trades with associated probabilities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages