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{ account := &types.Account{
MakerCommission: config.Account.MakerCommission, MakerFeeRate: config.Account.MakerFeeRate,
TakerCommission: config.Account.TakerCommission, TakerFeeRate: config.Account.TakerFeeRate,
AccountType: "SPOT", // currently not used 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) { func TestSimplePriceMatching_LimitOrder(t *testing.T) {
account := &types.Account{ account := &types.Account{
MakerCommission: 15, MakerFeeRate: fixedpoint.NewFromFloat(0.075 * 0.01),
TakerCommission: 15, TakerFeeRate: fixedpoint.NewFromFloat(0.075 * 0.01),
} }
account.UpdateBalances(types.BalanceMap{ account.UpdateBalances(types.BalanceMap{

View File

@ -119,6 +119,10 @@ func (t Backtest) ParseStartTime() (time.Time, error) {
} }
type BacktestAccount struct { 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"` MakerCommission fixedpoint.Value `json:"makerCommission"`
TakerCommission fixedpoint.Value `json:"takerCommission"` TakerCommission fixedpoint.Value `json:"takerCommission"`
BuyerCommission int `json:"buyerCommission"` BuyerCommission int `json:"buyerCommission"`

View File

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