search Nothing found
Main Algotrading documentation Trade operations Positions

Positions.Check

It sends a request to the server to check if there are enough funds to open a position

int Positions.Check(symbolName, positionType, volume, closePrice, out margin, out profit)

Input parameters

Parameter
Type
Description
symbolName
string
Symbol name
positionType
Buy or Sell
volume
double
Position volume in lots
closePrice
double
Position closing price in quoted currency
margin
оut double
In the parameter, you can set a variable in which the calculated amount of collateral in the account currency will be recorded
profit
оut double
In the parameter, you can set a variable in which the calculated amount of profit in the account currency will be recorded

Return value

0
Fund sufficiency check was passed successfully
If an error occurs, it returns the server error code

If the name of a variable is passed to the out parameter Margin, then the amount of funds required to ensure open positions on the account will be recorded to this variable

If the name of a variable is passed to the out parameter Profit, then the amount of the calculated profit will be recorded to this variable

 Example:

string symbolName = "EURUSD";
double volume = 0.1;
double bidprice= Symbols.Find(symbolName).Quote.Bid;
double margin;
double profit;
int result;
result = Positions.Check(symbolName, PositionType.Buy, volume, bidprice, out margin, out profit);
if (result == 0) {
line = " Positions.Check(" + symbolName + ", PositionType.Buy, " + volume.ToString() + ", " + bidprice.ToString()
+ ", out margin, out profit):";

line = line + " result: " + result.ToString() + ", margin: " + margin.ToString() + ", profit: " + profit.ToString();
using (StreamWriter sw = new StreamWriter(mOnStartLog, true))
sw.WriteLine(DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss:fff") + line + Environment.NewLine);
}



Subscribe to our newsletter and stay up to date with all the news!