Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

taapi-strategies

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

taapi-strategies - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

9

dist/cjs/fsm/Bot.js

@@ -54,2 +54,3 @@ "use strict";

this.taapiClient = taapiClient;
this.utilities = new Utilities_1.default();
this.order = new Order_1.default(systemConfig, exchange, database, notifications, taapiClient);

@@ -122,5 +123,5 @@ }

const State = yield (_a = `${process.cwd()}/bot/State_${trade.state}.js`, Promise.resolve().then(() => __importStar(require(_a))));
const state = new State.default(trade, this.systemConfig, this.database, this.order);
const state = new State.default(trade, this.systemConfig, this.database, this.utilities, this.order);
yield state.tick();
yield Utilities_1.default.sleep(this.systemConfig.bot.fsm.tradeDelay || 5000);
yield this.utilities.sleep(this.systemConfig.bot.fsm.tradeDelay || 5000);
}

@@ -139,6 +140,6 @@ }

const Scanner = yield (_a = `${process.cwd()}/bot/Scanner.js`, Promise.resolve().then(() => __importStar(require(_a))));
this.scanner = new Scanner.default(this.systemConfig, this.database, this.taapiClient, this.order);
this.scanner = new Scanner.default(this.systemConfig, this.database, this.utilities, this.taapiClient, this.order);
node_schedule_1.default.scheduleJob(this.systemConfig.bot.fsm.tick.schedule, (date) => __awaiter(this, void 0, void 0, function* () {
yield this.scanner.scan();
yield Utilities_1.default.sleep(this.systemConfig.bot.scanner.assetDelay || 5000);
yield this.utilities.sleep(this.systemConfig.bot.scanner.assetDelay || 5000);
}));

@@ -145,0 +146,0 @@ });

@@ -28,2 +28,3 @@ "use strict";

this.taapi = new TaapiClient_1.default(systemConfig);
this.utilities = new Utilities_js_1.default();
}

