I've been looking up static methods and non-static properties but I don't understand how it applies here. It's been a while since I've looked at C# code. I get the following error message from the following code. Any help would be greatly appreciated.
(awaitable) Task > IgRestApiClient.createPositionV2(CreatePositionRequest createPositionRequest) Creates an OTC position @param createPositionRequest the request for creating a position @return OTC create position response An object reference is required for the non-static field, method, or property 'IgRestApiClient.createPositionV2 (CreatePositionRequest)'
public async void BuyThis()
{
try
{
var buyDataX = new CreatePositionRequest
{
epic = "THIS",
expiry = "MAY-20",
direction = "SELL",
size = 1,
level = 100,
orderType = "LIMIT",
guaranteedStop = false,
stopLevel = null,
stopDistance = null,
trailingStop = false,
trailingStopIncrement = null,
forceOpen = false,
limitLevel = null,
limitDistance = null,
quoteId = null,
currencyCode = "USD",
timeInForce = "EXECUTE_AND_ELIMINATE",
};
var response = await IgRestApiClient.createPositionV2(buyDataX);
}
catch (Exception ex)
{
}
}
public async Task<IgResponse<CreatePositionResponse>> createPositionV2(dto.endpoint.positions.create.otc.v2.CreatePositionRequest createPositionRequest)
{
return await _igRestService.RestfulService<CreatePositionResponse>("/gateway/deal/positions/otc", HttpMethod.Post, "2", _conversationContext, createPositionRequest);
}