Git Product home page Git Product logo

alpacaalgo's Introduction

Theory

Every day the portfolio refreshes based on the EMA ranking among the universe (e.g. SP500 stocks), it ranks by daily (price - EMA) percentage as of trading time and keep positions in sync with lowest ranked stocks.

The idea is the low (price - EMA) vs price ration indicates there is a big dip in a short time. Since the universe is SP500 which means there is some fundamental strengths, the belief is that the price should be recovered to some extent. Also with the assumption that liquidty wouldn't be an issue

How to run

First set up you rAPI key in environment variables.

$ export APCA_API_KEY_ID=xxx
$ export APCA_API_SCRET_KEY=yyy

The only dependency is the alpace-trade-api module. You can set up the environment by pipenv. If python 3 and the dependency is ready,

$ python main.py

This repository is also set up for Heroku. If you have a Heroku account, create a new app and run this as an application. It is only one worker app so make sure you set up worker type app.

Customization

universe.Universe is hard-coded. Easy customization is to change this to a more dynamic set of stocks with some filters like per-share price set to a minimum or maximum. The assumption is that at most a position can take is up 20% of the portfolio. If your account siz varies or risk tolerance then changing the values is needed.

For the future

btes.py runs a simple simulation. Module needs more easy visualization or integrated setup.

alpacaalgo's People

Contributors

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