try to keep all orders from order store

This commit is contained in:
c9s 2020-11-17 15:53:46 +08:00
parent c40982164a
commit 914d5cdc94
2 changed files with 8 additions and 48 deletions

View File

@ -10,6 +10,8 @@ type OrderStore struct {
// any created orders for tracking trades
mu sync.Mutex
orders map[uint64]types.Order
RemoveCancelled bool
}
func NewOrderStore() *OrderStore {
@ -62,7 +64,12 @@ func (s *OrderStore) handleOrderUpdate(order types.Order) {
case types.OrderStatusPartiallyFilled, types.OrderStatusNew, types.OrderStatusFilled:
s.Update(order)
case types.OrderStatusCanceled, types.OrderStatusRejected:
case types.OrderStatusCanceled:
if s.RemoveCancelled {
s.Remove(order)
}
case types.OrderStatusRejected:
s.Remove(order)
}
}

View File

@ -69,51 +69,4 @@ func (m Market) CanonicalizeVolume(val float64) float64 {
return math.Trunc(p*val) / p
}
var MarketBTCUSDT = Market{
Symbol: "BTCUSDT",
BaseCurrency: "BTC",
QuoteCurrency: "USDT",
PricePrecision: 2,
VolumePrecision: 6,
MinQuantity: 0.000001,
MinLot: 0.000001,
MinAmount: 10.0,
MinNotional: 10.0,
}
var MarketETHUSDT = Market{
Symbol: "ETHUSDT",
BaseCurrency: "ETH",
QuoteCurrency: "USDT",
PricePrecision: 2,
VolumePrecision: 5,
MinQuantity: 0.01,
MinLot: 0.01,
MinAmount: 10.0,
MinNotional: 10.0,
}
var MarketBNBUSDT = Market{
Symbol: "BNBUSDT",
BaseCurrency: "BNB",
QuoteCurrency: "USDT",
PricePrecision: 4,
VolumePrecision: 2,
MinQuantity: 0.01,
MinLot: 0.01,
MinAmount: 10.0,
MinNotional: 10.0,
}
type MarketMap map[string]Market
var Markets = map[string]Market{
"ETHUSDT": MarketETHUSDT,
"BNBUSDT": MarketBNBUSDT,
"BTCUSDT": MarketBTCUSDT,
}
func FindMarket(symbol string) (m Market, ok bool) {
m, ok = Markets[symbol]
return m, ok
}