All Projects → dysonance → Strategems.jl

dysonance / Strategems.jl

Licence: other
Quantitative systematic trading strategy development and backtesting in Julia

Programming Languages

julia
2034 projects

Projects that are alternatives of or similar to Strategems.jl

Tradingstrategies
Algorithmic trading strategies
Stars: ✭ 120 (+13.21%)
Mutual labels:  trading, finance, trading-strategies, quantitative-finance, quantitative-trading
Trading Backtest
A stock backtesting engine written in modern Java. And a pairs trading (cointegration) strategy implementation using a bayesian kalman filter model
Stars: ✭ 247 (+133.02%)
Mutual labels:  trading, finance, quantitative-finance, quantitative-trading, backtest
Machine Learning And Ai In Trading
Applying Machine Learning and AI Algorithms applied to Trading for better performance and low Std.
Stars: ✭ 258 (+143.4%)
Mutual labels:  trading, finance, trading-strategies, quantitative-finance, quantitative-trading
Turingtrader
The Open-Source Backtesting Engine/ Market Simulator by Bertram Solutions.
Stars: ✭ 132 (+24.53%)
Mutual labels:  trading, finance, trading-strategies, quantitative-finance, quantitative-trading
AutoTrader
A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.
Stars: ✭ 227 (+114.15%)
Mutual labels:  finance, trading, trading-strategies, quantitative-finance, quantitative-trading
Awesome Algorithmic Trading
A curated list of awesome algorithmic trading frameworks, libraries, software and resources
Stars: ✭ 328 (+209.43%)
Mutual labels:  trading, trading-strategies, quantitative-finance, quantitative-trading
Stocksharp
Algorithmic trading and quantitative trading open source platform to develop trading robots (stock markets, forex, crypto, bitcoins, and options).
Stars: ✭ 4,601 (+4240.57%)
Mutual labels:  trading, finance, trading-strategies, quantitative-finance
Quantdom
Python-based framework for backtesting trading strategies & analyzing financial markets [GUI ]
Stars: ✭ 449 (+323.58%)
Mutual labels:  trading, finance, trading-strategies, quantitative-finance
Quant
Codera Quant is a Java framework for algorithmic trading strategies development, execution and backtesting via Interactive Brokers TWS API or other brokers API
Stars: ✭ 104 (-1.89%)
Mutual labels:  trading, trading-strategies, quantitative-finance, quantitative-trading
Quant Notes
Quantitative Interview Preparation Guide, updated version here ==>
Stars: ✭ 180 (+69.81%)
Mutual labels:  finance, quantitative-finance, quantitative-trading, optimization
Introneuralnetworks
Introducing neural networks to predict stock prices
Stars: ✭ 486 (+358.49%)
Mutual labels:  trading, finance, trading-strategies, quantitative-finance
Interactivebrokers Algo System
Java/MySQL live algorithmic trading using Interactive Brokers API
Stars: ✭ 151 (+42.45%)
Mutual labels:  trading, finance, trading-strategies, quantitative-trading
okama
Investment portfolio and stocks analyzing tools for Python with free historical data
Stars: ✭ 87 (-17.92%)
Mutual labels:  finance, time-series, optimization, quantitative-finance
Awesome Quant
A curated list of insanely awesome libraries, packages and resources for Quants (Quantitative Finance)
Stars: ✭ 8,205 (+7640.57%)
Mutual labels:  finance, trading-strategies, quantitative-finance, quantitative-trading
Quantitative Notebooks
Educational notebooks on quantitative finance, algorithmic trading, financial modelling and investment strategy
Stars: ✭ 356 (+235.85%)
Mutual labels:  trading-strategies, quantitative-finance, quantitative-trading
Elitequant cpp
C/C++ 11 High frequency quantitative trading platform. It follows modern design patterns such as event-driven, server/client architect, dependency injection and loosely-coupled robust distributed system. It is self-contained and can be used out of box. At the same time, it serves as server side for other EliteQuant projects.
Stars: ✭ 341 (+221.7%)
Mutual labels:  trading-strategies, quantitative-trading, backtest
Gdax Orderbook Ml
Application of machine learning to the Coinbase (GDAX) orderbook
Stars: ✭ 60 (-43.4%)
Mutual labels:  trading, quantitative-finance, quantitative-trading
Elitequant python
Python quantitative trading and investment platform; Python3 based multi-threading, concurrent high-frequency trading platform that provides consistent backtest and live trading solutions. It follows modern design patterns such as event-driven, server/client architect, and loosely-coupled robust distributed system. It follows the same structure and performance metrix as other EliteQuant product line, which makes it easier to share with traders using other languages.
Stars: ✭ 394 (+271.7%)
Mutual labels:  trading-strategies, quantitative-trading, backtest
Machine Learning For Trading
Code for Machine Learning for Algorithmic Trading, 2nd edition.
Stars: ✭ 4,979 (+4597.17%)
Mutual labels:  trading, finance, trading-strategies
Rqalpha
A extendable, replaceable Python algorithmic backtest && trading framework supporting multiple securities
Stars: ✭ 4,425 (+4074.53%)
Mutual labels:  trading, finance, backtest

Build Status Coverage Status codecov.io

