This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const signSecret = process.env.SLACK_SIGN_SECRET; | |
const validateRequest = (requestSignature, requestTime, rawBody, validFor = 300) => { | |
const requestValidFrom = Math.floor(Date.now() / 1000) - validFor; | |
if (requestTime < requestValidFrom) { | |
throw new Error(`Request outdated: !(${requestTime} < ${requestValidFrom})`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// © 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// © 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// © 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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), | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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), | |
}; |