mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
backtest: check quoteQuantity only when price is given
This commit is contained in:
parent
adc2216e1f
commit
f06ec76618
|
@ -43,6 +43,8 @@ const parseOrder = () => {
|
|||
case "quantity":
|
||||
d[key] = +d[key];
|
||||
break;
|
||||
case "update_time":
|
||||
case "creation_time":
|
||||
case "time":
|
||||
d[key] = new Date(d[key]);
|
||||
break;
|
||||
|
@ -150,7 +152,7 @@ const ordersToMarkets = (interval, orders) => {
|
|||
// var markers = [{ time: data[data.length - 48].time, position: 'aboveBar', color: '#f68410', shape: 'circle', text: 'D' }];
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
let order = orders[i];
|
||||
let t = order.time.getTime() / 1000.0;
|
||||
let t = order.update_time.getTime() / 1000.0;
|
||||
let lastMarker = markers.length > 0 ? markers[markers.length - 1] : null;
|
||||
if (lastMarker) {
|
||||
let remainder = lastMarker.time % intervalSecs;
|
||||
|
|
|
@ -31,8 +31,8 @@ backtest:
|
|||
# for testing max draw down (MDD) at 03-12
|
||||
# see here for more details
|
||||
# https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp
|
||||
startTime: "2022-01-10"
|
||||
endTime: "2022-01-11"
|
||||
startTime: "2022-05-09"
|
||||
endTime: "2022-05-20"
|
||||
symbols:
|
||||
- BTCUSDT
|
||||
sessions: [binance]
|
||||
|
@ -53,9 +53,9 @@ exchangeStrategies:
|
|||
# exp:
|
||||
# domain: [20_000, 30_000]
|
||||
# range: [0.2, 0.001]
|
||||
gridNumber: 100
|
||||
gridNumber: 30
|
||||
profitSpread: 1000.0 # The profit price spread that you want to add to your sell order when your buy order is executed
|
||||
upperPrice: 50_000.0
|
||||
lowerPrice: 20_000.0
|
||||
long: true # The sell order is submitted in the same order amount as the filled corresponding buy order, rather than the same quantity.
|
||||
# long: true # The sell order is submitted in the same order amount as the filled corresponding buy order, rather than the same quantity.
|
||||
|
||||
|
|
|
@ -118,9 +118,11 @@ func (m *SimplePriceMatching) PlaceOrder(o types.SubmitOrder) (closedOrders *typ
|
|||
return nil, nil, fmt.Errorf("order quantity %s is less than minQuantity %s, order: %+v", o.Quantity.String(), m.Market.MinQuantity.String(), o)
|
||||
}
|
||||
|
||||
quoteQuantity := o.Quantity.Mul(price)
|
||||
if quoteQuantity.Compare(m.Market.MinNotional) < 0 {
|
||||
return nil, nil, fmt.Errorf("order amount %s is less than minNotional %s, order: %+v", quoteQuantity.String(), m.Market.MinNotional.String(), o)
|
||||
if !price.IsZero() {
|
||||
quoteQuantity := o.Quantity.Mul(price)
|
||||
if quoteQuantity.Compare(m.Market.MinNotional) < 0 {
|
||||
return nil, nil, fmt.Errorf("order amount %s is less than minNotional %s, order: %+v", quoteQuantity.String(), m.Market.MinNotional.String(), o)
|
||||
}
|
||||
}
|
||||
|
||||
switch o.Side {
|
||||
|
|
|
@ -220,26 +220,30 @@ type Order struct {
|
|||
|
||||
func (o Order) CsvHeader() []string {
|
||||
return []string{
|
||||
"time",
|
||||
"order_id",
|
||||
"symbol",
|
||||
"side",
|
||||
"order_type",
|
||||
"status",
|
||||
"price",
|
||||
"quantity",
|
||||
"creation_time",
|
||||
"update_time",
|
||||
}
|
||||
}
|
||||
|
||||
func (o Order) CsvRecords() [][]string {
|
||||
return [][]string{
|
||||
{
|
||||
o.UpdateTime.Time().UTC().Format(time.RFC1123),
|
||||
strconv.FormatUint(o.OrderID, 10),
|
||||
o.Symbol,
|
||||
string(o.Side),
|
||||
string(o.Type),
|
||||
string(o.Status),
|
||||
o.Price.String(),
|
||||
o.Quantity.String(),
|
||||
o.CreationTime.Time().UTC().Format(time.RFC1123),
|
||||
o.UpdateTime.Time().UTC().Format(time.RFC1123),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user