Description
Using stock historical data, train a supervised learning algorithm with any combination of financial indicators. Rapidly backtest your model for accuracy and simulate investment portfolio performance.
Clairvoyant alternatives and similar packages
Based on the "Machine Learning" category.
Alternatively, view Clairvoyant alternatives based on common mentions on social networks and blogs.
-
xgboost
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow -
PaddlePaddle
PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署) -
Prophet
Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth. -
NuPIC
DISCONTINUED. Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex. -
H2O
H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc. -
Sacred
Sacred is a tool to help you configure, organize, log and reproduce experiments developed at IDSIA. -
garak, LLM vulnerability scanner
DISCONTINUED. the LLM vulnerability scanner [Moved to: https://github.com/NVIDIA/garak] -
karateclub
Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020) -
awesome-embedding-models
A curated list of awesome embedding models tutorials, projects and communities. -
Crab
Crab is a flexible, fast recommender engine for Python that integrates classic information filtering recommendation algorithms in the world of scientific Python packages (numpy, scipy, matplotlib). -
seqeval
A Python framework for sequence labeling evaluation(named-entity recognition, pos tagging, etc...) -
SciKit-Learn Laboratory
SciKit-Learn Laboratory (SKLL) makes it easy to run machine learning experiments. -
Feature Forge
A set of tools for creating and testing machine learning features, with a scikit-learn compatible API -
Robocorp Action Server
Create 🐍 Python AI Actions and 🤖 Automations, and deploy & operate them anywhere -
Data Flow Facilitator for Machine Learning (dffml)
DISCONTINUED. The easiest way to use Machine Learning. Mix and match underlying ML libraries and data set sources. Generate new datasets or modify existing ones with ease.
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Clairvoyant or a related project?
README
Basic Overview
Using stock historical data, train a supervised learning algorithm with any combination of financial indicators. Rapidly backtest your model for accuracy and simulate investment portfolio performance.
Visualize the Learning Process
Last Stable Release
pip install clairvoyant
Latest Development Changes
python -m pip install git+https://github.com/anfederico/clairvoyant
Backtesting Signal Accuracy
During the testing period, the model signals to buy or sell based on its prediction for price movement the following day. By putting your trading algorithm aside and testing for signal accuracy alone, you can rapidly build and test more reliable models.
from clairvoyant.engine import Backtest
import pandas as pd
features = ["EMA", "SSO"] # Financial indicators of choice
trainStart = 0 # Start of training period
trainEnd = 700 # End of training period
testStart = 701 # Start of testing period
testEnd = 1000 # End of testing period
buyThreshold = 0.65 # Confidence threshold for predicting buy (default = 0.65)
sellThreshold = 0.65 # Confidence threshold for predicting sell (default = 0.65)
continuedTraining = False # Continue training during testing period? (default = false)
# Initialize backtester
backtest = Backtest(features, trainStart, trainEnd, testStart, testEnd, buyThreshold, sellThreshold, continuedTraining)
# A little bit of pre-processing
data = pd.read_csv("SBUX.csv", date_parser=['date'])
data = data.round(3)
# Start backtesting and optionally modify SVC parameters
# Available paramaters can be found at: http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html
backtest.start(data, kernel='rbf', C=1, gamma=10)
backtest.conditions()
backtest.statistics()
backtest.visualize('SBUX')
Output
------------ Data Features ------------
X1: EMA
X2: SSO
---------------------------------------
----------- Model Arguments -----------
kernel: rbf
C: 1
gamma: 10
---------------------------------------
--------- Engine Conditions ----------
Training: 2013-03-01 -- 2015-12-09
Testing: 2015-12-10 -- 2017-02-17
Buy Threshold: 65.0%
Sell Threshold: 65.0%
Continued Training: False
---------------------------------------
------------- Statistics --------------
Total Buys: 170
Buy Accuracy: 68.24%
Total Sells: 54
Sell Accuracy: 59.3%
---------------------------------------
Simulate a Trading Strategy
Once you've established your model can accurately predict price movement a day in advance, simulate a portfolio and test your performance with a particular stock. User defined trading logic lets you control the flow of your capital based on the model's confidence in its prediction and the following next day outcome.
def logic(account, today, prediction, confidence):
if prediction == 1:
Risk = 0.30
EntryPrice = today['close']
EntryCapital = account.BuyingPower*Risk
if EntryCapital >= 0:
account.EnterPosition('Long', EntryCapital, EntryPrice)
if prediction == -1:
ExitPrice = today['close']
for Position in account.Positions:
if Position.Type == 'Long':
account.ClosePosition(Position, 1.0, ExitPrice)
simulation = backtester.Simulation(features, trainStart, trainEnd, testStart, testEnd, buyThreshold, sellThreshold, continuedTraining)
simulation.start(data, 1000, logic, kernel='rbf', C=1, gamma=10)
simulation.statistics()
simulation.chart('SBUX')
Output
------------- Statistics --------------
Buy and Hold : -6.18%
Net Profit : -61.84
Strategy : 5.82%
Net Profit : 58.21
Longs : 182
Sells : 168
Shorts : 0
Covers : 0
--------------------
Total Trades : 350
---------------------------------------
Other Projects
Intensive Backtesting
The primary purpose of this project is to rapidly test datasets on machine learning algorithms (specifically Support Vector Machines). While the Simulation class allows for basic strategy testing, there are other projects more suited for that task. Once you've tested patterns within your data and simulated a basic strategy, I'd recommend taking your model to the next level with:
https://github.com/anfederico/gemini
Social Sentiment Scores
The examples shown use data derived from a project where we are data mining social media and performing stock sentiment analysis. To get an idea of how we do that, please take a look at:
https://github.com/anfederico/stocktalk
Notes
Multivariate Functionality
Remember, more is not always better!
variables = ["SSO"] # 1 feature
variables = ["SSO", "SSC"] # 2 features
variables = ["SSO", "SSC", "RSI"] # 3 features
variables = ["SSO", "SSC", "RSI", ... , "Xn"] # n features
Contributing
Please take a look at our contributing guidelines if you're interested in helping!
Pending Features
- Export model
- Support for multiple sklearn SVM models
- Visualization for models with more than 2 features
*Note that all licence references and agreements mentioned in the Clairvoyant README section above
are relevant to that project's source code only.