

คุณกำลังมองหาการปรับปรุงกลยุทธ์การซื้อขายของคุณด้วยพลังของ Python และการเรียนรู้ของเครื่องหรือไม่? จากนั้นคุณต้องตรวจสอบ Pybroker ! เฟรมเวิร์ก Python นี้ได้รับการออกแบบมาเพื่อพัฒนากลยุทธ์การซื้อขายอัลกอริทึมโดยมุ่งเน้นที่กลยุทธ์ที่ใช้การเรียนรู้ของเครื่อง ด้วย Pybroker คุณสามารถสร้างและปรับแต่งกฎการซื้อขายได้อย่างง่ายดายสร้างโมเดลที่ทรงพลังและรับข้อมูลเชิงลึกที่มีค่าเกี่ยวกับประสิทธิภาพของกลยุทธ์ของคุณ
ด้วย Pybroker คุณจะมีเครื่องมือทั้งหมดที่คุณต้องการในการสร้างกลยุทธ์การซื้อขายที่ได้รับการสนับสนุนจากข้อมูลและการเรียนรู้ของเครื่อง เริ่มใช้ Pybroker วันนี้และนำการซื้อขายของคุณไปอีกระดับ!
Pybroker รองรับ Python 3.9+ บน Windows, Mac และ Linux คุณสามารถติดตั้ง pybroker โดยใช้ pip :
pip install -U lib-pybrokerหรือคุณสามารถโคลนพื้นที่เก็บข้อมูล Git ด้วย:
git clone https://github.com/edtechre/pybrokerรับแวบเดียวของสิ่งที่ backtesting กับ pybroker ดูเหมือนกับตัวอย่างรหัสเหล่านี้:
กลยุทธ์ตามกฎ :
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 )กลยุทธ์ตามแบบจำลอง :
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 )เอกสารอ้างอิงเต็มรูปแบบโฮสต์ที่ www.pybroker.com
(สำหรับผู้ใช้จีน: 中文文档ความอนุเคราะห์จาก Albert King)

รับทราบข้อมูลเกี่ยวกับข่าว AI เกี่ยวกับหุ้นที่ได้รับความนิยมสูงสุด ดู www.trendninja.ai สำหรับการอัปเดตล่าสุด!