

Möchten Sie Ihre Handelsstrategien mit der Kraft von Python und maschinellem Lernen verbessern? Dann müssen Sie sich Pybroker ansehen! Dieses Python -Framework ist für die Entwicklung algorithmischer Handelsstrategien konzipiert und konzentriert sich auf Strategien, die maschinelles Lernen verwenden. Mit Pybroker können Sie Handelsregeln erstellen und fein abteilen, leistungsstarke Modelle erstellen und wertvolle Einblicke in die Leistung Ihrer Strategie gewinnen.
Mit Pybroker verfügen Sie über alle Tools, die Sie benötigen, um Gewinnerstrategien zu erstellen, die durch Daten und maschinelles Lernen unterstützt werden. Verwenden Sie noch heute Pybroker und bringen Sie Ihren Handel auf die nächste Stufe!
Pybroker unterstützt Python 3.9+ unter Windows, Mac und Linux. Sie können Pybroker mit pip installieren:
pip install -U lib-pybrokerOder Sie können das Git -Repository mit:
git clone https://github.com/edtechre/pybrokerErhalten Sie einen Blick darauf, wie Backtesting mit Pybroker mit diesen Code -Snippets aussieht:
Regelbasierte Strategie :
from pybroker import Strategy , YFinance , highest
def exec_fn ( ctx ):
# Get the rolling 10 day high.
high_10d = ctx . indicator ( 'high_10d' )
# Buy on a new 10 day high.
if not ctx . long_pos () and high_10d [ - 1 ] > high_10d [ - 2 ]:
ctx . buy_shares = 100
# Hold the position for 5 days.
ctx . hold_bars = 5
# Set a stop loss of 2%.
ctx . stop_loss_pct = 2
strategy = Strategy ( YFinance (), start_date = '1/1/2022' , end_date = '7/1/2022' )
strategy . add_execution (
exec_fn , [ 'AAPL' , 'MSFT' ], indicators = highest ( 'high_10d' , 'close' , period = 10 ))
# Run the backtest after 20 days have passed.
result = strategy . backtest ( warmup = 20 )Modellbasierte Strategie :
import pybroker
from pybroker import Alpaca , Strategy
def train_fn ( train_data , test_data , ticker ):
# Train the model using indicators stored in train_data.
...
return trained_model
# Register the model and its training function with PyBroker.
my_model = pybroker . model ( 'my_model' , train_fn , indicators = [...])
def exec_fn ( ctx ):
preds = ctx . preds ( 'my_model' )
# Open a long position given my_model's latest prediction.
if not ctx . long_pos () and preds [ - 1 ] > buy_threshold :
ctx . buy_shares = 100
# Close the long position given my_model's latest prediction.
elif ctx . long_pos () and preds [ - 1 ] < sell_threshold :
ctx . sell_all_shares ()
alpaca = Alpaca ( api_key = ..., api_secret = ...)
strategy = Strategy ( alpaca , start_date = '1/1/2022' , end_date = '7/1/2022' )
strategy . add_execution ( exec_fn , [ 'AAPL' , 'MSFT' ], models = my_model )
# Run Walkforward Analysis on 1 minute data using 5 windows with 50/50 train/test data.
result = strategy . walkforward ( timeframe = '1m' , windows = 5 , train_size = 0.5 )Die vollständige Referenzdokumentation wird unter www.pybroker.com gehostet.
(Für chinesische Nutzer: 中文文档 mit freundlicher Genehmigung von Albert King.)

Bleiben Sie mit KI-angetriebenen Nachrichten über Top-Trendaktien informiert. Weitere Informationen finden Sie unter www.trendninja.ai!