sixth version
This commit is contained in:
@@ -507,9 +507,12 @@ func (e *Engine) repostDue(order domain.Order, after time.Duration) bool {
|
||||
}
|
||||
|
||||
func (e *Engine) ensureRepostBudget(ctx context.Context, order domain.Order, instrument domain.Instrument) error {
|
||||
if e.store == nil || instrument.FreeOrderLimitPerDay <= 0 {
|
||||
if e.store == nil || instrument.FreeOrderLimitPerDay < 0 {
|
||||
return nil
|
||||
}
|
||||
if instrument.FreeOrderLimitPerDay == 0 {
|
||||
return risk.ErrFreeOrderPolicyUnspecified
|
||||
}
|
||||
sent, err := e.store.GetFreeOrdersSent(ctx, order.TradeDate, instrument.InstrumentUID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -249,9 +249,10 @@ func TestMonitorUntilRepostsAndExpiresAtDeadline(t *testing.T) {
|
||||
gateway := tinvest.NewFakeGateway()
|
||||
engine := NewEngine(domain.ModeSandbox, "account", gateway, repo)
|
||||
instrument := domain.Instrument{
|
||||
InstrumentUID: "uid",
|
||||
Lot: 1,
|
||||
MinPriceIncrement: decimal.NewFromInt(1),
|
||||
InstrumentUID: "uid",
|
||||
Lot: 1,
|
||||
MinPriceIncrement: decimal.NewFromInt(1),
|
||||
FreeOrderLimitPerDay: -1,
|
||||
}
|
||||
book := domain.OrderBook{
|
||||
InstrumentUID: "uid",
|
||||
@@ -300,9 +301,10 @@ func TestMonitorOnceDoesNotRepostWhenCheckRejects(t *testing.T) {
|
||||
gateway := tinvest.NewFakeGateway()
|
||||
engine := NewEngine(domain.ModeSandbox, "account", gateway, repo)
|
||||
instrument := domain.Instrument{
|
||||
InstrumentUID: "uid",
|
||||
Lot: 1,
|
||||
MinPriceIncrement: decimal.NewFromInt(1),
|
||||
InstrumentUID: "uid",
|
||||
Lot: 1,
|
||||
MinPriceIncrement: decimal.NewFromInt(1),
|
||||
FreeOrderLimitPerDay: -1,
|
||||
}
|
||||
book := domain.OrderBook{
|
||||
InstrumentUID: "uid",
|
||||
|
||||
Reference in New Issue
Block a user