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.
-
tensorflow
An Open Source Machine Learning Framework for Everyone -
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 -
gym
A toolkit for developing and comparing reinforcement learning algorithms. -
CNTK
Microsoft Cognitive Toolkit (CNTK), an open source deep-learning toolkit -
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. -
TFLearn
Deep learning library featuring a higher-level API for TensorFlow. -
NuPIC
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. -
Pyro.ai
Deep universal probabilistic programming with Python and PyTorch -
Surprise
A Python scikit for building and analyzing recommender systems -
LightFM
A Python implementation of LightFM, a hybrid recommendation algorithm. -
Pylearn2
Warning: This project does not have any current developer. See bellow. -
Sacred
Sacred is a tool to help you configure, organize, log and reproduce experiments developed at IDSIA. -
skflow
Simplified interface for TensorFlow (mimicking Scikit Learn) for Deep Learning -
python-recsys
A python library for implementing a recommender system -
Metrics
Machine learning evaluation metrics, implemented in Python, R, Haskell, and MATLAB / Octave -
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...) -
adaptive
:chart_with_upwards_trend: Adaptive: parallel active learning of mathematical functions -
Xorbits
Scalable Python DS & ML, in an API compatible & lightning fast way. -
TrueSkill, the video game rating system
An implementation of the TrueSkill rating system for Python -
SciKit-Learn Laboratory
SciKit-Learn Laboratory (SKLL) makes it easy to run machine learning experiments. -
rwa
Machine Learning on Sequential Data Using a Recurrent Weighted Average -
Feature Forge
A set of tools for creating and testing machine learning features, with a scikit-learn compatible API -
Data Flow Facilitator for Machine Learning (dffml)
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. -
brew
Multiple Classifier Systems and Ensemble Learning Library in Python. -
bodywork
ML pipeline orchestration and model deployments on Kubernetes. -
Robocorp Action Server
Create 🐍 Python AI Actions and 🤖 Automations, and deploy & operate them anywhere -
MLP Classifier
A handwritten multilayer perceptron classifer using numpy. -
OptaPy
OptaPy is an AI constraint solver for Python to optimize planning and scheduling problems. -
vowpal_porpoise
lightweight python wrapper for vowpal wabbit -
omega-ml
MLOps simplified. From ML Pipeline ⇨ Data Product without the hassle -
ChaiPy
A developer interface for creating advanced chatbots for the Chai app. -
tfgraphviz
A visualization tool to show a TensorFlow's graph like TensorBoard
InfluxDB - Power Real-Time Data Analytics at Scale
* 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.