/
sys_trading_crypto_pair_setup.go
85 lines (71 loc) · 2.72 KB
/
sys_trading_crypto_pair_setup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package models
import (
"net/http"
"github.com/jinzhu/gorm"
"github.com/yapkah/go-api/pkg/e"
)
// SysTradingCryptoPairSetup struct
type SysTradingCryptoPairSetup struct {
ID int `gorm:"primary_key" json:"id"`
Code string `json:"code"`
Name string `json:"name"`
Status string `json:"status"`
// Spot Grid Trading
// GridQuantity int `json:"grid_quantity"` // removed since 5th april 2022 and is calculated instead
TakerRate float64 `json:"taker_rate"`
// Martingale Trading
// FirstOrderPrice float64 `json:"first_order_price"`
PriceScale float64 `json:"price_scale"`
// SubsequentPriceScale int `json:"subsequent_price_scale"` // removed since 5th april 2022
TakeProfitRatio float64 `json:"take_profit_ratio"`
TakeProfitAdjustment float64 `json:"take_profit_adjustment"`
// SafetyOrders int `json:"safety_orders"` // removed since 5th april 2022 and is calculated instead
AddShares int `json:"add_shares"`
// SubsequentAddShares int `json:"subsequent_add_shares"` // removed since 5th april 2022
CircularTrans int `json:"circular_trans"`
MtdPriceScale float64 `json:"mtd_price_scale"`
MtdTakeProfitRatio float64 `json:"mtd_take_profit_ratio"`
MtdTakeProfitAdjustment float64 `json:"mtd_take_profit_adjustment"`
MtdAddShares float64 `json:"mtd_add_shares"`
MtdCircularTrans int `json:"mtd_circular_trans"`
}
// GetSysTradingCryptoPairSetupFn
func GetSysTradingCryptoPairSetupFn(arrCond []WhereCondFn, selectColumn string, debug bool) ([]*SysTradingCryptoPairSetup, error) {
var result []*SysTradingCryptoPairSetup
tx := db.Table("sys_trading_crypto_pair_setup")
if len(arrCond) > 0 {
for _, v := range arrCond {
tx = tx.Where(v.Condition, v.CondValue)
}
}
if debug {
tx = tx.Debug()
}
err := tx.Find(&result).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, &e.CustomError{HTTPCode: http.StatusInternalServerError, Code: e.ERROR, Msg: err.Error(), Data: err}
}
return result, nil
}
// GetSysTradingCryptoPairSetupByPlatformFn
func GetSysTradingCryptoPairSetupByPlatformFn(arrCond []WhereCondFn, selectColumn, platform string, debug bool) ([]*SysTradingCryptoPairSetup, error) {
var result []*SysTradingCryptoPairSetup
var table = "sys_trading_crypto_pair_setup"
if platform == "KC" {
table = "sys_trading_crypto_pair_setup_kc"
}
tx := db.Table(table)
if len(arrCond) > 0 {
for _, v := range arrCond {
tx = tx.Where(v.Condition, v.CondValue)
}
}
if debug {
tx = tx.Debug()
}
err := tx.Find(&result).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, &e.CustomError{HTTPCode: http.StatusInternalServerError, Code: e.ERROR, Msg: err.Error(), Data: err}
}
return result, nil
}