beldur/kraken-go-api-client

Changing type of Order struct's numeric fields from float64 to string

salanfe opened this issue · 1 comments

I propose to update the Order struct

type Order struct {
as follow

type Order struct {
	TransactionID  string           `json:"-"`
	ReferenceID    string           `json:"refid"`
	UserRef        int              `json:"userref"`
	Status         string           `json:"status"`
	OpenTime       float64          `json:"opentm"`
	StartTime      float64          `json:"starttm"`
	ExpireTime     float64          `json:"expiretm"`
	Description    OrderDescription `json:"descr"`
	Volume         string           `json:"vol"`
	VolumeExecuted string           `json:"vol_exec"`
	Cost           string           `json:"cost"`
	Fee            string           `json:"fee"`
	Price          string           `json:"price"`
	StopPrice      string           `json:"stopprice"`
	LimitPrice     string           `json:"limitprice"`
	Misc           string           `json:"misc"`
	OrderFlags     string           `json:"oflags"`
	CloseTime      float64          `json:"closetm"`
	Reason         string           `json:"reason"`
	TradesID       []string         `json:"trades"`
}

so we do not lose precision casting numeric values (eg Cost, Fee, Price, etc)

as a reminder a ClosedOrders response looks like this

{
    "error": [],
    "result": {
        "closed": {
            "AAAAAA-BBBBB-CCCCCC": {
                "refid": null,
                "userref": 1234567890,
                "status": "closed",
                "reason": null,
                "opentm": 1234567890.1234,
                "closetm": 1234567890.5678,
                "starttm": 0,
                "expiretm": 1234567890,
                "descr": {
                    "pair": "ETHEUR",
                    "type": "buy",
                    "ordertype": "market",
                    "price": "0",
                    "price2": "0",
                    "leverage": "none",
                    "order": "buy 1.13147800 ETHEUR @ market",
                    "close": ""
                },
                "vol": "1.13147800",
                "vol_exec": "1.13147800",
                "cost": "249.96",
                "fee": "0.64",
                "price": "220.92",
                "stopprice": "0.00000",
                "limitprice": "0.00000",
                "misc": "",
                "oflags": "fciq",
                "trades": [
                    "EEEEEE-FFFFF-GGGGGG"
                ]
            }
        },
        "count": 1
    }
}

TradesID is addressed in my current PR #47

all amount and balances need to be kept strings. There is a reason Kraken API doesn't send them as JSON numbers.