1、减仓策略
2、减仓后减仓节点(60%)
This commit is contained in:
@ -25,6 +25,11 @@ const (
|
||||
PreSpotOrderList = "_PreSpotOrderList_:%s" // 待触发的现货订单集合{交易所类型 exchange_type}
|
||||
PreFutOrderList = "_PreFutOrderList_:%s" // 待触发的订单集合 {交易所类型 exchange_type}
|
||||
|
||||
//策略现货订单集合 {交易所类型 exchange_type}
|
||||
StrategySpotOrderList = "strategy_spot_order_list_%s"
|
||||
//策略合约订单集合 {交易所类型 exchange_type}
|
||||
StrategyFutOrderList = "strategy_fut_order_list_%s"
|
||||
|
||||
API_USER = "api_user:%v" // api用户
|
||||
SystemSetting = "system_setting" //系统设置
|
||||
ApiGroup = "api_group:%v" //api用户组 {id}
|
||||
@ -41,6 +46,11 @@ const (
|
||||
SpotTrigger = "spot_trigger_lock:%v_%s" //现货触发 {apiuserid|symbol}
|
||||
FutTrigger = "fut_trigger_lock:%v_%s" //合约触发 {apiuserid|symbol}
|
||||
|
||||
//波段现货触发{apiuserid|symbol}
|
||||
StrategySpotTriggerLock = "strategy_spot_trigger_l:%v_%s"
|
||||
//波段合约触发{apiuserid|symbol}
|
||||
StrategyFutTriggerLock = "strategy_fut_trigger_l:%v_%s"
|
||||
|
||||
SpotCallBack = "spot_callback:%s" //现货回调 {ordersn}
|
||||
FutCallBack = "fut_callback:%s" //合约回调 {ordersn}
|
||||
|
||||
@ -61,6 +71,11 @@ const (
|
||||
SpotPosition = "spot_position:%s:%v:%s_%s"
|
||||
//合约持仓 {exchangeType,apiuserid,symbol,side}
|
||||
FuturePosition = "future_position:%s:%v:%s_%s"
|
||||
|
||||
//现货减仓单减仓策略 {exchangeType}
|
||||
SpotOrderReduceStrategyList = "spot_reduce_strategy_list:%s"
|
||||
//合约减仓单减仓策略 {exchangeType}
|
||||
FutOrderReduceStrategyList = "fut_reduce_strategy_list:%s"
|
||||
//需要清理键值---------END-----------------
|
||||
|
||||
//定时取消限价并下市价锁
|
||||
@ -79,6 +94,12 @@ const (
|
||||
SpotTickerLastPrice = "spot_ticker_last_price:%s:%s"
|
||||
//合约最后成交价 sort set {exchangeType,symbol}
|
||||
FutureTickerLastPrice = "fut_ticker_last_price:%s:%s"
|
||||
|
||||
//允许缓存交易对价格的交易对 list
|
||||
CacheSymbolLastPrice = "cache_symbol_price"
|
||||
|
||||
//减仓策略缓存 {id}
|
||||
ReduceStrategy = "reduce_stragy:%d"
|
||||
)
|
||||
|
||||
// 用户下单
|
||||
|
||||
@ -697,6 +697,22 @@ func (e *RedisHelper) GetRevRangeScoresSortSet(key string) ([]redis.Z, error) {
|
||||
return e.client.ZRevRangeWithScores(e.ctx, key, 0, -1).Result()
|
||||
}
|
||||
|
||||
// 获取最后一条数据
|
||||
func (e *RedisHelper) GetLastSortSet(key string) ([]redis.Z, error) {
|
||||
// 获取最后一个元素及其分数
|
||||
results, err := e.client.ZRevRangeWithScores(e.ctx, key, 0, 0).Result()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get last member: %w", err)
|
||||
}
|
||||
|
||||
// 如果没有数据,返回空
|
||||
if len(results) == 0 {
|
||||
return []redis.Z{}, nil
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// 获取指定区间数据
|
||||
func (e *RedisHelper) GetSortSetMembers(key string, start, stop int64) ([]string, error) {
|
||||
return e.client.ZRange(e.ctx, key, start, stop).Result()
|
||||
|
||||
Reference in New Issue
Block a user