alpacahq/Momentum-Trading-Example
关于
一个基于动量的日内交易策略示例算法。
商业与金融实测星标增长
- 24小时
- +2
- 7天
- +2
- 15天
- +2
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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.)
探索相关项目
加载中…