All Projects → devalpha-io → Devalpha Node

devalpha-io / Devalpha Node

Licence: gpl-3.0
A stream-based approach to algorithmic trading and backtesting in Node.js

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Devalpha Node

Quantdom
Python-based framework for backtesting trading strategies & analyzing financial markets [GUI ]
Stars: ✭ 449 (+106.91%)
Mutual labels:  trading, algorithmic-trading, trading-strategies, algotrading
Algotrading
Algorithmic trading framework for cryptocurrencies.
Stars: ✭ 249 (+14.75%)
Mutual labels:  trading, algorithmic-trading, algotrading, backtest
Vectorbt
Ultimate Python library for time series analysis and backtesting at scale
Stars: ✭ 855 (+294.01%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Sibyl
Platform for backtesting and live-trading intraday Stock/ETF/ELW using recurrent neural networks
Stars: ✭ 32 (-85.25%)
Mutual labels:  trading, algorithmic-trading, backtest
Gekko Backtesttool
Batch backtest, import and strategy params optimalization for Gekko Trading Bot. With one command you will run any number of backtests.
Stars: ✭ 203 (-6.45%)
Mutual labels:  trading, trading-strategies, backtest
Trading Server
A multi-asset, multi-strategy, event-driven trade execution and management platform for running many algorithms/bots at many venues simultaneously with unified risk management and reporting. Uses MongoDB for storage and Telegram for user notifications/trade consent.
Stars: ✭ 191 (-11.98%)
Mutual labels:  trading, algorithmic-trading, backtest
Finta
Common financial technical indicators implemented in Pandas.
Stars: ✭ 901 (+315.21%)
Mutual labels:  trading, algorithmic-trading, algotrading
Grademark
An API for backtesting trading strategies in JavaScript and TypeScript.
Stars: ✭ 140 (-35.48%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
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 (-52.07%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Strategems.jl
Quantitative systematic trading strategy development and backtesting in Julia
Stars: ✭ 106 (-51.15%)
Mutual labels:  trading, trading-strategies, backtest
Aat
Asynchronous, event-driven algorithmic trading in Python and C++
Stars: ✭ 109 (-49.77%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Tradinggym
Trading and Backtesting environment for training reinforcement learning agent or simple rule base algo.
Stars: ✭ 813 (+274.65%)
Mutual labels:  trading, trading-strategies, backtest
Sgx Full Orderbook Tick Data Trading Strategy
Providing the solutions for high-frequency trading (HFT) strategies using data science approaches (Machine Learning) on Full Orderbook Tick Data.
Stars: ✭ 733 (+237.79%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Socktrader
🚀 Websocket based trading bot for 💰cryptocurrencies 📈
Stars: ✭ 152 (-29.95%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Introneuralnetworks
Introducing neural networks to predict stock prices
Stars: ✭ 486 (+123.96%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Jesse
An advanced crypto trading bot written in Python
Stars: ✭ 1,038 (+378.34%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Roq Api
API for algorithmic and high-frequency trading
Stars: ✭ 132 (-39.17%)
Mutual labels:  trading, algorithmic-trading, trading-strategies
Quantitative Notebooks
Educational notebooks on quantitative finance, algorithmic trading, financial modelling and investment strategy
Stars: ✭ 356 (+64.06%)
Mutual labels:  algorithmic-trading, trading-strategies, algotrading
Optopsy
A nimble options backtesting library for Python
Stars: ✭ 373 (+71.89%)
Mutual labels:  trading, algorithmic-trading, backtest
Backtesting.py
🔎 📈 🐍 💰 Backtest trading strategies in Python.
Stars: ✭ 1,124 (+417.97%)
Mutual labels:  trading, algorithmic-trading, trading-strategies

DevAlpha

Build Status Dependencies NPM Version Coverage Status

DevAlpha is a Javascript framework for creating and running your own algorithmic trading systems. It is built using TypeScript, weighs in at a less than 1500 lines of code, and is speedy as hell.

The internal architecture primarily consists of one big stream and a bunch of consumers. It is implemented using the excellent Highland streams library, and also makes use of some helper functions from Redux.

Features

  • [x] Event sourced
  • [x] Tiny footprint
  • [x] Easily extensible
  • [x] Simple API
  • [x] Thoroughly tested
  • [x] Typescript definitions

Interested in finance?

Talos is hiring senior engineers! Send an email to filip+hiring at talos.com.

Installation

Install using NPM:

npm install devalpha

Quickstart

(Check out devalpha-example for a starter repo.)

Getting started is easy as pie. Hook up any source of data you like and start trading in seconds.

import { createTrader } from 'devalpha'

const feeds = {
  myQuandlFeed: [1, 2, 3, 4],
  myStreamFeed: fs.createReadStream(...)
}

const strategy = (context, action) => {

  // Place an order
  if (action.type === 'myQuandlFeed') {
    context.order({
      identifier: action.payload.identifier,
      quantity: 100 * action.payload.signalStrength,
      price: 1000
    })
  }

  // Get current portfolio state
  const state = context.state()

  // Cancel an order
  if (state.capital.cash < 10000) {
    context.cancel({
      id: 123
    })
  }
}

// Create the trading stream
const stream = createTrader({ feeds }, strategy)

// Consumer the stream and make money!
stream.done(() => {
  console.log('Finished!')
})

Settings

const settings = {

  /* Toggle backtesting/realtime mode. In backtesting mode, events from the feed stream are pulled
  as needed rather than pushed as created. This allows you to do a number of events for each feed
  item, and then pull the next one only when you're finished with the current.
  
  NOTE: DevAlpha will only activate realtime mode when this parameter is explicitly set to `false`.
  This means that setting `backtesting: 0` will not do the job. */
  backtesting: true,

  /* Only used in realtime mode. The client manages order execution, and is provided to the 
  internal broker middleware. */
  client: null,

  /* Define the starting capital of your algorithm. Use only in backtesting mode. In realtime mode
  you're better of using the `initialStates` setting instead. */
  startCapital: 0,
  
  /* Provide initial states for your algorithm. One obvious use case would be when realtime
  trading, and you want to fetch positions, capital, or order information from your broker. */
  initialStates: {},

  /* An object mapping event names to stream-like objects. See https://highlandjs.org/#_(source)
  for a definition of "stream-like". Keys will be used as event type names. */
  feeds: {},

  /* Settings for your backtest. */
  backtest: {
    
    /* Denotes when your backtest is started (the first date of your backtesting data). */
    timestamp: 0,

    /* A number or a function used when calculating expected commission. */
    commission: 0

  },

  /* Settings for the guard middleware, which will prevent or alter orders (based on your
  configuration). */
  guard: {
    
    /* Allow/disallow shorting. */
    shorting: false,
    
    /* Allow/disallow trading on margin. */
    margin: false,

    /* An array of restricted instrument identifiers. Example: ['GOOG', 'SPOT']. */
    restricted: []

  },

  /* DevAlpha dashboard settings. */
  dashboard: {

    /* Toggle the DevAlpha dashboard. */
    active: false,

    /* Port used to pipe portfolio data. */
    port: 4449
  }

}

Usage

The createTrader-function returns an unconsumed stream, and so it is up to you to consume it (thereby running the strategy). Highland provides a number of ways of doing this (see here), but the easiest one is probably just to use .resume() like so:

const settings = {...}
const strategy = (context, action) => {...}

createTrader(settings, strategy).resume()

However, you could also do crazy things like this:

import { createTrader, ORDER_FILLED, ORDER_FAILED } from 'devalpha'

const settings = {...}
const strategy = (context, action) => {...}

const stream = createTrader(settings, strategy)

const slackStream = stream.fork()
const redisStream = stream.fork()

// Get Slack notifications on filled or failed orders
slackStream.each((event) => {
  if (event.action.type === ORDER_FILLED) {
    slackLogger.log('Hooray! An order was filled!')
  } else if (event.action.type === ORDER_FAILED) {
    slackLogger.log('Whoops! One of your orders was not executed!')
  }
})

// Place the current state in a Redis store
redisStream.each((event) => {
  redisClient.set('state', JSON.stringify(event.state))
})

Pretty neat, huh?

Resources

License

GNU GPL license. See the LICENSE.md file for details.

Responsibilities

The author of this software is not responsible for any indirect damages (foreseeable or unforeseeable), such as, if necessary, loss or alteration of or fraudulent access to data, accidental transmission of viruses or of any other harmful element, loss of profits or opportunities, the cost of replacement goods and services or the attitude and behavior of a third party.

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].