Giter Club home page Giter Club logo

trading-core's Introduction

trading-core

Description

Backend core needed for automated trading

This project implements the trading platform discussed in the book: Professional Automated Trading: Theory and Practice by Eugene A. Durenard.

Loading the project

To load this project, use QuickLisp. First, download or clone this repo into the quicklisp local-projects folder. Alternately, if you have cloned it into a different location, add a symbolic link to its location in the local-projects folder.

(ql:quickload "trading-core")

Examples

A simple back testing example is listed below. More example scripts can be found in the examples folder

(in-package :trading-core)

;; load historical data
(defparameter *security-data*
  `((:msft . ,(load-event-data "MSFT"
                               :start-date "1992-01-01" :end-date "2012-01-01"))
    (:aapl . ,(load-event-data "AAPL"
                               :start-date "1992-01-01" :end-date "2012-01-01"))))

;; create the trading agents that will process the historical data
(setf *agents*
      (list (make-instance 'adaptive-moving-avg-trend-following
                           :min-period 11 :max-period 21 :width-factor 1.5
                           :snr-factor .9 :security :msft)
            (make-instance 'adaptive-moving-avg-trend-following
                           :min-period 11 :max-period 21 :width-factor 1.2
                           :snr-factor .9 :security :msft)
            (make-instance 'adaptive-moving-avg-trend-following
                           :min-period 11 :max-period 21 :width-factor 1.5
                           :snr-factor .9 :security :aapl)
            (make-instance 'adaptive-moving-avg-trend-following
                           :min-period 11 :max-period 21 :width-factor 1.2
                           :snr-factor .9 :security :aapl)))

;; create a list of all events in datetime order for the simulation engine
(defparameter *events* (sort (copy-list (union (cdr (assoc :msft *security-data*))
                                               (cdr (assoc :aapl *security-data*))))
                             (lambda (x y)
                               (local-time:timestamp< (timestamp x) (timestamp y)))))

;; unless you wish to see all of the logging/debugging messages, turn off logging
(log:config :warn)

;; run the simulation
(run-simulation *events*)

(analyze *agents* *security-data*)

To using the included example files, load it.

;; Use of an example system
(load (merge-pathnames "trading-core/examples/backtesting-simulation.lisp"
                       (first ql:*local-project-directories*)))

License

MIT. See "LICENSE".

The generated analysis web pages use Highstocks, which has its own, separate licensing.

trading-core's People

Contributors

wzrdsappr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.