Skip to content

alpacahq/alpaca-erasure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alpaca - Erasure

This script is an example code that calcualtes stock scores every day using latest price data. With the output of this script, you can build daily rebalancing long-short algorithm.

The score is calculated using exponential weighted moving average with span=10, and take the difference from last day closing price. The value range is between 0 and 1 with 0 being most overvalued and 1 being most undervalued. For more information, please take a look at the reference below.

How to

Install alpaca-trade-api

$ pip install alpaca-trade-api

and run erasure.py

$ python erasure.py

It outputs something like below.

...
PFIE,0.5015664246239445
PFIS,0.4997877550102791
PFNX,0.4768029748467622
PFPT,0.500816891906715
PFS,0.5010411315523059
PFSI,0.5053465393041152
PFSW,0.5149531269639088
PG,0.49686832450835694
PGC,0.5057306188423834
PGNX,0.4998828329411989
PGR,0.498740133468462
PGRE,0.5007967622834778
PGTI,0.5019629289791301
...

Reference

The part of scoring logic was extracted from Alpaca tutorial algorithm

About

Example script to generate Erasure data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages