Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5db68f7
move limits, transition to key gen
gloriousCode Mar 24, 2025
b2e4ca8
rollout NewExchangePairAssetKey everywhere
gloriousCode Mar 24, 2025
1c80e21
test improvements
gloriousCode Mar 25, 2025
16b07c9
self-review fixes
gloriousCode Mar 25, 2025
6cc6f8e
ok, lets go
gloriousCode Mar 25, 2025
1956680
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode Apr 9, 2025
4032269
fix merge issue
gloriousCode Apr 9, 2025
8c29378
slower value func,assertify,drop IsValidPairString
gloriousCode Apr 9, 2025
8284c16
remove binance reference for backtesting test
gloriousCode Apr 9, 2025
611d108
Redundant nil checks removed due to redundancy
gloriousCode Apr 10, 2025
8776a14
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode Apr 10, 2025
61df1de
Update order_test.go
gloriousCode Apr 11, 2025
b8cb0c5
Move limits back into /exchanges/
gloriousCode Apr 11, 2025
41fb91a
puts limits in a different box again
gloriousCode Apr 11, 2025
91eac9c
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode Apr 14, 2025
63f2d80
SHAZBERT SPECIAL SUGGESTIONS
gloriousCode Apr 16, 2025
df2ebd1
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode May 1, 2025
5e81663
Update gateio_wrapper.go
gloriousCode May 1, 2025
71ef90a
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode Aug 11, 2025
fd363c9
fixes all build issues
gloriousCode Aug 11, 2025
0e2419b
Many niteroos!
gloriousCode Aug 12, 2025
b09a4e3
something has gone awry
gloriousCode Aug 13, 2025
9d1555a
bugfix
gloriousCode Aug 14, 2025
6c8f8cf
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode Aug 14, 2025
79e098d
gk's everywhere nits
gloriousCode Aug 14, 2025
6164f04
lint
gloriousCode Aug 14, 2025
b6ef0bc
extra lint
gloriousCode Aug 14, 2025
4ff18da
re-remove IsValidPairString
gloriousCode Aug 14, 2025
a8e2666
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode Aug 20, 2025
6026d3a
lint fix
gloriousCode Aug 20, 2025
78bb38e
standardise test
gloriousCode Aug 21, 2025
0f80072
revert some bads
gloriousCode Aug 21, 2025
ba97389
dupe rm
gloriousCode Aug 21, 2025
1e22be1
another revert 360 mcgee
gloriousCode Aug 21, 2025
08e8d02
un-in-revertify
gloriousCode Aug 21, 2025
1509f49
Update exchange/order/limits/levels_test.go
gloriousCode Aug 21, 2025
f52ce47
fix
gloriousCode Aug 21, 2025
86e7d97
Update exchanges/binance/binance_test.go
gloriousCode Aug 22, 2025
422b403
update text
gloriousCode Aug 25, 2025
4246525
Merge remote-tracking branch 'upstream' into at-my-limit
gloriousCode Aug 26, 2025
3b8b178
rn func, same line err gk4202000
gloriousCode Aug 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backtester/engine/grpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func StartRPCServer(server *GRPCServer) error {
return err
}
log.Debugf(log.GRPCSys, "Backtester GRPC server enabled. Starting GRPC server on https://%v.\n", server.config.GRPC.ListenAddress)

lis, err := net.Listen("tcp", server.config.GRPC.ListenAddress)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions backtester/eventhandlers/exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func (e *Exchange) ExecuteOrder(o order.Event, dh data.Handler, om *engine.Order
}

