Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the output of the performance analysis asnychronous? #14

Open
seongs1024 opened this issue Jan 1, 2023 · 2 comments
Open

Is the output of the performance analysis asnychronous? #14

seongs1024 opened this issue Jan 1, 2023 · 2 comments

Comments

@seongs1024
Copy link

I got bad formatted output, when I ran the example with BTCUSDTPERP data (about 1000 ticks).
It seems that printing the performance analysis and system event logs is executed asynchronously.

# snipped...
PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T21:14:59.999Z, current_symbol_price: 16306.0, current_value_gross: 97.836, unrealised_profit_loss: -30.915479999999995 }
PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T21:29:59.999Z, current_symbol_price: 16338.0, current_value_gross: 98.028, unrealised_profit_loss: -30.723479999999988 }
                PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T21:44:59.999Z, current_symbol_price: 16374.4, current_value_gross: 98.2464, unrealised_profit_loss: -30.50508 }
PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T21:59:59.999Z, current_symbol_price: 16396.6, current_value_gross: 98.3796, unrealised_profit_loss: -30.371879999999997 }
 | PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T22:14:59.999Z, current_symbol_price: 16404.2, current_value_gross: 98.4252, unrealised_profit_loss: -30.32627999999999 }
0.000        PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T22:29:59.999Z, current_symbol_price: 16393.4, current_value_gross: 98.36040000000001, unrealised_profit_loss: -30.39107999999998 }
 | PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T22:44:59.999Z, current_symbol_price: 16356.0, current_value_gross: 98.136, unrealised_profit_loss: -30.615479999999998 }
0                 PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T22:59:59.999Z, current_symbol_price: 16398.0, current_value_gross: 98.388, unrealised_profit_loss: -30.36347999999999 }
Signal { time: 2023-01-01T14:32:05.173112179Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, signals: {CloseLong: SignalStrength(1.0), Short: SignalStrength(1.0)}, market_meta: MarketMeta { close: 16549.2, time: 2022-11-14T23:14:59.999Z } }
PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T23:14:59.999Z, current_symbol_price: 16549.2, current_value_gross: 99.29520000000001, unrealised_profit_loss: -29.456279999999985 }
OrderEvent { time: 2023-01-01T14:32:05.173124573Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, market_meta: MarketMeta { close: 16549.2, time: 2022-11-14T23:14:59.999Z }, decision: CloseLong, quantity: -0.006, order_type: Market }
FillEvent { time: 2023-01-01T14:32:05.173127616Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, market_meta: MarketMeta { close: 16549.2, time: 2022-11-14T23:14:59.999Z }, decision: CloseLong, quantity: -0.006, fill_value_gross: 99.29520000000001, fees: Fees { exchange: 9.929520000000002, slippage: 4.964760000000001, network: 0.0 } }
PositionExit { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", exit_time: 2023-01-01T14:32:05.173127616Z, exit_balance: Balance { time: 2023-01-01T14:32:05.173127616Z, total: 8754.7218585, available: 8670.3209385 }, exit_fees: Fees { exchange: 9.929520000000002, slippage: 4.964760000000001, network: 0.0 }, exit_fees_total: 14.894280000000002, exit_avg_price_gross: 16549.2, exit_value_gross: 99.29520000000001, realised_profit_loss: -29.494619999999987 }
Balance { time: 2023-01-01T14:32:05.173127616Z, total: 8754.7218585, available: 8754.7218585 }
Signal { time: 2023-01-01T14:32:05.173154442Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, signals: {Short: SignalStrength(1.0), CloseLong: SignalStrength(1.0)}, market_meta: MarketMeta { close: 16634.6, time: 2022-11-14T23:29:59.999Z } }
OrderEvent { time: 2023-01-01T14:32:05.173164310Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, market_meta: MarketMeta { close: 16634.6, time: 2022-11-14T23:29:59.999Z }, decision: Short, quantity: -0.006, order_type: Market }
FillEvent { time: 2023-01-01T14:32:05.173167174Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, market_meta: MarketMeta { close: 16634.6, time: 2022-11-14T23:29:59.999Z }, decision: Short, quantity: -0.006, fill_value_gross: 99.8076, fees: Fees { exchange: 9.98076, slippage: 4.99038, network: 0.0 } }
 Position { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", meta: PositionMeta { enter_time: 2022-11-14T23:29:59.999Z, update_time: 2023-01-01T14:32:05.173167174Z, exit_balance: None }, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, side: Sell, quantity: -0.006, enter_fees: Fees { exchange: 9.98076, slippage: 4.99038, network: 0.0 }, enter_fees_total: 14.97114, enter_avg_price_gross: 16634.6, enter_value_gross: 99.8076, exit_fees: Fees { exchange: 0.0, slippage: 0.0, network: 0.0 }, exit_fees_total: 0.0, exit_avg_price_gross: 0.0, exit_value_gross: 0.0, current_symbol_price: 16634.6, current_value_gross: 99.8076, unrealised_profit_loss: -29.94228, realised_profit_loss: 0.0 }
Balance { time: 2023-01-01T14:32:05.173167174Z, total: 8754.7218585, available: 8639.9431185 }
Signal { time: 2023-01-01T14:32:05.173184671Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, signals: {CloseLong: SignalStrength(1.0), Short: SignalStrength(1.0)}, market_meta: MarketMeta { close: 16692.1, time: 2022-11-14T23:44:59.999Z } }
PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T23:44:59.999Z, current_symbol_price: 16692.1, current_value_gross: 100.15259999999999, unrealised_profit_loss: -30.28728 }
Signal { time: 2023-01-01T14:32:05.173202045Z, exchange: binance, instrument: Instrument { base: btc, quote: usdt, kind: Spot }, signals: {CloseLong: SignalStrength(1.0), Short: SignalStrength(1.0)}, market_meta: MarketMeta { close: 16605.2, time: 2022-11-14T23:59:59.999Z } }
PositionUpdate { position_id: "255385be-bc70-4f3d-bdb6-186049dd7900_binance_(btc_usdt, spot)_position", update_time: 2022-11-14T23:59:59.999Z, current_symbol_price: 16605.2, current_value_gross: 99.6312, unrealised_profit_loss: -29.765880000000013 }
|
+-----------------------+--------+------+--------+--------------+----------------+-------------+------------------+------------------+-------------+--------------+--------------+---------------+--------------+--------------+-------------------+---------------+--------------------+
@just-a-stream
Copy link
Contributor

Hey @seongs1024! Sorry just seen this :)

The events that you've printed out would be appropriately sequenced per Trader.

The printing of the prettytable performance analysis should happen after all Traders have stopped.

@seongs1024
Copy link
Author

seongs1024 commented Jan 19, 2023

Can you test the example backtest with this data?

btcusdt-15m-2020-01-01-2022-11-15.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants