@ixily/activ
Version:
Alpha Capture Trade Idea Verification. Blockchain ownership proven trade ideas and strategies.
57 lines • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.portfolio = void 0;
const add = (isOpen, pricing, ticker, allocation, notes, title, direction, assetDescription, reference, assetImage, alternativeProviderSymbols) => {
if (isOpen) {
if (title === undefined || typeof title !== 'string') {
throw new Error('title is required when you open a new idea');
}
else {
if (title.length === 0) {
throw new Error('title is required when you open a new idea');
}
}
if (assetDescription === undefined ||
typeof assetDescription !== 'string') {
throw new Error('assetDescription is required when you open a new idea');
}
else {
if (assetDescription.length === 0) {
throw new Error('assetDescription is required when you open a new idea');
}
}
if (direction === undefined ||
(direction !== 'long' && direction !== 'short')) {
throw new Error('direction is required when you open a new idea and it must be "open" or "short"');
}
}
const entry = {
reference,
pricing: { ...pricing },
notes,
title,
asset: {
ticker,
description: assetDescription,
image: assetImage,
alternativeProviderSymbols,
},
direction: isOpen ? direction : undefined,
// reuse in open and for calculate adjustment
allocation,
};
return entry;
};
exports.portfolio = {
add,
open: (title, notes, pricing, ticker, assetDescription, direction, allocation, reference, assetImage, alternativeProviderSymbols) => {
return add(true, pricing, ticker, allocation, notes, title, direction, assetDescription, reference, assetImage, alternativeProviderSymbols);
},
adjust: (notes, pricing, ticker, allocation, reference) => {
return add(false, pricing, ticker, allocation, notes, undefined, undefined, undefined, reference);
},
close: (notes, pricing, ticker, reference) => {
return add(false, pricing, ticker, 0, notes, undefined, undefined, undefined, reference);
},
};
//# sourceMappingURL=portfolio.tool.js.map