Multi-session x Multi-strategy in one single process. • Ability to develop private strategy. • Back-testing with KLine Data (candlestick data) • Grid Search Optimizer
Info Standard Indicators Market Data Store Trade Store Account Information Margin Related Info Strategy #1 Bind Callbacks Bind Callbacks Access Common Exchange API Send Request
strategy ID. • InstanceID() — returns the instance ID of the strategy. • Subscribe(session) — for adding the market data subscriptions. • Run() — the core strategy logics.
quantity and quote quantity. • When you buy 1 BTC at 19300, your average cost = 19300, base = 1, quote = -19300 • Then you sell 0.5 BTC at 20000, your average cost = 19300, base = 0.5, quote = -9300 • Then you buy 0.5 BTC at 18000, your average cost = 18650, base = 1, quote = -18300
you hold Long position, it means you hold positive base quantity. • You spent quote currency (-19000 USDT) and increase base quantity (+1 BTC) • When you hold Short position, it means you hold negative base quantity. • You spent base currency (-1 BTC) and increase quote quantity (+19000 USDT) • The base asset borrow in the spot margin trading. • Or, Sell Short in the futures contract. • Or, if you hold some inventory with zero cost basis, you can sell these inventory to hold a short position.
ff erent Strategies shares the same user data stream for each exchange. • The strategy itself needs to know which trade belongs to its sent orders. • *bbgo.TradeCollector helps you collect the trades of your sent orders. • *types.Position will be updated by *bbgo.TradeCollector. • *bbgo.ActiveOrderBook helps you manage the open orders. • Each strategy can manage its own position and active orders.
exchange, you register the returned order ID to the trade collector. • TradeCollector receives the trades from the user data stream and update the position. • Updating position also generates the pro fi t information.
the position ROI (currently the price change) - roiStopLoss: percentage: 0.8% # (1) roiTakeProfit is used to force taking profit by percentage of the position ROI (currently the price change) # force to take the profit ROI exceeded the percentage. - roiTakeProfit: percentage: 35% # (2) protective stop loss -- short term - protectiveStopLoss: activationRatio: 0.6% stopLossRatio: 0.1% placeStopOrder: false # (3) protective stop loss -- long term - protectiveStopLoss: activationRatio: 5% stopLossRatio: 1% placeStopOrder: false
In the example, suppose for the sake of simplicity that 60 trades were winners, and 40 were losers. Your win/loss ratio would be 60/40 = 1.5. That would mean that you are winning 50% more often than you are losing. symbol: ETHUSDT winningRatio: "0.94736842" numOfLossTrade: 19 numOfPro fi tTrade: 18 grossPro fi t: "30171.32449936" grossLoss: "-3515.41900049" pro fi ts: - "1.59999990" - "11586.99999990" - "20.60000000" - "16.89999999" - "10.39999989" - "12.00000000" - "30.70000000" - "276.80000000" - "267.10000000" - "205.80000000" - "26.29999999" - "24.60000000" - "29.90000000" - "10716.39999990" - "146.24999989" - "10.01649999" - "175.20000000" - "6613.75799990" losses: - "-36.58000000" - "-202.20000000" - "-208.20000000" - "-203.90000000" - "-239.30000000" - "-220.30000000" - "-6.49700000" - "-270.10000010" - "-267.20000000" - "-248.70000000" - "-236.50000000" - "-9.19999999" - "-268.89999999" - "-299.80000000" - "-214.03850010" - "-170.08900000" - "-159.00000000" - "-5.38250000" - "-249.53200030" mostPro fi tableTrade: "11586.99999990" mostLossTrade: "-299.80000000" pro fi tFactor: "8.58256853" totalNetPro fi t: "26655.90549887"
have many parameters for di ff erent scenarios. • It’s hard to try the parameters one by one. • There are too many combinations. • The optimizer helps you fi nd the best combination. • BBGO uses JSON patch syntax to de fi ne the optimization. • You can optimize ANYTHING de fi ned in the con fi g fi le.