@showr/core
Version:
Core library for Showr
44 lines (43 loc) • 939 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TradePosition = exports.newTradingPositionMap = void 0;
exports.newTradingPositionMap = {
idle: {
idle: 'idle',
entry: 'entry',
exit: 'idle',
hold: 'idle',
},
entry: {
idle: 'hold',
entry: 'hold',
exit: 'exit',
hold: 'hold',
},
exit: {
idle: 'idle',
entry: 'entry',
exit: 'idle',
hold: 'idle',
},
hold: {
idle: 'hold',
entry: 'hold',
exit: 'exit',
hold: 'hold',
},
};
class TradePosition {
_type;
constructor(type) {
this._type = type;
}
get value() {
return this._type;
}
update(newPosition) {
this._type = exports.newTradingPositionMap[this._type][newPosition ?? this._type];
return this;
}
}
exports.TradePosition = TradePosition;