zaifapi class : CreatePosition(string,string,string,string,real,real,real,real,real) method

Description

Makes an order.

Syntax

zaifapiInstance.CreatePosition(string type, string groupId, string currencyPair, string action, real plice, real amount, real leverage, real limit, real stop)

Arguments

ClassNameDescription
stringtype"margin" or "futures"。
stringgroupIdA group identifier.
stringcurrencyPairA currency pair.
stringaction"ask" or "bid"。
realpriceA price.
realamountA amount.
realleverageA leverage ratio.
reallimitA limit price.
realstopA stop price.

Return value

ClassDescription
zaifresA response to the request which have a JSON-text.

Sample code

1:

string apiKey = "3622c294-zs5m-587w-vv7j-sdf454h1sdbl";

2:

string secretKey = "4be789k3-dd7r-9d23-jy45-qng4c83hjk1g";

3:

zaifapi zaifapiIns = new zaifapi(apiKey, secretKey);

4:

zaifres zaifresIns = zaifapiIns.CreatePosition("futures", "1", "btc_jpy", "bid", 810000.0, 0.001, 5.0, 860000.0, 780000.0);

5:

string jsonStr = zaifresIns.Result;

Example for JSON-text

{"success": 1, "return": {"leverage_id": 6165423, "timestamp": "1558286346", "deposit_jpy": 176.14, "funds": {"jpy": 100000.0, "btc": 7.86e-06, "xem": 0.0, "mona": 0.0, "BCH": 9.96e-05, "ETH": 3.09e-05, "ZAIF": 0.0}}}

Notes

It is a trade API for the leverage transaction. You can not get the information if do not set the API key and the secret key.

It makes the order for the margin transaction of the spot market if the type argument is specified the "margin". In this case, the groupId argument must be specified an empty string.

It makes the order for the AirFX market if the type argument is specified the "futures". In this case, the groupId argument must be specified the "1".

The action argument must be specified to either "ask" or "bid".

It does not set the limit price if a number that is not greater than 0 specifies to the limit argument.

It does not set the stop price if a number that is not greater than 0 specifies to the stop argument.

An instance of the zaifres class is returned as the response to the request. This instance holds the JSON-text of the result of the response.

If an API error occurs, the following JSON-text will be returned.

{"success": 0, "error": "..."}

"error" is different for each API error.

If an HTTP error occurs, the following JSON-text will be returned.

{"success": -1000,"error": { "statuscode" : 404, "message": "Not Found"}}

"statuscode" and "message" are different for each HTTP error.

If the request times out, the following JSON-text will be returned.

{"success": -1001,"error": { "typename" : "TaskCanceledException", "message": "A task was canceled."}}

If the request fails due to other exceptions, the following JSON-text will be returned.

{"success": -1002,"error": { "typename" : "...", "message": "..."}}

"typename" and "message" are different for each exception.

Links for reference

Copyright © Cooker All rights reserved.