mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #1287 from bailantaotao/edwin/add-bybit-kline-backtest
FEATURE: [bybit] add kline backtest
This commit is contained in:
commit
6f4f1ad558
10
migrations/mysql/20230815173104_add_bybit_klines.sql
Normal file
10
migrations/mysql/20230815173104_add_bybit_klines.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
CREATE TABLE `bybit_klines` LIKE `binance_klines`;
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
|
||||
-- +begin
|
||||
DROP TABLE `bybit_klines`;
|
||||
-- +end
|
29
migrations/sqlite3/20230815173104_add_bybit_klines.sql
Normal file
29
migrations/sqlite3/20230815173104_add_bybit_klines.sql
Normal file
|
@ -0,0 +1,29 @@
|
|||
-- +up
|
||||
-- +begin
|
||||
CREATE TABLE `bybit_klines`
|
||||
(
|
||||
`gid` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`exchange` VARCHAR(10) NOT NULL,
|
||||
`start_time` DATETIME(3) NOT NULL,
|
||||
`end_time` DATETIME(3) NOT NULL,
|
||||
`interval` VARCHAR(3) NOT NULL,
|
||||
`symbol` VARCHAR(7) NOT NULL,
|
||||
`open` DECIMAL(16, 8) NOT NULL,
|
||||
`high` DECIMAL(16, 8) NOT NULL,
|
||||
`low` DECIMAL(16, 8) NOT NULL,
|
||||
`close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,
|
||||
`volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,
|
||||
`closed` BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
`last_trade_id` INT NOT NULL DEFAULT 0,
|
||||
`num_trades` INT NOT NULL DEFAULT 0,
|
||||
`quote_volume` DECIMAL NOT NULL DEFAULT 0.0,
|
||||
`taker_buy_base_volume` DECIMAL NOT NULL DEFAULT 0.0,
|
||||
`taker_buy_quote_volume` DECIMAL NOT NULL DEFAULT 0.0
|
||||
);
|
||||
-- +end
|
||||
|
||||
-- +down
|
||||
|
||||
-- +begin
|
||||
DROP TABLE bybit_klines;
|
||||
-- +end
|
34
pkg/migrations/mysql/20230815173104_add_bybit_klines.go
Normal file
34
pkg/migrations/mysql/20230815173104_add_bybit_klines.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/c9s/rockhopper"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddMigration(upAddBybitKlines, downAddBybitKlines)
|
||||
|
||||
}
|
||||
|
||||
func upAddBybitKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is applied.
|
||||
|
||||
_, err = tx.ExecContext(ctx, "CREATE TABLE `bybit_klines` LIKE `binance_klines`;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func downAddBybitKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is rolled back.
|
||||
|
||||
_, err = tx.ExecContext(ctx, "DROP TABLE `bybit_klines`;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
34
pkg/migrations/sqlite3/20230815173104_add_bybit_klines.go
Normal file
34
pkg/migrations/sqlite3/20230815173104_add_bybit_klines.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package sqlite3
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/c9s/rockhopper"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddMigration(upAddBybitKlines, downAddBybitKlines)
|
||||
|
||||
}
|
||||
|
||||
func upAddBybitKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is applied.
|
||||
|
||||
_, err = tx.ExecContext(ctx, "CREATE TABLE `bybit_klines`\n(\n `gid` INTEGER PRIMARY KEY AUTOINCREMENT,\n `exchange` VARCHAR(10) NOT NULL,\n `start_time` DATETIME(3) NOT NULL,\n `end_time` DATETIME(3) NOT NULL,\n `interval` VARCHAR(3) NOT NULL,\n `symbol` VARCHAR(7) NOT NULL,\n `open` DECIMAL(16, 8) NOT NULL,\n `high` DECIMAL(16, 8) NOT NULL,\n `low` DECIMAL(16, 8) NOT NULL,\n `close` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `volume` DECIMAL(16, 8) NOT NULL DEFAULT 0.0,\n `closed` BOOLEAN NOT NULL DEFAULT TRUE,\n `last_trade_id` INT NOT NULL DEFAULT 0,\n `num_trades` INT NOT NULL DEFAULT 0,\n `quote_volume` DECIMAL NOT NULL DEFAULT 0.0,\n `taker_buy_base_volume` DECIMAL NOT NULL DEFAULT 0.0,\n `taker_buy_quote_volume` DECIMAL NOT NULL DEFAULT 0.0\n);")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func downAddBybitKlines(ctx context.Context, tx rockhopper.SQLExecutor) (err error) {
|
||||
// This code is executed when the migration is rolled back.
|
||||
|
||||
_, err = tx.ExecContext(ctx, "DROP TABLE bybit_klines;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
Loading…
Reference in New Issue
Block a user