Skip to content

Commit

Permalink
Constrain buys and sells more
Browse files Browse the repository at this point in the history
  • Loading branch information
djkazic committed Nov 10, 2023
1 parent 34a3390 commit 00ac98e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async function loadModules() {
runningPositions.forEach((position) => {
if (position.side === "s") {
totalSellExposure += position.quantity;
if (position.pl > 11) {
if (position.pl > 14) {
logger(
"finance-profit",
`CLOSING SHORT POSITION ${JSON.stringify(position)}`
Expand All @@ -276,7 +276,7 @@ async function loadModules() {
}
} else if (position.side === "b") {
totalBuyExposure += position.quantity;
if (position.pl > 11) {
if (position.pl > 14) {
logger(
"finance-profit",
`CLOSING LONG POSITION ${JSON.stringify(position)}`
Expand Down Expand Up @@ -327,7 +327,7 @@ async function loadModules() {
logger("error", `Fetching positions failed: ${JSON.stringify(error)}`);
logger(error.stack);
}
logger("info", `Last tick direction: ${lastTickDirection}`);
logger("info", `Last tick direction: ${lastTickDirection}, price ${lastPrice}`);
try {
let action = "none";
let rsi = await fetchRSI("15m");
Expand Down Expand Up @@ -377,7 +377,8 @@ async function loadModules() {
// Check for sell conditions
if (
rsi.value >= adjustedSellRsiThreshold &&
lastPrice > sellPriceThreshold
lastPrice > sellPriceThreshold &&
lastTickDirection === "PlusTick" || lastTickDirection === "ZeroPlusTick"
) {
action = "sell";
logger(
Expand All @@ -393,7 +394,8 @@ async function loadModules() {
sendTelegramMessage(`Shorted on LNM at ${lastPrice}`);
} else if (
rsi.value <= adjustedBuyRsiThreshold &&
lastPrice < buyPriceThreshold
lastPrice < buyPriceThreshold &&
lastTickDirection === "MinusTick" || lastTickDirection === "ZeroMinusTick"
) {
action = "buy";
logger(
Expand Down

0 comments on commit 00ac98e

Please sign in to comment.