• Stars
    star
    568
  • Rank 78,502 (Top 2 %)
  • Language
    Python
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An example algorithm for a momentum-based day trading strategy.

Momentum-Trading-Example

An example algorithm for a momentum-based day trading strategy. This script uses the API provided by Alpaca. A brokerage account with Alpaca, available to US customers, is required to access the Polygon data stream used by this algorithm.

Running the Script

Note that near the top of the file, there are placeholders for your API informationโ€Š-โ€Šyour key ID, your secret key, and the URL you want to connect to. You can get all that information from the Alpaca dashboard. Replace the placeholder strings with your own information, and the script is ready to run with python algo.py. Please note that running with Python 3.6 is required.

Algorithm Logic

This algorithm may buy stocks during a 45 minute period each day, starting 15 minutes after market open. (The first 15 minutes are avoided, as the high volatility can lead to poor performance.) The signals it uses to determine if it should buy a stock are if it has gained 4% from the previous day's close, is above the highest point seen during the first 15 minutes of trading, and if its MACD is positive and increasing. (It also checks that the volume is strong enough to make trades on reliably.) It sells when a stock drops to a stop loss level or increases to a target price level. If there are open positions in your account at the end of the day on a symbol the script is watching, those positions will be liquidated at market. (Potentially holding positions overnight goes against the concept of risk that the algorithm uses, and must be avoided for it to be effective.)

More Repositories

1

marketstore

DataFrame Server for Financial Timeseries Data
Go
1,814
star
2

alpaca-trade-api-python

Python client for Alpaca's trade API
Python
1,552
star
3

pylivetrader

Python live trade execution library with zipline interface.
Python
622
star
4

example-scalping

A working example algorithm for scalping strategy trading multiple stocks concurrently using python asyncio
Python
619
star
5

example-hftish

Example Order Book Imbalance Algorithm
Python
615
star
6

alpaca-backtrader-api

Alpaca Trading API integrated with backtrader
Python
524
star
7

alpaca-trade-api-js

Node.js library for Alpaca Trade API.
JavaScript
428
star
8

alpaca-trade-api-go

Go client for Alpaca's trade API
Go
318
star
9

alpaca-py

The Official Python SDK for Alpaca API
Python
249
star
10

alpaca-trade-api-csharp

C# SDK for Alpaca Trade API https://docs.alpaca.markets/
C#
208
star
11

pipeline-live

Pipeline Extension for Live Trading
Python
198
star
12

alpaca-ts

A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
TypeScript
144
star
13

Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
136
star
14

pymarketstore

Python driver for MarketStore
Python
103
star
15

user-docs

Documentation for the Alpaca platform.
HTML
72
star
16

samplealgo01

Sample algo
Python
69
star
17

slait

A time-series data cache
Go
47
star
18

roboadvisor

Python
43
star
19

example-portfolio-manager

Simple portfolio management script in python
Python
42
star
20

insomnia-workspace

An Insomnia Workspace for Alpaca API
34
star
21

ribbit-backend

Backend for Ribbit, Broker API Reference App
Go
33
star
22

blogmaterials

Jupyter Notebook
30
star
23

alpaca-postman

Postman collections for Alpaca's APIs
29
star
24

alpaca-zipline

Alpaca riding on a zipline
Python
28
star
25

ribbit-ios

iOS app for Ribbit, Broker API Reference App
Swift
28
star
26

plug-and-play-strategies

Jupyter Notebook
27
star
27

sp100algo

Follow S&P100
Python
16
star
28

alpaca-erasure

Example script to generate Erasure data
Python
15
star
29

slackbot-trader

A Slackbot that can access the Alpaca API
Python
14
star
30

ribbit-android

Android app for Ribbit, Broker API Reference App
Java
12
star
31

alpaca-docs

Developer documentation for Alpaca API's
HTML
10
star
32

broker-fastapi-backend

A reference backend for Alpaca's Broker API utilizing Python & FastAPI
Python
8
star
33

bkdocs

Broker API Documentation
HTML
8
star
34

notebooks

A collection of Jupyter notebooks for getting started with Alpaca
Jupyter Notebook
6
star
35

Alpaca-Flutter-Demo-App

A boilerplate trading application to trade crypto on Alpaca. Made with Flutter and Dart.
C++
5
star
36

alpacadecimal

Similar and compatible with decimal.Decimal, but optimized for Alpaca's data sets.
Go
5
star
37

supertrend_crypto_bot

An Alpaca Live Crypto Trading Bot built with Python!
Python
4
star
38

Triangular-Arbitrage-with-Alpaca-API-s

Python
3
star
39

quantopian-fundamentals-examples

Implementations of algorithms from https://blog.quantopian.com/fundamentals-contest-winners/ using Alpaca's API.
Python
3
star
40

plprofiler

Python
2
star
41

alpaca-discord-bot

Python
1
star
42

go-onfido

Wrapper around the go-onfido-openapi package
1
star
43

alexa-trader-skill

An Alexa skill that can access the Alpaca API
1
star
44

go-onfido-openapi

Golang sdk for onfido. Generated from openapi
Shell
1
star