Skip to content

Instantly share code, notes, and snippets.

View gloriousCode's full-sized avatar
🌮
Hello, my name is Scott

Scott gloriousCode

🌮
Hello, my name is Scott
View GitHub Profile
func TestWsDepthUpdate(t *testing.T) {
seedLastUpdateID := int64(161)
book := OrderBook{
Asks: []OrderbookItem{
{Price: 6621.80000000, Quantity: 0.00198100},
{Price: 6622.14000000, Quantity: 4.00000000},
{Price: 6622.46000000, Quantity: 2.30000000},
{Price: 6622.47000000, Quantity: 1.18633300},
{Price: 6622.64000000, Quantity: 4.00000000},
{Price: 6622.73000000, Quantity: 0.02900000},
module main
go 1.14
replace github.com/thrasher-corp/gocryptotrader => ./../../gocryptotrader
require github.com/thrasher-corp/gocryptotrader v0.0.0-00010101000000-000000000000
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func randSeq(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}
// the following response is in this loop 9 times:
// { "Timestamp": "2020-07-01T04:42:24.982288Z", "TID": "57923392", "Price": 0.08329, "Amount": 1000, "Exchange": "FTX", "Type": "", "Side": "buy", "Fee": 0, "Description": "" }
// raw response:
[ [ { "Timestamp": "2020-07-01T04:43:26.086596Z", "TID": "57923864", "Price": 0.08329, "Amount": 1, "Exchange": "FTX", "Type": "", "Side": "buy", "Fee": 0, "Description": "" }, { "Timestamp": "2020-07-01T04:43:23.500016Z", "TID": "57923852", "Price": 0.08329, "Amount": 1, "Exchange": "FTX", "Type": "", "Side": "buy", "Fee": 0, "Description": "" }, { "Timestamp": "2020-07-01T04:43:21.470694Z", "TID": "57923846", "Price": 0.08329, "Amount": 2, "Exchange": "FTX", "Type": "", "Side": "buy", "Fee": 0, "Description": "" }, { "Timestamp": "2020-07-01T04:43:19.449064Z", "TID": "57923842", "Price": 0.08329, "Amount": 4, "Exchange": "FTX", "Type": "", "Side": "buy", "Fee": 0, "Description": "" }, { "Timestamp": "2020-07-01T04:43:17.342063Z", "TID": "57923825", "Price": 0.0832
// AddSubscription appends a successful subscription
func (w *Websocket) AddSubscription(cs ...ChannelSubscription) {
w.subscriptions = append(w.subscriptions, cs...)
}
// Demos how it can be handled when only one request sent
func (b *Bitmex) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error {
var subscriber WebsocketRequest
subscriber.Command = "subscribe"
func TestTheThing1(t *testing.T) {
var err error
Bot, err = New()
if err != nil {
t.Fatalf("Failed to initialise engine. Err: %s", err)
}
Bot.Settings = Settings{
DisableExchangeAutoPairUpdates: true,
// uses existing sqlite db in .gocryptotrader/database directory
func TestCandleSaving(t *testing.T) {
var err error
Bot, err = New()
if err != nil {
t.Fatalf("Failed to initialise engine. Err: %s", err)
}
Bot.Settings = Settings{
DisableExchangeAutoPairUpdates: true,
EnableExchangeHTTPRateLimiter: true,
func Setup() *Engine {
engerino := new(Engine)
engerino.Config = &config.Cfg
err := engerino.Config.LoadConfig(config.TestFile, true)
if err != nil {
}
exch := engerino.GetExchangeByName(testExchange)
if exch == nil {
err = engerino.LoadExchange(testExchange, false, nil)
if err != nil {
func ReturnErr() error {
return errors.New("hello")
}
func DeferErr() error {
return errors.New("deferred")
}
func HandleErrs() error {
@gloriousCode
gloriousCode / changes.go
Created September 3, 2021 01:32
changes
diff --git a/engine/order_manager.go b/engine/order_manager.go
index 859e32b3c..b00df09a7 100644
--- a/engine/order_manager.go
+++ b/engine/order_manager.go
@@ -240,8 +240,8 @@ func (m *OrderManager) GetOrderInfo(exchangeName, orderID string, cp currency.Pa
return order.Detail{}, err
}
- err = m.orderStore.upsert(&result)
- if err != nil && err != ErrOrdersAlreadyExists {