@backtest/command-line
Version:
This project is a CLI build around Backtest, a library for trading developers
56 lines • 2.66 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.viewHistoricalDataPortal = viewHistoricalDataPortal;
const portals_1 = require("../../helpers/portals");
const headers_1 = require("../../infra/headers");
const colors_1 = require("../../infra/colors");
const edit_1 = require("./edit");
const framework_1 = require("@backtest/framework");
function viewHistoricalDataPortal() {
return __awaiter(this, void 0, void 0, function* () {
console.clear();
let back = false;
let portalReturn = { error: false, data: '' };
while (!back) {
const historicalNames = yield (0, framework_1.findHistoricalDataNames)();
if (!(historicalNames === null || historicalNames === void 0 ? void 0 : historicalNames.length))
return { error: true, data: 'There are no saved candles' };
let choices = historicalNames;
choices.push((0, colors_1.colorBack)('👈 Back'));
(0, headers_1.headerViewHistoricalData)();
yield (0, portals_1.handlePortalReturn)(portalReturn);
const choiceCLI = yield (0, portals_1.interactCLI)({
type: 'autocomplete',
message: 'Choose a symbol / interval to interact with:',
choices
});
if (choiceCLI.includes('👈')) {
back = true;
portalReturn.error = false;
portalReturn.data = '';
}
else {
let userChoice = '';
for (let i = 0; i < choices.length; i++) {
if (choices[i] === choiceCLI) {
userChoice = historicalNames[i];
break;
}
}
portalReturn = yield (0, edit_1.editPortal)(userChoice);
}
console.clear();
}
return portalReturn;
});
}
//# sourceMappingURL=view.js.map
;