mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
max: parse debt
This commit is contained in:
parent
2ffbb2ed82
commit
459d839c1a
|
@ -218,9 +218,32 @@ func parseADRatio(v *fastjson.Value) (*ADRatio, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
adRatio := ADRatio{}
|
|
||||||
|
adRatio := struct {
|
||||||
|
ADRatio ADRatio `json:"ad"`
|
||||||
|
}{}
|
||||||
err = json.Unmarshal(o, &adRatio)
|
err = json.Unmarshal(o, &adRatio)
|
||||||
return &adRatio, err
|
return &adRatio.ADRatio, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type Debt struct {
|
||||||
|
Currency string `json:"cu"`
|
||||||
|
DebtPrincipal fixedpoint.Value `json:"dbp"`
|
||||||
|
DebtInterest fixedpoint.Value `json:"dbi"`
|
||||||
|
TU types.MillisecondTimestamp `json:"TU"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseDebts(v *fastjson.Value) ([]Debt, error) {
|
||||||
|
o, err := v.StringBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := struct {
|
||||||
|
Debts []Debt `json:"db"`
|
||||||
|
}{}
|
||||||
|
err = json.Unmarshal(o, &m)
|
||||||
|
return m.Debts, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseUserEvent(v *fastjson.Value) (interface{}, error) {
|
func ParseUserEvent(v *fastjson.Value) (interface{}, error) {
|
||||||
|
@ -241,10 +264,17 @@ func ParseUserEvent(v *fastjson.Value) (interface{}, error) {
|
||||||
case "ad_ratio_snapshot", "ad_ratio_update":
|
case "ad_ratio_snapshot", "ad_ratio_update":
|
||||||
return parseADRatio(v)
|
return parseADRatio(v)
|
||||||
|
|
||||||
|
case "borrowing_snapshot", "borrowing_update":
|
||||||
|
return parseDebts(v)
|
||||||
|
|
||||||
case "account_snapshot", "account_update", "mwallet_account_snapshot", "mwallet_account_update":
|
case "account_snapshot", "account_update", "mwallet_account_snapshot", "mwallet_account_update":
|
||||||
var e AccountUpdateEvent
|
var e AccountUpdateEvent
|
||||||
o := v.String()
|
o, err := v.StringBytes()
|
||||||
err := json.Unmarshal([]byte(o), &e)
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(o, &e)
|
||||||
return &e, err
|
return &e, err
|
||||||
|
|
||||||
case "error":
|
case "error":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user