Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
salanfe opened this issue May 23, 2019 · 1 comment
Open

Comments

@salanfe
Copy link
Contributor

salanfe commented May 23, 2019

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

@salanfe salanfe changed the title Changing type of ClosedOrders' numeric fields from float64 to string Changing type of Order struct's numeric fields from float64 to string May 23, 2019
@RoanBrand
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants