zaifapi class : GetPositions(string,string,int,string) method

Description

Gets personal trade history.

Syntax

zaifapiInstance.GetPositions(string type, string groupId, int count, string currencyPair)

Arguments

ClassNameDescription
stringtype"margin" or "futures"。
stringgroupIdA group identifier.
intcountA number of records to retrieve.
stringcurrencyPairA currency pair.

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.GetPositions("futures", "1", 10, "btc_jpy");

5:

string jsonStr = zaifresIns.Result;

Example for JSON-text

{"success": 1, "return": {"6185413": {"group_id": 1, "currency_pair": "btc_jpy", "action": "bid", "amount": 0.001, "price": 810000.0, "limit": 860000.0, "stop": 780000.0, "timestamp": "1558280346", "leverage": 5.0, "fee_spent": 0.0, "timestamp_closed": "1558281875", "deposit_jpy": 176.14, "refunded_jpy": 176.14, "swap": 0.0}, "6176292": {"group_id": 1, "currency_pair": "btc_jpy", "action": "bid", "amount": 0.001, "price": 790000.0, "limit": 865000.0, "stop": 785000.0, "timestamp": "1558238180", "leverage": 5.0, "fee_spent": 0.0, "timestamp_closed": "1558248455", "deposit_jpy": 176.24, "refunded_jpy": 176.24, "swap": 0.0}, "6175974": {"group_id": 1, "currency_pair": "btc_jpy", "action": "bid", "amount": 0.001, "price": 800000.0, "timestamp": "1558237296", "leverage": 5.0, "fee_spent": 0.0, "timestamp_closed": "1558237560", "deposit_jpy": 174.5, "refunded_jpy": 174.5, "swap": 0.0}, "5968352": {"group_id": 1, "currency_pair": "btc_jpy", "action": "ask", "amount": 0.0318, "price": 617890.0, "limit": 634000.0, "stop": 632890.0, "timestamp": "1556985859", "leverage": 25.0, "fee_spent": 7.7301666, "timestamp_closed": "1557003795", "price_avg": 617890.0, "amount_done": 0.0318, "close_avg": 634000.0, "close_done": 0.0318, "deposit_jpy": 792.8376, "refunded_jpy": 338.02651857, "swap": 65.21708517}, "5967856": {"group_id": 1, "currency_pair": "btc_jpy", "action": "ask", "amount": 0.0317, "price": 619995.0, "limit": 618410.0, "stop": 629995.0, "timestamp": "1556981067", "leverage": 25.0, "fee_spent": 7.7367654, "timestamp_closed": "1556982256", "price_avg": 619995.0, "amount_done": 0.0317, "close_avg": 618410.0, "close_done": 0.0317, "deposit_jpy": 793.5144, "refunded_jpy": 838.20219531, "swap": 2.18006071}, "5966678": {"group_id": 1, "currency_pair": "btc_jpy", "action": "ask", "amount": 0.0313, "price": 628000.0, "limit": 625000.0, "stop": 638000.0, "timestamp": "1556977646", "leverage": 25.0, "fee_spent": 0.0, "timestamp_closed": "1556977815", "deposit_jpy": 795.1452, "refunded_jpy": 795.1452, "swap": 0.0}, "5964938": {"group_id": 1, "currency_pair": "btc_jpy", "action": "bid", "amount": 0.0319, "price": 635020.0, "limit": 631000.0, "stop": 625020.0, "timestamp": "1556956920", "leverage": 25.0, "fee_spent": 8.0082717, "timestamp_closed": "1556959693", "price_avg": 635020.0, "amount_done": 0.0319, "close_avg": 636000.0, "close_done": 0.0319, "deposit_jpy": 821.3612, "refunded_jpy": 844.6149283, "swap": 0.0}, "5960557": {"group_id": 1, "currency_pair": "btc_jpy", "action": "ask", "amount": 0.0031, "price": 641030.0, "limit": 638030.0, "stop": 651030.0, "timestamp": "1556913528", "leverage": 2.5, "fee_spent": 0.0, "timestamp_closed": "1556913595", "deposit_jpy": 790.128, "refunded_jpy": 790.128, "swap": 0.0}, "5960548": {"group_id": 1, "currency_pair": "btc_jpy", "action": "ask", "amount": 0.0124, "price": 641000.0, "limit": 638000.0, "stop": 651000.0, "timestamp": "1556913441", "leverage": 10.0, "fee_spent": 0.0, "timestamp_closed": "1556913463", "deposit_jpy": 790.748, "refunded_jpy": 790.748, "swap": 0.0}, "5960543": {"group_id": 1, "currency_pair": "btc_jpy", "action": "ask", "amount": 0.0012, "price": 641600.0, "limit": 638600.0, "stop": 651600.0, "timestamp": "1556913367", "leverage": 1.0, "fee_spent": 0.0, "timestamp_closed": "1556913383", "deposit_jpy": 765.48, "refunded_jpy": 765.48, "swap": 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 gets the trade history 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 gets the trade history for the AirFX market if the type argument is specified the "futures". In this case, the groupId argument must be specified the "1".

If count argument is set not greater than 0, returns up to 1000 record.

It returns the trade history for all currency pair if the currencyPair argument is specified an empty string. However, leverage transaction is effective only with the "btc_jpy", so it makes the same result as the "btc_jpy".

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.