- Home
- Search & Web
- Example Scalping
Example Scalping
A working example algorithm for scalping strategy trading multiple stocks concurrently using python
Rating
Votes
0
score
Downloads
0
total
Price
Free
No login needed
Works With
About
Concurrent Scalping Algo
This python script is a working example to execute scalping trading algorithm for Alpaca API. This algorithm uses real time order updates as well as minute level bar streaming from Polygon via Websockets (see the document for Polygon data access). One of the contributions of this example is to demonstrate how to handle multiple stocks concurrently as independent routine using Python's asyncio.
The strategy holds positions for very short period and exits positions quickly, so you have to have more than $25k equity in your account due to the Pattern Day Trader rule, to run this example. For more information about PDT rule, please read the document.
Dependency
This script needs latest Alpaca Python SDK. Please install it using pip
$ pip3 install alpaca-trade-apior use pipenv using Pipfile in this directory.
$ pipenv installUsage
$ python main.py --lot=2000 TSLA FB AAPLYou can specify as many symbols as you want. The script is designed to kick off while market is open. Nothing would happen until 21 minutes from the market open as it relies on the simple moving average as the buy signal.
Strategy
The algorithm idea is to buy the stock upon the buy signal (20 minute moving average crossover) as much as lot amount of dollar, then immediately sell the position at or above the entry price. The assumption is that the market is bouncing upward when this signal occurs in a short period of time. The buy signal is extremely simple, but what this strategy achieves is the quick reaction to exit the position as soon as the buy order fills. There are reasonable probabilities that you can sell the positions at the better prices than or the same price as your entry within the small window. We send limit order at the last trade or position entry price whichever the higher to avoid unnecessary slippage.
The buy order is canceled after 2 minutes if it does not fill, assuming the signal is not effective anymore. This could happen in a fast-moving market situation. The sell order is left indifinitely until it fills, but this may cause loss more than the accumulated profit depending on the market situation. This is where you can improve the risk control beyond this example.
The buy signal is calculated as soon as a minute bar arrives, which typically happen about 4 seconds after the top of every minute (this is Polygon's behavior for minute bar streaming).
Don't lose this
Three weeks from now, you'll want Example Scalping again. Will you remember where to find it?
Save it to your library and the next time you need Example Scalping, it’s one tap away — from any AI app you use. Group it into a bench with the rest of the team for that kind of task and you can pull the whole stack at once.
⚡ Pro tip for geeks: add a-gnt 🤵🏻♂️ as a custom connector in Claude or a custom GPT in ChatGPT — one click and your library is right there in the chat. Or, if you’re in an editor, install the a-gnt MCP server and say “use my [bench name]” in Claude Code, Cursor, VS Code, or Windsurf.
a-gnt's Take
Our honest review
This plugs directly into your AI and gives it new abilities it didn't have before. A working example algorithm for scalping strategy trading multiple stocks concurrently using python . Once connected, just ask your AI to use it. It's completely free and works across most major AI apps. This one just landed in the catalog — worth trying while it's fresh.
Tips for getting started
Tap "Get" above, pick your AI app, and follow the steps. Most installs take under 30 seconds.
What's New
Imported from GitHub
Ratings & Reviews
0.0
out of 5
0 ratings
No reviews yet. Be the first to share your experience.