@sharplygroup/xtb-api-js
Version:
A module for interacting with the XTB API
48 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SymbolOperations = void 0;
class SymbolOperations {
wsManager;
constructor(wsManager) {
this.wsManager = wsManager;
}
/**
* Returns array of all symbols available for the user.
* @returns {Promise<ISymbolsResponse>}
*/
async getAllSymbols() {
const response = (await this.wsManager.sendCommand({
command: "getAllSymbols",
arguments: {},
}));
if (!response.status || !response.returnData) {
throw new Error(response.errorDescr || "Failed to get all symbols");
}
return {
status: response.status,
returnData: response.returnData,
};
}
/**
* Returns information about symbol available for the user.
* @param {string} symbol - Symbol name
* @returns {Promise<ISymbolResponse>}
*/
async getSymbol(symbol) {
const response = (await this.wsManager.sendCommand({
command: "getSymbol",
arguments: {
symbol: symbol,
},
}));
if (!response.status || !response.returnData) {
throw new Error(response.errorDescr || `Failed to get symbol ${symbol}`);
}
return {
status: response.status,
returnData: response.returnData,
};
}
}
exports.SymbolOperations = SymbolOperations;
//# sourceMappingURL=SymbolOperations.js.map