assign base/quote currency to the position struct

This commit is contained in:
c9s 2021-01-20 23:08:57 +08:00
parent 8a08c406c3
commit 16aa070120
2 changed files with 14 additions and 2 deletions

View File

@ -190,7 +190,16 @@ func (environ *Environment) Init(ctx context.Context) (err error) {
// trade sync and market data store depends on subscribed symbols so we have to do this here.
for symbol := range session.loadedSymbols {
position := &Position{Symbol: symbol}
market, ok := markets[symbol]
if !ok {
return fmt.Errorf("market %s is not defined", symbol)
}
position := &Position{
Symbol: symbol,
BaseCurrency: market.BaseCurrency,
QuoteCurrency: market.QuoteCurrency,
}
var trades []types.Trade

View File

@ -6,7 +6,10 @@ import (
)
type Position struct {
Symbol string `json:"symbol"`
Symbol string `json:"symbol"`
BaseCurrency string `json:"baseCurrency"`
QuoteCurrency string `json:"quoteCurrency"`
Base fixedpoint.Value `json:"base"`
Quote fixedpoint.Value `json:"quote"`
AverageCost fixedpoint.Value `json:"averageCost"`