xiaohongshu
xiaohongshu
Expert skill for building high-performance EUR/CAD forex trading bots with IBKR integration, advanced strategies, news analysis, and proven high win-rate systems for both demo and live environments
Full skill instructions
When building EUR/CAD forex trading bots, you MUST follow these expert guidelines:
EUR/CAD is heavily influenced by:
You MUST read:
eurcad-trading-bot/additional_context.md for detailed market characteristics.
Implement these proven strategies for EUR/CAD:
You MUST review:
eurcad-trading-bot/scripts/strategy_template.py for implementation patterns.
Position Sizing:
Position = (Account * Risk%) / (Stop Loss in Pips * Pip Value)Stop Loss Rules:
Stop = Entry ± (2 × ATR)Daily Limits:
You MUST implement:
eurcad-trading-bot/scripts/risk_manager.py for all position sizing.
Critical News Sources:
Implementation Steps:
You MUST reference:
eurcad-trading-bot/scripts/news_parser_example.py for implementation.
from ib_insync import IB, Forex
ib = IB()
ib.connect('127.0.0.1', 7497, clientId=1) # Paper trading port: 7497
# Create EUR/CAD contract
eurcad = Forex('EURCAD')
ib.qualifyContracts(eurcad)
# Place market order
order = ib.placeOrder(eurcad, MarketOrder('BUY', 20000))
ib.connect('127.0.0.1', 7496, clientId=1) # Live trading port: 7496
# CRITICAL: Implement additional safety checks for live
# - Verify sufficient margin
# - Double-check order parameters
# - Implement circuit breakers
Connection Requirements:
You MUST follow:
eurcad-trading-bot/scripts/ibkr_connection_example.py for connection patterns.
ForexBot/
├── main.py # Entry point, orchestration
├── strategies/
│ ├── base_strategy.py # Abstract strategy class
│ ├── mean_reversion.py # Mean reversion implementation
│ ├── trend_following.py # Trend strategy
│ └── news_breakout.py # News-based strategy
├── data/
│ ├── data_feed.py # Real-time data handling
│ └── historical.py # Backtesting data
├── execution/
│ ├── ibkr_client.py # IBKR connection manager
│ └── order_manager.py # Order execution logic
├── risk/
│ ├── position_sizer.py # Position sizing calculations
│ └── risk_monitor.py # Real-time risk tracking
└── utils/
├── news_feed.py # Economic calendar integration
└── logger.py # Trade logging
Before deploying ANY strategy:
You MUST use:
eurcad-trading-bot/scripts/backtesting_framework.py for validation.
Implement these mandatory safety features:
Kill Switch Conditions:
Emergency Procedures:
Log Every:
Performance Tracking:
# See full implementation in:
# eurcad-trading-bot/scripts/strategy_template.py
from ib_insync import IB, Forex, MarketOrder
import pandas as pd
import talib
class MeanReversionBot:
def __init__(self):
self.ib = IB()
self.ib.connect('127.0.0.1', 7497, clientId=1)
self.eurcad = Forex('EURCAD')
self.position_size = 20000 # 2 mini lots
def calculate_signals(self, df):
# Bollinger Bands
upper, middle, lower = talib.BBANDS(df['close'], timeperiod=20)
df['rsi'] = talib.RSI(df['close'], timeperiod=14)
# Buy signal: Price touches lower band + RSI < 30
buy_signal = (df['close'] <= lower) & (df['rsi'] < 30)
# Sell signal: Price touches upper band + RSI > 70
sell_signal = (df['close'] >= upper) & (df['rsi'] > 70)
return buy_signal, sell_signal
def execute_trade(self, signal):
if signal == 'BUY':
order = MarketOrder('BUY', self.position_size)
self.ib.placeOrder(self.eurcad, order)
elif signal == 'SELL':
order = MarketOrder('SELL', self.position_size)
self.ib.placeOrder(self.eurcad, order)
# Monitor economic calendar and adjust trading
# See: eurcad-trading-bot/scripts/news_parser_example.py
import requests
from datetime import datetime, timedelta
def get_high_impact_news():
# Forex Factory API or Trading Economics
url = "https://nfs.faireconomy.media/ff_calendar_thisweek.json"
response = requests.get(url)
events = response.json()
# Filter EUR and CAD high-impact events
important_events = [
e for e in events
if e['impact'] == 'High' and e['country'] in ['EUR', 'CAD']
]
return important_events
def is_safe_to_trade():
events = get_high_impact_news()
now = datetime.now()
for event in events:
event_time = datetime.fromisoformat(event['date'])
time_diff = abs((now - event_time).total_seconds() / 60)
# Block trading 5 min before, 2 min after
if time_diff < 5:
return False
return True
# See: eurcad-trading-bot/scripts/risk_manager.py
def calculate_position_size(account_balance, risk_percent, stop_loss_pips):
"""
Calculate position size based on risk management rules
Args:
account_balance: Current account equity
risk_percent: Risk per trade (e.g., 0.02 for 2%)
stop_loss_pips: Stop loss distance in pips
Returns:
Position size in units
"""
pip_value = 10 # For EUR/CAD, 1 pip = $10 per lot
risk_amount = account_balance * risk_percent
position_size = risk_amount / (stop_loss_pips * pip_value)
# Round to nearest 1000 units (0.01 lot)
position_size = round(position_size / 1000) * 1000
return int(position_size)
# Example usage:
account = 10000 # $10k account
risk = 0.02 # 2% risk
stop_pips = 25 # 25 pip stop loss
size = calculate_position_size(account, risk, stop_pips)
print(f"Trade size: {size} units ({size/100000} lots)")
# Output: Trade size: 8000 units (0.08 lots)
# See: eurcad-trading-bot/scripts/ibkr_connection_example.py
from ib_insync import IB, Forex, MarketOrder, LimitOrder
import time
class SafeIBKRTrader:
def __init__(self, paper_trading=True):
self.ib = IB()
port = 7497 if paper_trading else 7496
self.ib.connect('127.0.0.1', port, clientId=1)
self.eurcad = Forex('EURCAD')
self.ib.qualifyContracts(self.eurcad)
def place_safe_order(self, action, quantity, stop_loss_pips):
"""Place order with stop loss and safety checks"""
# Get current price
ticker = self.ib.reqMktData(self.eurcad)
time.sleep(2) # Wait for data
if action == 'BUY':
entry_price = ticker.ask
stop_price = entry_price - (stop_loss_pips * 0.0001)
else:
entry_price = ticker.bid
stop_price = entry_price + (stop_loss_pips * 0.0001)
# Place main order
main_order = MarketOrder(action, quantity)
trade = self.ib.placeOrder(self.eurcad, main_order)
# Wait for fill
while not trade.isDone():
self.ib.sleep(0.1)
if trade.orderStatus.status == 'Filled':
# Place stop loss
stop_action = 'SELL' if action == 'BUY' else 'BUY'
stop_order = MarketOrder(stop_action, quantity)
stop_order.conditions = [
PriceCondition(self.eurcad, stop_price)
]
self.ib.placeOrder(self.eurcad, stop_order)
print(f"Order filled: {action} {quantity} @ {entry_price}")
print(f"Stop loss placed @ {stop_price}")
return trade
See complete working bot implementation:
eurcad-trading-bot/scripts/strategy_template.pyeurcad-trading-bot/scripts/risk_manager.pyeurcad-trading-bot/scripts/news_parser_example.pyeurcad-trading-bot/scripts/ibkr_connection_example.pyeurcad-trading-bot/scripts/backtesting_framework.pySee optimized parameters in:
eurcad-trading-bot/strategy_parameters.md
Mean Reversion:
- Bollinger Bands: 20 period, 2 std dev
- RSI: 14 period, buy < 30, sell > 70
- Timeframe: 15-min charts
- Win rate: 72% (backtested 2022-2024)
Trend Following:
- EMA Fast: 12, EMA Slow: 26
- MACD: 12, 26, 9
- ADX: > 25 for trend confirmation
- Timeframe: 1-hour charts
- Win rate: 68% (backtested 2022-2024)
eurcad-trading-bot/additional_context.mdeurcad-trading-bot/data.csveurcad-trading-bot/scripts/eurcad-trading-bot/strategy_parameters.mdRemember: Consistent profitability comes from discipline, not from complex strategies. Follow the rules, manage risk, and let the edge play out over time.
xiaohongshu
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