if cs.CanUseExchangeLimits || cs.UseRealOrders {
// Conforms the amount to the exchange order defined step amount
// Validate the amount to the exchange order defined step amount
// reducing it when needed
adjustedAmount = cs.Limits.ConformToDecimalAmount(amount)
adjustedAmount = cs.Limits.FloorAmountToStepIncrementDecimal(amount)
if !adjustedAmount.Equal(amount) && !adjustedAmount.IsZero() {
f.AppendReasonf("Order size shrunk from %v to %v to remain within exchange step amount limits",
amount,
Expand Down
3 changes: 2 additions & 1 deletion cmd/exchange_template/exchange_template.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"errors"
"flag"
"fmt"
Expand Down Expand Up @@ -241,7 +242,7 @@ func saveConfig(exchangeDirectory string, configTestFile *config.Config, newExch
}

func runCommand(dir, param string) error {
cmd := exec.Command("go", param)
cmd := exec.CommandContext(context.TODO(), "go", param)
cmd.Dir = dir
out, err := cmd.CombinedOutput()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ var acceptableErrors = []error{
futures.ErrNotPerpetualFuture, // Is thrown when a futures function receives a non-perpetual future
limits.ErrExchangeLimitNotLoaded, // Is thrown when the limits aren't loaded for a particular exchange, asset, pair
limits.ErrOrderLimitNotFound, // Is thrown when the order limit isn't found for a particular exchange, asset, pair
limits.ErrCannotLoadLimit, // Is thrown if limits are not provided for the asset
limits.ErrEmptyLevels, // Is thrown if limits are not provided for the asset
account.ErrExchangeHoldingsNotFound,
ticker.ErrTickerNotFound,
orderbook.ErrOrderbookNotFound,
Expand Down
4 changes: 2 additions & 2 deletions cmd/gctcli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var (
func clearScreen() error {
switch runtime.GOOS {
case "windows":
cmd := exec.Command("cmd", "/c", "cls")
cmd := exec.CommandContext(context.TODO(), "cmd", "/c", "cls")
cmd.Stdout = os.Stdout
return cmd.Run()
default:
cmd := exec.Command("clear")
cmd := exec.CommandContext(context.TODO(), "clear")
cmd.Stdout = os.Stdout
return cmd.Run()
}
Expand Down
5 changes: 3 additions & 2 deletions database/database.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package database

import (
"context"
"database/sql"
"fmt"
"time"
Expand Down Expand Up @@ -46,7 +47,7 @@ func (i *Instance) SetPostgresConnection(con *sql.DB) error {
if con == nil {
return errNilSQL
}
if err := con.Ping(); err != nil {
if err := con.PingContext(context.TODO()); err != nil {
return fmt.Errorf("%w %s", errFailedPing, err)
}
i.m.Lock()
Expand Down Expand Up @@ -117,7 +118,7 @@ func (i *Instance) Ping() error {
if i.SQL == nil {
return errNilSQL
}
return i.SQL.Ping()
return i.SQL.PingContext(context.TODO())
}

// GetSQL returns the sql connection
Expand Down
7 changes: 4 additions & 3 deletions database/models/postgres/psql_main_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 27 additions & 30 deletions exchange/order/limits/levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
)

// Conforms checks outbound parameters
func (m *MinMaxLevel) Conforms(price, amount float64, orderType order.Type) error {
// TODO: Update to take in account Quote amounts as well as Base amounts.
// Validate ensures MinMaxLevel fields are valid
func (m *MinMaxLevel) Validate(price, amount float64, orderType order.Type) error {
// TODO: Verify Quote as well as Base amounts
if m == nil {
return nil
}
Expand Down Expand Up @@ -37,23 +37,25 @@ func (m *MinMaxLevel) Conforms(price, amount float64, orderType order.Type) erro
}
}

// ContractMultiplier checking not done due to the fact we need coherence with the
// last average price (TODO)
// m.multiplierUp will be used to determine how far our price can go up
// m.multiplierDown will be used to determine how far our price can go down
// m.averagePriceMinutes will be used to determine mean over this period
/*
ContractMultiplier checking not done due to the fact we need coherence with the
last average price (TODO)
m.multiplierUp will be used to determine how far our price can go up
m.multiplierDown will be used to determine how far our price can go down
m.averagePriceMinutes will be used to determine mean over this period

// Max iceberg parts checking not done as we do not have that
// functionality yet (TODO)
// m.maxIcebergParts // How many components in an iceberg order
Max iceberg parts checking not done as we do not have that
functionality yet (TODO)
m.maxIcebergParts // How many components in an iceberg order

// Max total orders not done due to order manager limitations (TODO)
// m.maxTotalOrders
Max total orders not done due to order manager limitations (TODO)
m.maxTotalOrders

// Max algo orders not done due to order manager limitations (TODO)
// m.maxAlgoOrders
Max algo orders not done due to order manager limitations (TODO)
m.maxAlgoOrders

// If order type is Market we do not need to do price checks
If order type is Market we do not need to do price checks
*/
if orderType != order.Market {
if m.MinPrice != 0 && price < m.MinPrice {
return fmt.Errorf("%w min: %.8f supplied %.8f",
Expand Down Expand Up @@ -87,24 +89,19 @@ func (m *MinMaxLevel) Conforms(price, amount float64, orderType order.Type) erro
return nil
}

if m.MarketMinQty != 0 &&
m.MinimumBaseAmount < m.MarketMinQty &&
amount < m.MarketMinQty {
if m.MarketMinQty != 0 && m.MinimumBaseAmount < m.MarketMinQty && amount < m.MarketMinQty {
return fmt.Errorf("%w min: %.8f supplied %.8f",
ErrMarketAmountBelowMin,
m.MarketMinQty,
amount)
}
if m.MarketMaxQty != 0 &&
m.MaximumBaseAmount > m.MarketMaxQty &&
amount > m.MarketMaxQty {
if m.MarketMaxQty != 0 && m.MaximumBaseAmount > m.MarketMaxQty && amount > m.MarketMaxQty {
return fmt.Errorf("%w max: %.8f supplied %.8f",
ErrMarketAmountExceedsMax,
m.MarketMaxQty,
amount)
}
if m.MarketStepIncrementSize != 0 &&
m.AmountStepIncrementSize != m.MarketStepIncrementSize {
if m.MarketStepIncrementSize != 0 && m.AmountStepIncrementSize != m.MarketStepIncrementSize {
dAmount := decimal.NewFromFloat(amount)
dMinMAmount := decimal.NewFromFloat(m.MarketMinQty)
dStep := decimal.NewFromFloat(m.MarketStepIncrementSize)
Expand All @@ -118,8 +115,8 @@ func (m *MinMaxLevel) Conforms(price, amount float64, orderType order.Type) erro
return nil
}

// ConformToDecimalAmount (POC) conforms amount to its amount interval
func (m *MinMaxLevel) ConformToDecimalAmount(amount decimal.Decimal) decimal.Decimal {
// FloorAmountToStepIncrementDecimal floors decimal amount to step increment
func (m *MinMaxLevel) FloorAmountToStepIncrementDecimal(amount decimal.Decimal) decimal.Decimal {
if m == nil {
return amount
}
Expand All @@ -137,8 +134,8 @@ func (m *MinMaxLevel) ConformToDecimalAmount(amount decimal.Decimal) decimal.Dec
return amount.Sub(mod)
}

// ConformToAmount (POC) conforms amount to its amount interval
func (m *MinMaxLevel) ConformToAmount(amount float64) float64 {
// FloorAmountToStepIncrement floors float amount to step increment
func (m *MinMaxLevel) FloorAmountToStepIncrement(amount float64) float64 {
if m == nil {
return amount
}
Expand All @@ -158,8 +155,8 @@ func (m *MinMaxLevel) ConformToAmount(amount float64) float64 {
return dAmount.Sub(mod).InexactFloat64()
}

// ConformToPrice (POC) conforms amount to its amount interval
func (m *MinMaxLevel) ConformToPrice(price float64) float64 {
// FloorPriceToStepIncrement floors float price to step increment
func (m *MinMaxLevel) FloorPriceToStepIncrement(price float64) float64 {
if m == nil {
return price
}
Expand Down
Loading
Loading