Giter Club home page Giter Club logo

easyalgo's Introduction

A Buy-on-dip algo for Alpaca API

This is a simple algo that trades every day refreshing portfolio 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 rationale behind this: low (price - EMA) vs price ratio 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.

How to run

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

$ python main.py

That's it.

Also, this repository is set up for Heroku. If you have 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.

Cutomization

universe.Universe is hard-coded. Easy customization is to change this to more dynamic set of stocks with some filters such as per-share price to be less than $50 or so. Some of the numbers are also hard-coded and it is meant to run in an account with about $500 deposit, with asuumption that one position to be up to $100, resulting in 5 positions at most. If your account size and position size preference are different, you can change these valuess.

EMA-5 is also very arbitrary choice. You could try something like 10, too.

Future work

There is btest.py that runs a simple simulation. This module needs more easy visualization and more integrated setup, possibly using jupyter and matplotlib.

easyalgo's People

Watchers

 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.