Skip to content

Instantly share code, notes, and snippets.

@tiagosiebler
tiagosiebler / okxWebsocketSNodejs.ts
Created November 18, 2024 14:32
Simple demo for connecting to OKX websockets in javascript/node.js
import { DefaultLogger, WebsocketClient } from 'okx-api';
// Optional: Inject a custom logger.
// This example overrides the default logger to also log "silly" (super verbose) messages, which are disabled by default
const logger = {
...DefaultLogger,
silly: (...params) => console.log('silly', ...params),
};
const wsClient = new WebsocketClient(
@tiagosiebler
tiagosiebler / _cleanup.sh
Last active November 11, 2024 11:49
Sorts a huge folder into sub folders, by file type
varName=./_sorted
if [ ! -d "$varName" ]; then
echo "Creating $varName";
mkdir "$varName";
fi
## array variable containing extensions
declare -a extensions=("dmg" "archives" "pdfs" "images" "php" "html" "js" "documents" "powerpoints" "excel" "java" "logs" "objc" "emails" "videos" "dbbackup")
declare -a images=("jpg" "JPG" "jpeg" "png" "PNG" "gif" "jpg" "svg" "webp")
@tiagosiebler
tiagosiebler / huskyConvCommits.sh
Created February 28, 2024 08:46
precommit hook for husky for conv commits
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
red=$(tput setaf 1) # ANSI escape code for red color
reset=$(tput sgr0) # ANSI escape code to reset color
#Commit message check
commit_msg=$(git log -1 --pretty=%B)
@tiagosiebler
tiagosiebler / bybit-change-symbol.ts
Last active March 20, 2023 13:05
unsub from BNB topics and sub to BTC events after delay
// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
// or
import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api';
const logger = {
...DefaultLogger,
silly: (...params) => console.log(new Date(), 'silly', ...params),
};
@tiagosiebler
tiagosiebler / bybit.ts
Created March 20, 2023 12:48
unsubscribe from topics on bybit sdk
// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
// or
import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api';
const logger = {
...DefaultLogger,
silly: (...params) => console.log(new Date(), 'silly', ...params),
};
@tiagosiebler
tiagosiebler / openShort.js
Last active February 14, 2023 19:32
Open a short position in node.js using binance APIs, on binance USDM futures
const client = new USDMClient({
api_key: 'apikeyhere',
api_secret: 'apisecrethere',
beautifyResponses: true,
});
async function start() {
try {
// if you don't have a position yet, and your account is set to one-way mode, just place a sell order to open a short position
const result = await client.submitNewOrder({
@tiagosiebler
tiagosiebler / psychologicalLine.js
Created January 31, 2023 00:09
a = SUM(CLOSE>REF(CLOSE,1),n)/n*100;
function psychologicalLine(candles, n) {
let sum = 0;
for (let i = 0; i < n; i++) {
if (candles[i].close > candles[i - 1].close) {
sum++;
}
}
return sum / n * 100;
}
@tiagosiebler
tiagosiebler / bands.pine
Created January 25, 2023 10:49
MATIC - no filter - bands
// © tsts123
//@version=5
indicator("Tiago / @AlgoTraderL : SR FVG Bands MATICUSDT")
l0h = hline(2.7, title="line0 4h s.l high", color=color.gray, linestyle=hline.style_solid)
l0l = hline(2.285, title="line0 4h s.l low", color=color.gray, linestyle=hline.style_solid)
fill(l0h, l0l, color=color.rgb(255, 156, 114, 79.75))
if (barstate.islast)
label.new(bar_index, 2.7, text="4h 81 % | #98", size=size.normal, style=label.style_label_right, color = color.rgb(0, 0, 0, 100), textcolor = color.white)
@tiagosiebler
tiagosiebler / bands.pine
Created January 25, 2023 10:48
xrpusdt >50% filter bands
// © tsts123
//@version=5
indicator("Tiago / @AlgoTraderL : SR FVG Bands XRPUSDT")
l0h = hline(1.18, title="line0 4h s.l high", color=color.gray, linestyle=hline.style_solid)
l0l = hline(1.048, title="line0 4h s.l low", color=color.gray, linestyle=hline.style_solid)
fill(l0h, l0l, color=color.rgb(255, 156, 114, 75))
if (barstate.islast)
label.new(bar_index, 1.18, text="4h 100 % | #389", size=size.normal, style=label.style_label_right, color = color.rgb(0, 0, 0, 100), textcolor = color.white)
@tiagosiebler
tiagosiebler / bands.pine
Created January 25, 2023 10:46
xrpusdt no filter bands
// © tsts123
//@version=5
indicator("Tiago / @AlgoTraderL : SR FVG Bands XRPUSDT")
l0h = hline(1.7287, title="line0 2h s.l high", color=color.gray, linestyle=hline.style_solid)
l0l = hline(1.6058, title="line0 2h s.l low", color=color.gray, linestyle=hline.style_solid)
fill(l0h, l0l, color=color.rgb(255, 156, 114, 98))
if (barstate.islast)
label.new(bar_index, 1.7287, text="2h 8 % | #21", size=size.normal, style=label.style_label_right, color = color.rgb(0, 0, 0, 100), textcolor = color.white)