Strategems

Strategems is a Julia package aimed at simplifying and streamlining the process of developing, testing, and optimizing algorithmic/systematic trading strategies. This package is inspired in large part by the quantstrat1,2 package in R, adopting a similar general structure to the building blocks that make up a strategy.

Given the highly iterative nature of event-driven trading strategy development, Julia's high-performance design (particularly in the context of loops) and straightforward syntax would seem to make it a natural fit as a language for systematic strategy research and development. While this package remains early in development, with time the hope is to be able to rapidly implement a trading idea, construct a historical backtest, analyze its results, optimize over a given parameter set, and visualize all of this with great detail.

Dependencies

This package makes heavy use of the Temporal package's TS time series type to facilitate the underlying computations involved in cleaning & preprocessing the data used when testing a Strategy. Additionally, the Indicators package offers many technical analysis functions that have been written/designed with the goal of a highly generalized systematic trading strategy research engine in mind, and should thus should simplify the process of working with this data quite a bit.

Install

The Strategems package can be installed using the standard Julia package manager functions.

# Option A:
Pkg.add("Strategems")

# Option B:
Pkg.clone("https://github.com/dysonance/Strategems.jl")

Anatomy of a Strategy

Below are the basic building blocks making up the general anatomy of a Strategy with respect to the Strategems.jl package design and the type definitions used to facilitate the research workflow.

  • Universe: encapsulation of the assets/securities the strategy is to be allowed to trade
  • Indicator: calculation done on each asset in the universe whose results we think have predictive potential for future price movement
  • ParameterSet: inputs/arguments to the indicator calculations
  • Signal: boolean flag sending messages to the trading logic/rules to be interpreted and acted upon
  • Rule: applications of trading logic derived from interpretations of prior calculations & signals at each time step
  • Strategy: overarching object encapsulating and directing all of the above logic and data to power the backtesting engine

Example Usage

Below is a quick example demonstrating a simple use-case that one might use to get acquainted with how the package works. Note that the custom infix operators denoted by the uparrow and downarrow below are defined in this package as another way of expressing that one variable crosses over another. The intention of this infix operator definition is to hopefully make the definition of a strategy more syntactically expressive and intuitive.

The key indicator used in this strategy is John Ehlers's MESA Adaptive Moving Average (or MAMA for short). This functionality is implemented in the Indicators.jl package described above, and outputs a Matrix (or TS object if one is passed as an input) of two columns, the first being the MAMA itself and the second being the FAMA, or following adaptive moving average.

This strategy simply goes long when the MAMA crosses over the FAMA, and goes short when the FAMA crosses over the MAMA. Below is an implementation that shows how to set default arguments to the Indicators.mama function and run a simple backtest using those parameters, and also define specified ranges over which we might like to see how the strategy behaves under different parameter sets.

using Strategems, Indicators, Temporal, Dates

# define universe and gather data
assets = ["CHRIS/CME_CL1", "CHRIS/CME_RB1"]
universe = Universe(assets)
function datasource(asset::String; save_downloads::Bool=true)::TS
    savedata_path = joinpath(dirname(pathof(Strategems)), "..", "data", "$asset.csv")
    if isfile(savedata_path)
        return Temporal.tsread(savedata_path)
    else
        X = quandl(asset)
        if save_downloads
            if !isdir(dirname(savedata_path))
                mkdir(dirname(savedata_path))
            end
            Temporal.tswrite(X, savedata_path)
        end
        return X
    end
end
gather!(universe, source=datasource)

# define indicators and parameter space
arg_names     = [:fastlimit, :slowlimit]
arg_defaults  = [0.5, 0.05]
arg_ranges    = [0.01:0.01:0.99, 0.01:0.01:0.99]
paramset      = ParameterSet(arg_names, arg_defaults, arg_ranges)
f(x; args...) = Indicators.mama(x; args...)
indicator     = Indicator(f, paramset)

# define signals that will trigger trading decisions
# note the uparrow infix operator is defined to simplify one variable crossing over another
# (similarly for the downarrow infix operator for crossing under)
siglong  = @signal MAMA  FAMA
sigshort = @signal MAMA  FAMA
sigexit  = @signal MAMA == FAMA

# define the trading rules
longrule  = @rule siglong  long 100
shortrule = @rule sigshort  short 100
exitrule  = @rule sigexit  liquidate 1.0
rules     = (longrule, shortrule, exitrule)

# run strategy
strat = Strategy(universe, indicator, rules)
backtest!(strat)
optimize!(strat, samples=0)  # randomly sample the parameter space (0 -> use all combinations)

# cumulative pnl for each combination of the parameter space
strat.backtest.optimization

# visualizing results with the Plots.jl package
using Plots
gr()
(x, y, z) = (strat.backtest.optimization[:,i] for i in 1:3)
surface(x, y, z)

alt text

Roadmap / Wish List

  • Get a sufficiently full-featured type system established to facilitate easy construction of simple strategies
  • Allow more intelligent logic for trading rules
    • Adjust order sizing based on portfolio/account at time t
    • Portfolio optimization logic
    • Risk limits
    • Stop loss rules
  • Define a more diverse set of order types
    • Limit orders
    • Stop orders
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].