realign account fields

This commit is contained in:
c9s 2021-12-05 12:23:27 +08:00
parent 44d7055809
commit f692ef2c31
4 changed files with 15 additions and 9 deletions

View File

@ -90,8 +90,8 @@ func NewExchange(sourceName types.ExchangeName, srv *service.BacktestService, co
}
account := &types.Account{
MakerCommission: config.Account.MakerCommission,
TakerCommission: config.Account.TakerCommission,
MakerFeeRate: config.Account.MakerFeeRate,
TakerFeeRate: config.Account.TakerFeeRate,
AccountType: "SPOT", // currently not used
}

View File

@ -23,8 +23,8 @@ func newLimitOrder(symbol string, side types.SideType, price, quantity float64)
func TestSimplePriceMatching_LimitOrder(t *testing.T) {
account := &types.Account{
MakerCommission: 15,
TakerCommission: 15,
MakerFeeRate: fixedpoint.NewFromFloat(0.075 * 0.01),
TakerFeeRate: fixedpoint.NewFromFloat(0.075 * 0.01),
}
account.UpdateBalances(types.BalanceMap{

View File

@ -119,6 +119,10 @@ func (t Backtest) ParseStartTime() (time.Time, error) {
}
type BacktestAccount struct {
// TODO: MakerFeeRate should replace the commission fields
MakerFeeRate fixedpoint.Value `json:"makerFeeRate"`
TakerFeeRate fixedpoint.Value `json:"takerFeeRate"`
MakerCommission fixedpoint.Value `json:"makerCommission"`
TakerCommission fixedpoint.Value `json:"takerCommission"`
BuyerCommission int `json:"buyerCommission"`

View File

@ -2,13 +2,14 @@ package types
import (
"fmt"
"github.com/slack-go/slack"
"math"
"sort"
"strings"
"sync"
"time"
"github.com/slack-go/slack"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
@ -183,13 +184,14 @@ func (m BalanceMap) Print() {
type Account struct {
sync.Mutex `json:"-"`
// bps. 0.15% fee will be 15.
MakerCommission fixedpoint.Value `json:"makerCommission,omitempty"`
TakerCommission fixedpoint.Value `json:"takerCommission,omitempty"`
AccountType string `json:"accountType,omitempty"`
MakerFeeRate fixedpoint.Value `json:"makerFeeRate,omitempty"`
TakerFeeRate fixedpoint.Value `json:"takerFeeRate,omitempty"`
AccountType string `json:"accountType,omitempty"`
// bps. 0.15% fee will be 15.
MakerCommission fixedpoint.Value `json:"makerCommission,omitempty"`
TakerCommission fixedpoint.Value `json:"takerCommission,omitempty"`
TotalAccountValue fixedpoint.Value `json:"totalAccountValue,omitempty"`