-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_bot.py
More file actions
41 lines (30 loc) · 905 Bytes
/
Copy pathrun_bot.py
File metadata and controls
41 lines (30 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Entry point for the trading bot."""
import sys
from pathlib import Path
# Ensure project root is on sys.path so both `bot` and local `lumibot` resolve.
ROOT = Path(__file__).resolve().parent
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from lumibot.brokers import Alpaca
from lumibot.traders import Trader
from bot.config import settings
from bot.strategy import TradingStrategy
from bot.utils import setup_logging
setup_logging()
def main() -> None:
broker = Alpaca(settings.alpaca_config)
strategy = TradingStrategy(
broker=broker,
parameters={
"symbol": "SPY",
"risk_per_trade": 0.02,
"max_positions": 5,
"stop_loss_pct": 0.02,
"take_profit_pct": 0.04,
},
)
trader = Trader()
trader.add_strategy(strategy)
trader.run_all()
if __name__ == "__main__":
main()