vectorbtvectorbt
A fast Python library for vectorized backtesting that can test thousands of strategy variations in seconds.ספריית Python מהירה ל-backtesting וקטורי, שיכולה לבדוק אלפי וריאציות של אסטרטגיה בשניות.
What is it?מה זה?
vectorbt is a Python package for backtesting and analyzing trading strategies built on pandas, NumPy and Numba. Instead of looping through time bar by bar, it represents signals and portfolios as arrays, so many parameter combinations can be simulated at once. The open-source version is the community edition, licensed as Apache 2.0 with Commons Clause. A separate paid product, VectorBT PRO, adds features such as parallelization, portfolio optimization and more order types.vectorbt היא חבילת Python ל-backtesting ולניתוח אסטרטגיות מסחר, שבנויה על pandas, NumPy ו-Numba. במקום לעבור על הזמן בר אחר בר בלולאה, היא מייצגת סיגנלים ותיקים כמערכים, כך שאפשר לדמות הרבה צירופי פרמטרים בבת אחת. גרסת הקוד הפתוח היא ה-community edition, ברישיון Apache 2.0 with Commons Clause. מוצר נפרד בתשלום, VectorBT PRO, מוסיף יכולות כמו מקביליות, אופטימיזציית תיקים וסוגי פקודות נוספים.
Why it matters for quantsלמה זה חשוב לקוואנטים
In early research you want to know quickly whether an idea has any signal and how sensitive it is to its parameters. vectorbt is built for exactly that: sweeping across many windows or thresholds and viewing results as a heatmap rather than a single number. That sensitivity view helps you spot fragile, overfit strategies whose performance depends on one lucky setting. Quants often screen ideas in a vectorized tool like this and then validate the survivors in an event-driven engine with more realistic execution.בשלב המחקר המוקדם רוצים לדעת מהר אם לרעיון יש סיגנל כלשהו ועד כמה הוא רגיש לפרמטרים. vectorbt נבנתה בדיוק לזה: סריקה של הרבה חלונות או ספים וצפייה בתוצאות כ-heatmap במקום כמספר בודד. התצוגה הזו של רגישות עוזרת לזהות אסטרטגיות שבירות עם overfitting, שהביצועים שלהן תלויים בהגדרה אחת שהתמזל בה מזל. קוונטים מסננים לעיתים קרובות רעיונות בכלי וקטורי כזה, ואז מאמתים את מי ששרדו במנוע event-driven עם ביצוע ריאליסטי יותר.
What quants look forמה קוואנטים מחפשים שם
- Portfolio.from_signals() to turn entry and exit signals into a simulated portfolioPortfolio.from_signals() להפיכת סיגנלי כניסה ויציאה לתיק מדומה
- Built-in indicators such as MA and RSI that run across many parameter values at onceאינדיקטורים מובנים כמו MA ו-RSI שרצים על הרבה ערכי פרמטרים בבת אחת
- Performance statistics (total return, Sharpe ratio, max drawdown) and trade recordsסטטיסטיקות ביצועים (תשואה כוללת, Sharpe ratio, max drawdown) ורשומות עסקאות
- Fees and slippage parameters to make simulations more realisticפרמטרים של עמלות ו-slippage כדי שהסימולציות יהיו ריאליסטיות יותר
- Interactive plots and parameter heatmapsגרפים אינטראקטיביים ו-heatmaps של פרמטרים
How to get startedאיך מתחילים
- Install it with: pip install -U vectorbtהתקינו עם: pip install -U vectorbt
- Run the moving-average crossover example below in a Jupyter notebook.הריצו את דוגמת חציית הממוצעים הנעים שלמטה ב-notebook של Jupyter.
- Call pf.stats() and pf.plot() to see the full statistics and equity curve.קראו ל-pf.stats() ול-pf.plot() כדי לראות את הסטטיסטיקות המלאות ואת עקומת ההון.
- Pass lists of window lengths to the indicators to test many combinations, then compare results.העבירו לאינדיקטורים רשימות של אורכי חלונות כדי לבדוק הרבה צירופים, ואז השוו תוצאות.
Code exampleדוגמת קוד
import vectorbt as vbt
price = vbt.YFData.download("BTC-USD", start="2019-01-01 UTC", end="2020-01-01 UTC").get("Close")
fast_ma = vbt.MA.run(price, 10, short_name="fast")
slow_ma = vbt.MA.run(price, 20, short_name="slow")
entries = fast_ma.ma_crossed_above(slow_ma)
exits = fast_ma.ma_crossed_below(slow_ma)
pf = vbt.Portfolio.from_signals(price, entries, exits)
print(pf.total_return())
Adapted from the official vectorbt quick start. It downloads data through yfinance, so it needs an internet connection. This simple test ignores fees by default.מבוסס על ה-quick start הרשמי של vectorbt. הקוד מוריד נתונים דרך yfinance, ולכן צריך חיבור לאינטרנט. הבדיקה הפשוטה הזו מתעלמת מעמלות כברירת מחדל.
Tips & pitfallsטיפים ומלכודות
- Testing thousands of combinations makes it easy to find one that looks amazing by chance. Look for broad, stable regions in the heatmap, not the single best cell.בדיקה של אלפי צירופים מקלה על מציאת אחד שנראה מדהים במקרה. חפשו אזורים רחבים ויציבים ב-heatmap, לא את התא הטוב ביותר.
- Add realistic fees and slippage (the fees and slippage arguments); many fast strategies vanish once costs are included.הוסיפו עמלות ו-slippage ריאליסטיים (הארגומנטים fees ו-slippage); הרבה אסטרטגיות מהירות נעלמות ברגע שמכניסים עלויות.
- The open-source license (Commons Clause) restricts selling products or services that are mainly vectorbt itself. Check it if you plan commercial use.רישיון הקוד הפתוח (Commons Clause) מגביל מכירה של מוצרים או שירותים שהם בעיקרם vectorbt עצמה. בדקו אותו אם אתם מתכננים שימוש מסחרי.
Relatedקשור
Sourcesמקורות
Quant Israel is not affiliated with this service or company. Details may change — check the official site. Nothing here is investment advice.Quant Israel אינה קשורה לשירות או לחברה הזו. הפרטים עשויים להשתנות — בדקו באתר הרשמי. שום דבר כאן אינו ייעוץ השקעות.