All Projects → anfederico → Clairvoyant

anfederico / Clairvoyant

Licence: mit
Software designed to identify and monitor social/historical cues for short term stock movement

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Clairvoyant

plutus-algo-backtesting
Algorithmic Trading : A python framework to run backtest on stocks using your own custom algorithmic strategies
Stars: ✭ 28 (-98.75%)
Mutual labels:  stock-market, backtesting-trading-strategies
Bullish
Stock market performance insights and trends in your inbox daily.
Stars: ✭ 171 (-92.39%)
Mutual labels:  stock-market
Sumzerotrading
A Java API for Developing Automated Trading Applications for the Equity, Futures, and Currency Markets
Stars: ✭ 128 (-94.3%)
Mutual labels:  stock-market
Sec Edgar Downloader
Download SEC filings from the EDGAR database using Python
Stars: ✭ 146 (-93.5%)
Mutual labels:  stock-market
Stock market sentiment analysis
股市情感分析
Stars: ✭ 130 (-94.21%)
Mutual labels:  stock-market
Stocks
Programs for stock prediction and evaluation
Stars: ✭ 155 (-93.1%)
Mutual labels:  stock-market
Trendyways
Simple javascript library containing methods for financial technical analysis
Stars: ✭ 121 (-94.61%)
Mutual labels:  stock-market
Yahoo Finance Api
PHP client for Yahoo Finance API 📈
Stars: ✭ 179 (-92.03%)
Mutual labels:  stock-market
Stock market indicators
A small Python library with most common stock market indicators
Stars: ✭ 162 (-92.79%)
Mutual labels:  stock-market
Liteexchange
My programming lab : multithreaded order matching engine in C++11 using FIX for order entry for Linux/Windows , no 3rd party libraries
Stars: ✭ 142 (-93.68%)
Mutual labels:  stock-market
Tf deep rl trader
Trading Environment(OpenAI Gym) + PPO(TensorForce)
Stars: ✭ 139 (-93.81%)
Mutual labels:  stock-market
Robinhood On Rails
A web dashboard for the free trading platform Robinhood using Ruby on Rails and a private API
Stars: ✭ 134 (-94.03%)
Mutual labels:  stock-market
Bovespastockratings
Crawler for Fundamental analysis platform for BOVESPA stocks, generating a score for each share according to the selected criteria on the indicators.
Stars: ✭ 154 (-93.14%)
Mutual labels:  stock-market
Pytse Client
work with Tehran stock exchange data in Python
Stars: ✭ 130 (-94.21%)
Mutual labels:  stock-market
Alpha Mind
quantitative security portfolio analysis. The analysis pipeline including data storage abstraction, alpha calculation, ML based alpha combining and portfolio calculation.
Stars: ✭ 171 (-92.39%)
Mutual labels:  stock-market
Simplestockanalysispython
Stock Analysis Tutorial in Python
Stars: ✭ 126 (-94.39%)
Mutual labels:  stock-market
Financial Machine Learning
A curated list of practical financial machine learning tools and applications.
Stars: ✭ 2,172 (-3.29%)
Mutual labels:  stock-market
Tiingo Python
Python REST Client for interacting with the Tiingo Financial Data API
Stars: ✭ 152 (-93.23%)
Mutual labels:  stock-market
Stock Market India
API for Indian Stock Market's NSE and BSE.
Stars: ✭ 185 (-91.76%)
Mutual labels:  stock-market
Paperbroker
An open source simulated options brokerage and UI for paper trading, algorithmic interfaces and backtesting.
Stars: ✭ 173 (-92.3%)
Mutual labels:  stock-market

                    Python Build Status Dependencies GitHub Issues Contributions welcome License

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 the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].