@@ -33,3 +34,3 @@ setEntryDetails(price, targetPrice, stoplossPrice) {

this.trade.entryAtTimestamp = (0, moment_1.default)().unix();
this.trade.entryAtHuman = Utilities_js_1.default.timestampToHuman((0, moment_1.default)().unix());
this.trade.entryAtHuman = this.utilities.timestampToHuman((0, moment_1.default)().unix());
this.trade.entryPrice = price;

@@ -44,3 +45,3 @@ this.trade.targetPrice = targetPrice;

this.trade.exitAtTimestamp = (0, moment_1.default)().unix();
this.trade.exitAtHuman = Utilities_js_1.default.timestampToHuman((0, moment_1.default)().unix());
this.trade.exitAtHuman = this.utilities.timestampToHuman((0, moment_1.default)().unix());
this.trade.exitPrice = price;

@@ -70,3 +71,3 @@ this.trade.exitReason = reason;

isEntryHit(candles) {
let direction = Utilities_js_1.default.getDirection(this.trade);
let direction = this.utilities.getDirection(this.trade);
let entryHit = false;

@@ -87,3 +88,3 @@ let tradeSetupCandleStart = this.ta.getIntervalStartTimestamp(this.trade.setupAtTimestamp, this.trade.interval);

isTargetHit(candles) {
let direction = Utilities_js_1.default.getDirection(this.trade);
let direction = this.utilities.getDirection(this.trade);
let targetHit = false;

@@ -104,3 +105,3 @@ let tradeEntryCandleStart = this.ta.getIntervalStartTimestamp(this.trade.entryAtTimestamp, this.trade.interval);

isStoplossHit(candles) {
let direction = Utilities_js_1.default.getDirection(this.trade);
let direction = this.utilities.getDirection(this.trade);
let stoplossHit = false;

@@ -224,3 +225,3 @@ let tradeEntryCandleStart = this.ta.getIntervalStartTimestamp(this.trade.entryAtTimestamp, this.trade.interval);

return __awaiter(this, void 0, void 0, function* () {
this.trade.log.push(`${Utilities_js_1.default.timestampToHuman((0, moment_1.default)().unix())}: ${logMessage}`);
this.trade.log.push(`${this.utilities.timestampToHuman((0, moment_1.default)().unix())}: ${logMessage}`);
});

@@ -227,0 +228,0 @@ }

@@ -45,2 +45,3 @@ "use strict";

this.collectionPrefix = systemConfig["database"]["collectionPrefix"];
this.utilities = new Utilities_1.default();
}

@@ -301,3 +302,3 @@ connect(showOutputMessages) {

state: state,
signature: Utilities_1.default.getTradeSignature(exchangeId, symbol, interval),
signature: this.utilities.getTradeSignature(exchangeId, symbol, interval),
exchangeId: exchangeId,

@@ -309,3 +310,3 @@ symbol: symbol,

createdAt: createdAt,
createdAtHuman: Utilities_1.default.timestampToHuman(createdAt),
createdAtHuman: this.utilities.timestampToHuman(createdAt),
};

@@ -440,3 +441,3 @@ yield this.db

}
setCoinInfo(exchangeId, baseAsset, data) {
setCoinInfo(exchangeId, baseAsset, data = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -471,29 +472,22 @@ yield this.db.collection(`coinInfo`)

}
getShortlist(exchangeId) {
getShortlist(id, query = {}, sort = {}) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.db
.collection("shortlist")
.find({
exchangeId: exchangeId,
})
.sort({ volumeWeekly: -1 })
.collection(`shortlist_${id}`)
.find(query)
.sort(sort)
.toArray();
});
}
setShortlist(exchangeId, symbol, price, priceUSD, volumeWeekly) {
setShortlistItem(id, symbol, data = {}) {
return __awaiter(this, void 0, void 0, function* () {
const doc = {
exchangeId: exchangeId,
symbol: symbol,
price: price,
priceUSD: priceUSD,
volumeWeekly: volumeWeekly,
updatedAt: (0, moment_1.default)().unix(),
};
yield this.db.collection(`shortlist`)
data["symbol"] = symbol;
data["exchangeId"] = data["exchangeId"] ? data["exchangeId"] : this.systemConfig.exchange.id;
data["updatedAt"] = (0, moment_1.default)().unix();
yield this.db.collection(`shortlist_${id}`)
.updateOne({
"exchangeId": exchangeId,
"exchangeId": data["exchangeId"],
"symbol": symbol,
}, {
$set: doc
$set: data
}, {

@@ -508,10 +502,9 @@ upsert: true,

}
deleteShortlist(exchangeId, symbol) {
deleteShortlistItem(id, symbol, query = {}) {
return __awaiter(this, void 0, void 0, function* () {
query["symbol"] = symbol;
query["exchangeId"] = query["exchangeId"] ? query["exchangeId"] : this.systemConfig.exchange.id;
yield this.db
.collection(`shortlist`)
.deleteOne({
exchangeId: exchangeId,
symbol: symbol,
})
.collection(`shortlist_${id}`)
.deleteOne(query)
.then(result => {

@@ -518,0 +511,0 @@ });

@@ -238,2 +238,2 @@ "use strict";

}
exports.default = new Utilities();
exports.default = Utilities;

@@ -18,2 +18,3 @@ "use strict";

const apiRoutes = (systemConfig, app, auth, exchange, database, notifications, taapiClient, bot) => {
const utilities = new Utilities_1.default();
app.get(`/get-historical-trades`, auth, (req, res) => __awaiter(void 0, void 0, void 0, function* () {

@@ -33,3 +34,3 @@ let hoursBack = req.query.hoursBack || 10000;

trades = trades.map(trade => {
trade.direction = Utilities_1.default.getDirection(trade);
trade.direction = utilities.getDirection(trade);
let exitReason = trade.exitReason ? `, exit=${trade.exitReason}` : "";

@@ -43,11 +44,3 @@ return trade;

app.get(`/force-scan`, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
let exchangeId = req.query.exchangeId;
let interval = req.query.interval;
let errors = [];
if (!exchangeId) {
errors.push("Parameter 'exchangeId' is required!");
}
if (!interval) {
errors.push("Parameter 'interval' is required!");
}
let responseStatusCode = 200;

@@ -82,3 +75,3 @@ let responseData = {};

trades = trades.map(trade => {
trade.direction = Utilities_1.default.getDirection(trade);
trade.direction = utilities.getDirection(trade);
trade.profitGoal = Math.abs(Math.round((trade.targetPrice - trade.entryPrice) * 100 / trade.entryPrice * 100) / 100);

@@ -92,9 +85,6 @@ return trade;

app.post(`/create-trade`, auth, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
let exchangeId = req.body.exchangeId;
let exchangeId = req.body.exchangeId || systemConfig["exchange"]["id"];
let symbol = req.body.symbol;
let interval = req.body.interval;
let errors = [];
if (!exchangeId) {
errors.push("Parameter 'exchangeId' is required!");
}
if (!symbol) {

@@ -101,0 +91,0 @@ errors.push("Parameter 'symbol' is required!");

@@ -54,2 +54,3 @@ "use strict";

this.taapiClient = taapiClient;
this.utilities = new Utilities_1.default();
this.order = new Order_1.default(systemConfig, exchange, database, notifications, taapiClient);

@@ -122,5 +123,5 @@ }

const State = yield (_a = `${process.cwd()}/bot/State_${trade.state}.js`, Promise.resolve().then(() => __importStar(require(_a))));
const state = new State.default(trade, this.systemConfig, this.database, this.order);
const state = new State.default(trade, this.systemConfig, this.database, this.utilities, this.order);
yield state.tick();
yield Utilities_1.default.sleep(this.systemConfig.bot.fsm.tradeDelay || 5000);
yield this.utilities.sleep(this.systemConfig.bot.fsm.tradeDelay || 5000);
}

@@ -139,6 +140,6 @@ }

const Scanner = yield (_a = `${process.cwd()}/bot/Scanner.js`, Promise.resolve().then(() => __importStar(require(_a))));
this.scanner = new Scanner.default(this.systemConfig, this.database, this.taapiClient, this.order);
this.scanner = new Scanner.default(this.systemConfig, this.database, this.utilities, this.taapiClient, this.order);
node_schedule_1.default.scheduleJob(this.systemConfig.bot.fsm.tick.schedule, (date) => __awaiter(this, void 0, void 0, function* () {
yield this.scanner.scan();
yield Utilities_1.default.sleep(this.systemConfig.bot.scanner.assetDelay || 5000);
yield this.utilities.sleep(this.systemConfig.bot.scanner.assetDelay || 5000);
}));

@@ -145,0 +146,0 @@ });

@@ -28,2 +28,3 @@ "use strict";

this.taapi = new TaapiClient_1.default(systemConfig);
this.utilities = new Utilities_js_1.default();
}

@@ -33,3 +34,3 @@ setEntryDetails(price, targetPrice, stoplossPrice) {

this.trade.entryAtTimestamp = (0, moment_1.default)().unix();
this.trade.entryAtHuman = Utilities_js_1.default.timestampToHuman((0, moment_1.default)().unix());
this.trade.entryAtHuman = this.utilities.timestampToHuman((0, moment_1.default)().unix());
this.trade.entryPrice = price;

@@ -44,3 +45,3 @@ this.trade.targetPrice = targetPrice;

this.trade.exitAtTimestamp = (0, moment_1.default)().unix();
this.trade.exitAtHuman = Utilities_js_1.default.timestampToHuman((0, moment_1.default)().unix());
this.trade.exitAtHuman = this.utilities.timestampToHuman((0, moment_1.default)().unix());
this.trade.exitPrice = price;

@@ -70,3 +71,3 @@ this.trade.exitReason = reason;

isEntryHit(candles) {
let direction = Utilities_js_1.default.getDirection(this.trade);
let direction = this.utilities.getDirection(this.trade);
let entryHit = false;

@@ -87,3 +88,3 @@ let tradeSetupCandleStart = this.ta.getIntervalStartTimestamp(this.trade.setupAtTimestamp, this.trade.interval);

isTargetHit(candles) {
let direction = Utilities_js_1.default.getDirection(this.trade);
let direction = this.utilities.getDirection(this.trade);
let targetHit = false;

@@ -104,3 +105,3 @@ let tradeEntryCandleStart = this.ta.getIntervalStartTimestamp(this.trade.entryAtTimestamp, this.trade.interval);

isStoplossHit(candles) {
let direction = Utilities_js_1.default.getDirection(this.trade);
let direction = this.utilities.getDirection(this.trade);
let stoplossHit = false;

@@ -224,3 +225,3 @@ let tradeEntryCandleStart = this.ta.getIntervalStartTimestamp(this.trade.entryAtTimestamp, this.trade.interval);

return __awaiter(this, void 0, void 0, function* () {
this.trade.log.push(`${Utilities_js_1.default.timestampToHuman((0, moment_1.default)().unix())}: ${logMessage}`);
this.trade.log.push(`${this.utilities.timestampToHuman((0, moment_1.default)().unix())}: ${logMessage}`);
});

@@ -227,0 +228,0 @@ }

@@ -45,2 +45,3 @@ "use strict";

this.collectionPrefix = systemConfig["database"]["collectionPrefix"];
this.utilities = new Utilities_1.default();
}

@@ -301,3 +302,3 @@ connect(showOutputMessages) {

state: state,
signature: Utilities_1.default.getTradeSignature(exchangeId, symbol, interval),
signature: this.utilities.getTradeSignature(exchangeId, symbol, interval),
exchangeId: exchangeId,

@@ -309,3 +310,3 @@ symbol: symbol,

createdAt: createdAt,
createdAtHuman: Utilities_1.default.timestampToHuman(createdAt),
createdAtHuman: this.utilities.timestampToHuman(createdAt),
};

@@ -440,3 +441,3 @@ yield this.db

}
setCoinInfo(exchangeId, baseAsset, data) {
setCoinInfo(exchangeId, baseAsset, data = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -471,29 +472,22 @@ yield this.db.collection(`coinInfo`)

}
getShortlist(exchangeId) {
getShortlist(id, query = {}, sort = {}) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.db
.collection("shortlist")
.find({
exchangeId: exchangeId,
})
.sort({ volumeWeekly: -1 })
.collection(`shortlist_${id}`)
.find(query)
.sort(sort)
.toArray();
});
}
setShortlist(exchangeId, symbol, price, priceUSD, volumeWeekly) {
setShortlistItem(id, symbol, data = {}) {
return __awaiter(this, void 0, void 0, function* () {
const doc = {
exchangeId: exchangeId,
symbol: symbol,
price: price,
priceUSD: priceUSD,
volumeWeekly: volumeWeekly,
updatedAt: (0, moment_1.default)().unix(),
};
yield this.db.collection(`shortlist`)
data["symbol"] = symbol;
data["exchangeId"] = data["exchangeId"] ? data["exchangeId"] : this.systemConfig.exchange.id;
data["updatedAt"] = (0, moment_1.default)().unix();
yield this.db.collection(`shortlist_${id}`)
.updateOne({
"exchangeId": exchangeId,
"exchangeId": data["exchangeId"],
"symbol": symbol,
}, {
$set: doc
$set: data
}, {

@@ -508,10 +502,9 @@ upsert: true,

}
deleteShortlist(exchangeId, symbol) {
deleteShortlistItem(id, symbol, query = {}) {
return __awaiter(this, void 0, void 0, function* () {
query["symbol"] = symbol;
query["exchangeId"] = query["exchangeId"] ? query["exchangeId"] : this.systemConfig.exchange.id;
yield this.db
.collection(`shortlist`)
.deleteOne({
exchangeId: exchangeId,
symbol: symbol,
})
.collection(`shortlist_${id}`)
.deleteOne(query)
.then(result => {

@@ -518,0 +511,0 @@ });

@@ -238,2 +238,2 @@ "use strict";

}
exports.default = new Utilities();
exports.default = Utilities;

@@ -18,2 +18,3 @@ "use strict";

const apiRoutes = (systemConfig, app, auth, exchange, database, notifications, taapiClient, bot) => {
const utilities = new Utilities_1.default();
app.get(`/get-historical-trades`, auth, (req, res) => __awaiter(void 0, void 0, void 0, function* () {

@@ -33,3 +34,3 @@ let hoursBack = req.query.hoursBack || 10000;

trades = trades.map(trade => {
trade.direction = Utilities_1.default.getDirection(trade);
trade.direction = utilities.getDirection(trade);
let exitReason = trade.exitReason ? `, exit=${trade.exitReason}` : "";

@@ -43,11 +44,3 @@ return trade;

app.get(`/force-scan`, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
let exchangeId = req.query.exchangeId;
let interval = req.query.interval;
let errors = [];
if (!exchangeId) {
errors.push("Parameter 'exchangeId' is required!");
}
if (!interval) {
errors.push("Parameter 'interval' is required!");
}
let responseStatusCode = 200;

@@ -82,3 +75,3 @@ let responseData = {};

trades = trades.map(trade => {
trade.direction = Utilities_1.default.getDirection(trade);
trade.direction = utilities.getDirection(trade);
trade.profitGoal = Math.abs(Math.round((trade.targetPrice - trade.entryPrice) * 100 / trade.entryPrice * 100) / 100);

@@ -92,9 +85,6 @@ return trade;

app.post(`/create-trade`, auth, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
let exchangeId = req.body.exchangeId;
let exchangeId = req.body.exchangeId || systemConfig["exchange"]["id"];
let symbol = req.body.symbol;
let interval = req.body.interval;
let errors = [];
if (!exchangeId) {
errors.push("Parameter 'exchangeId' is required!");
}
if (!symbol) {

@@ -101,0 +91,0 @@ errors.push("Parameter 'symbol' is required!");

{
"name": "taapi-strategies",
"version": "1.1.5",
"version": "1.1.6",
"description": "A TAAPI.IO Strategies framework and helper package",

@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc