xiaohongshu
xiaohongshu
broker-order-limitations
Alpaca broker limitations: crypto shorts blocked (broker doesn't support), stock shorts allowed. Trigger when: (1) shorting gate blocks wrong assets, (2) SELL signals blocked, (3) order type confusion.
Full skill instructions
| Item | Details |
|---|---|
| Date | 2024-12-26 |
| Goal | Document broker-specific order limitations |
| Environment | scripts/live_trader.py, Alpaca Trading API |
| Status | Reference |
Alpaca broker has specific limitations on order types. The most important one for this trading system:
Crypto shorting is NOT supported by Alpaca. Stock shorting IS allowed.
This distinction is critical because:
# In live_trader.py (~line 1335)
# Only block shorts for crypto, not equities
if desired_side == -1 and asset_type == AssetType.CRYPTO and state.side <= 0:
# Trying to go short on crypto when not already long
gate_statuses[symbol] = GateStatus(
final_status='BLOCKED',
blocking_gate='crypto_short',
crypto_short_gate=False, # Failed
)
continue
# desired_side == -1: Model wants to SELL
# asset_type == AssetType.CRYPTO: Asset is cryptocurrency
# state.side <= 0: Not currently holding a long position
# All three conditions must be true to block:
# 1. SELL signal (-1)
# 2. Is crypto (not equity)
# 3. Would be opening a short (not closing a long)
| Asset Type | Buy (Long) | Sell to Close | Sell to Short |
|---|---|---|---|
| Equity | Yes | Yes | Yes |
| Crypto | Yes | Yes | NO |
When crypto short is blocked:
gate_status = {
'final_status': 'BLOCKED',
'blocking_gate': 'crypto_short',
'crypto_short_gate': False,
# ... other gates may be True
}
| Attempt | Why it Failed | Lesson Learned |
|---|---|---|
| Block all SELL signals for crypto | Prevented closing profitable longs | Only block new shorts |
| Block all shorts (crypto + equity) | Equity shorts are valid strategy | Check asset type |
| No short gate at all | Orders rejected by broker | Pre-filter before submission |
Check desired_side < 0 | Could catch rounding errors | Use == -1 exactly |
| Order Type | Equities | Crypto |
|---|---|---|
| Market Buy | Yes | Yes |
| Market Sell | Yes | Yes (close only) |
| Limit Buy | Yes | Yes |
| Limit Sell | Yes | Yes (close only) |
| Stop Loss | Yes | Yes |
| Take Profit | Yes | Yes |
| Short Sell | Yes | NO |
| Fractional | Yes (0.001) | Yes (varies) |
USD (e.g., BTCUSD, ETHUSD)# Simple heuristic used in live_trader.py
def is_crypto(symbol: str) -> bool:
return symbol.endswith('USD')
# Or use Alpaca's asset class
from alpaca.trading.enums import AssetClass
asset = api.get_asset(symbol)
is_crypto = asset.asset_class == AssetClass.CRYPTO
The model is trained on both crypto and equity data. It learns:
Blocking shorts in the model would:
Better approach: Let model predict freely, filter at execution gate.
When equity markets close, capital shifts to crypto. During this time:
scripts/live_trader.py:
- Line 1335: Crypto short gate check
- Uses AssetType enum for asset classification
- Gate status stored in gate_statuses dict
scripts/live_trader.py: Order execution logic (lines ~1300-1400)alpaca_trading/risk/capital_shift.py: Equity→crypto shift logicxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience