Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Latest commit

 

History

History
382 lines (283 loc) · 15.5 KB

SWGPositionsApi.md

File metadata and controls

382 lines (283 loc) · 15.5 KB

SWGPositionsApi

All URIs are relative to https://api.bybit.com

Method HTTP request Description
positionsChangeMargin POST /position/change-position-margin Update margin.
positionsClosePnlRecords GET /v2/private/trade/closed-pnl/list Get user's closed profit and loss records
positionsMyPosition GET /v2/private/position/list Get my position list.
positionsSaveLeverage POST /user/leverage/save Change user leverage.
positionsTradingStop POST /open-api/position/trading-stop Set Trading-Stop Condition.

positionsChangeMargin

-(NSURLSessionTask*) positionsChangeMarginWithSymbol: (NSString*) symbol
    margin: (NSString*) margin
        completionHandler: (void (^)(NSObject* output, NSError* error)) handler;

Update margin.

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure API key authorization: (authentication scheme: apiKey)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"api_key"];

// Configure API key authorization: (authentication scheme: apiSignature)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"sign"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"sign"];

// Configure API key authorization: (authentication scheme: timestamp)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"timestamp"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"timestamp"];


NSString* symbol = @"symbol_example"; // Contract type which you want update its margin
NSString* margin = @"margin_example"; // New margin you want set

SWGPositionsApi*apiInstance = [[SWGPositionsApi alloc] init];

// Update margin.
[apiInstance positionsChangeMarginWithSymbol:symbol
              margin:margin
          completionHandler: ^(NSObject* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPositionsApi->positionsChangeMargin: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
symbol NSString* Contract type which you want update its margin
margin NSString* New margin you want set

Return type

NSObject*

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

positionsClosePnlRecords

-(NSURLSessionTask*) positionsClosePnlRecordsWithSymbol: (NSString*) symbol
    startTime: (NSNumber*) startTime
    endTime: (NSNumber*) endTime
    execType: (NSString*) execType
    page: (NSNumber*) page
    limit: (NSNumber*) limit
        completionHandler: (void (^)(NSObject* output, NSError* error)) handler;

Get user's closed profit and loss records

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure API key authorization: (authentication scheme: apiKey)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"api_key"];

// Configure API key authorization: (authentication scheme: apiSignature)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"sign"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"sign"];

// Configure API key authorization: (authentication scheme: timestamp)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"timestamp"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"timestamp"];


NSString* symbol = @"symbol_example"; // Contract type
NSNumber* startTime = @56; // Start timestamp point for result, in second (optional)
NSNumber* endTime = @56; // End timestamp point for result, in second (optional)
NSString* execType = @"execType_example"; // Execution type (optional)
NSNumber* page = @56; // Page. By default, gets first page of data. Maximum of 50 pages (optional)
NSNumber* limit = @56; // Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page. (optional)

SWGPositionsApi*apiInstance = [[SWGPositionsApi alloc] init];

// Get user's closed profit and loss records
[apiInstance positionsClosePnlRecordsWithSymbol:symbol
              startTime:startTime
              endTime:endTime
              execType:execType
              page:page
              limit:limit
          completionHandler: ^(NSObject* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPositionsApi->positionsClosePnlRecords: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
symbol NSString* Contract type
startTime NSNumber* Start timestamp point for result, in second [optional]
endTime NSNumber* End timestamp point for result, in second [optional]
execType NSString* Execution type [optional]
page NSNumber* Page. By default, gets first page of data. Maximum of 50 pages [optional]
limit NSNumber* Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page. [optional]

Return type

NSObject*

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

positionsMyPosition

-(NSURLSessionTask*) positionsMyPositionWithSymbol: (NSString*) symbol
        completionHandler: (void (^)(NSObject* output, NSError* error)) handler;

Get my position list.

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure API key authorization: (authentication scheme: apiKey)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"api_key"];

// Configure API key authorization: (authentication scheme: apiSignature)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"sign"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"sign"];

// Configure API key authorization: (authentication scheme: timestamp)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"timestamp"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"timestamp"];


NSString* symbol = @"symbol_example"; // Contract type which you want update its margin (optional)

SWGPositionsApi*apiInstance = [[SWGPositionsApi alloc] init];

// Get my position list.
[apiInstance positionsMyPositionWithSymbol:symbol
          completionHandler: ^(NSObject* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPositionsApi->positionsMyPosition: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
symbol NSString* Contract type which you want update its margin [optional]

Return type

NSObject*

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

positionsSaveLeverage

-(NSURLSessionTask*) positionsSaveLeverageWithSymbol: (NSString*) symbol
    leverage: (NSString*) leverage
        completionHandler: (void (^)(NSObject* output, NSError* error)) handler;

Change user leverage.

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure API key authorization: (authentication scheme: apiKey)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"api_key"];

// Configure API key authorization: (authentication scheme: apiSignature)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"sign"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"sign"];

// Configure API key authorization: (authentication scheme: timestamp)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"timestamp"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"timestamp"];


NSString* symbol = @"symbol_example"; // A symbol which you want change its leverage
NSString* leverage = @"leverage_example"; // New leverage you want set

SWGPositionsApi*apiInstance = [[SWGPositionsApi alloc] init];

// Change user leverage.
[apiInstance positionsSaveLeverageWithSymbol:symbol
              leverage:leverage
          completionHandler: ^(NSObject* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPositionsApi->positionsSaveLeverage: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
symbol NSString* A symbol which you want change its leverage
leverage NSString* New leverage you want set

Return type

NSObject*

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

positionsTradingStop

-(NSURLSessionTask*) positionsTradingStopWithSymbol: (NSString*) symbol
    takeProfit: (NSString*) takeProfit
    stopLoss: (NSString*) stopLoss
    trailingStop: (NSString*) trailingStop
    varNewTrailingActive: (NSString*) varNewTrailingActive
        completionHandler: (void (^)(NSObject* output, NSError* error)) handler;

Set Trading-Stop Condition.

Example

SWGDefaultConfiguration *apiConfig = [SWGDefaultConfiguration sharedConfig];

// Configure API key authorization: (authentication scheme: apiKey)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"api_key"];

// Configure API key authorization: (authentication scheme: apiSignature)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"sign"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"sign"];

// Configure API key authorization: (authentication scheme: timestamp)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"timestamp"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"timestamp"];


NSString* symbol = @"symbol_example"; // Contract type
NSString* takeProfit = @"takeProfit_example"; // Not less than 0, 0 means cancel TP (optional)
NSString* stopLoss = @"stopLoss_example"; // Not less than 0, 0 means cancel SL (optional)
NSString* trailingStop = @"trailingStop_example"; // Not less than 0, 0 means cancel TS (optional)
NSString* varNewTrailingActive = @"varNewTrailingActive_example"; // Trailing stop trigger price. Trailing stops are triggered only when the price reaches the specified price. Trailing stops are triggered immediately by default. (optional)

SWGPositionsApi*apiInstance = [[SWGPositionsApi alloc] init];

// Set Trading-Stop Condition.
[apiInstance positionsTradingStopWithSymbol:symbol
              takeProfit:takeProfit
              stopLoss:stopLoss
              trailingStop:trailingStop
              varNewTrailingActive:varNewTrailingActive
          completionHandler: ^(NSObject* output, NSError* error) {
                        if (output) {
                            NSLog(@"%@", output);
                        }
                        if (error) {
                            NSLog(@"Error calling SWGPositionsApi->positionsTradingStop: %@", error);
                        }
                    }];

Parameters

Name Type Description Notes
symbol NSString* Contract type
takeProfit NSString* Not less than 0, 0 means cancel TP [optional]
stopLoss NSString* Not less than 0, 0 means cancel SL [optional]
trailingStop NSString* Not less than 0, 0 means cancel TS [optional]
varNewTrailingActive NSString* Trailing stop trigger price. Trailing stops are triggered only when the price reaches the specified price. Trailing stops are triggered immediately by default. [optional]

Return type

NSObject*

Authorization

apiKey, apiSignature, timestamp

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]