Skip to content

Instantly share code, notes, and snippets.

@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)
@tiagosiebler
tiagosiebler / build.ts
Created November 16, 2022 11:58
CURL from axios options request
function buildCurlRequest(options: AxiosRequestConfig): string {
let curlQuery = '';
curlQuery += `curl --location --request ${options.method} '${options.url}'`;
for (const header in options.headers) {
curlQuery += `\\\n --header '${header}: ${options.headers[header]}'`;
}
return curlQuery;
}
import { createMachine, interpret, Interpreter, State } from 'xstate';
export function sleep(timeoutMS: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, timeoutMS));
}
type StopLossService = Interpreter<unknown>;
type StopLossState = 'none' | 'active' | 'breakeven' | 'trailing';
type StopLossStateEvents = 'SET_SL' | 'SET_BREAKEVEN' | 'SET_TRAILING' | 'RESET';