Skip to content
Automated trading example for https://alpaca.markets/
C#
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Alpaca
.gitattributes
.gitignore
AlpacaTrade.sln
LICENSE.md
README.md

README.md

AlpacaTrade

Donate with Bitcoin Donate with Ethereum Donate with Litecoin

Simple automated trading example for alpaca.markets written in C#.

Strategy

Entry

Buys at the low of day at 10:00 AM EST if the first hourly candle closes red. Day orders are used so they cancel at the market close. The strategy essentially resets everyday if there is no fill.

Exit

Sells when the position is up half the hourly 20 period Average True Range (ATR).

Stop

Holds the bag until profitable.

Requirements

You should have a live alpaca.markets brokerage account for real time data from Polygon. If you do not, you will need to modify the code to retrieve data from their free API that utilizes IEX. Using the free data means there will be missing bars on certain stocks and possibly wrong OHLC values. This will affect entries for the strategy.

Configuration

Upon first start a settings.json file will be created. This file allows you to set your Alpaca API keys and the symbols you want it to trade.

Disclaimer

Do not use this to trade with a live account without rigorous testing and do expect to lose all your money if you use the implemented strategy. I take no responsibility for how you use this code.

Risks of Automated Trading Systems

License

MIT

You can’t perform that action at this time.