Skip to content

Instantly share code, notes, and snippets.

View tubackkhoa's full-sized avatar
💭
buidl

Pham Thanh Tu tubackkhoa

💭
buidl
View GitHub Profile
@tubackkhoa
tubackkhoa / market-maker.md
Created October 30, 2025 08:54
Trading Notes

Chương 1: Quản Lý Tiền Bạc Để Thành Công Trong Giao Dịch Ngày (Managing Money to Succeed as a Day Trader)

  • Kiểm soát rủi ro là nền tảng: Kết quả giao dịch không kiểm soát được, nhưng mức lỗ thì có; sống sót qua kỷ luật để học hỏi.
  • Vị thế quá lớn gây hại: Gây mất lớn, cảm xúc mạnh (tham lam/sợ hãi); cắt lợi nhuận sớm, giữ lỗ lâu; rủi ro 50-100% vốn một lệnh = cờ bạc, không phải giao dịch.
  • Chỉ giao dịch tiền có thể mất: Không phụ thuộc vào thắng để sống; mất hết = không sao; giảm gắn bó cảm xúc, tăng khách quan.
  • Nhỏ hơn = lớn hơn: Vị thế nhỏ giúp cắt lỗ nhanh, phục hồi dễ; vị thế lớn cần lợi nhuận cao hơn để bù phí, thời gian.
  • Điều chỉnh vị thế cân bằng: Dựa giá cổ phiếu (ví dụ: 1 điểm ở $10 = 10%, ở $100 = 1%); vị thế tỷ lệ nghịch với giá để rủi ro % bằng nhau.
  • Quy tắc 2%: Mất tối đa 2% vốn/lệnh (bao gồm phí); lỗ 6-8% tháng = dừng, đánh giá; dùng để bảo hiểm, tăng cơ hội chơi lâu dài.
  • Biên (margin): Tăng đòn bẩy nhưng rủi ro cao (ví dụ: LTCM phá sản 1997 do 20:
/**
* DuckDB HTTPServer wrapper (NDJSON parser)
* Supports Basic Auth + API Key
*
* Example server:
* curl -u user:pass -H "X-API-Key: secretkey" \
* "http://localhost:9999?query=select * from transactions limit 2"
*/
export type RowData = Record<string, any>;
// save as extract-urls.ts
// Usage: node extract-urls.ts <extension_id> <version>
import fs from 'fs';
import path from 'path';
import AdmZip from 'adm-zip';
// Known genesis hashes
const clusters = {
mainnet: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
testnet: '4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IUniswapV2Factory {
function createPair(
address tokenA,
address tokenB
import http from 'http';
import httpProxy from 'http-proxy';
const items = Object.values({
'jup.ag': 'https://jupiter-frontend.rpcpool.com',
'pump.fun':
'https://pump-fe.helius-rpc.com/?api-key=1b8db865-a5a1-4535-9aec-01061440523b',
'raydium.io': 'https://raydium-raydium-5ad5.mainnet.rpcpool.com',
});
let currentInd = 0;
import puppeteer, { Browser, Page } from 'puppeteer';
class Crawler {
private browser: Browser;
constructor(private readonly userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36') {}
async init() {
// Launch the browser and open a new blank page
this.browser = await puppeteer.launch({ headless: true });
}
@tubackkhoa
tubackkhoa / convert.js
Created June 18, 2024 09:46
convert snake case to camel
const { readdirSync, readFileSync, writeFileSync } = require('fs');
const { join } = require('path');
function walk(dir, ext = '.rs') {
return readdirSync(dir, { withFileTypes: true })
.flatMap((file) => (file.isDirectory() ? walk(join(dir, file.name), ext) : file.name.endsWith(ext) ? join(dir, file.name) : null))
.filter(Boolean);
}
const reg = /(?<=#\[wasm_bindgen)\]([\n\t\s])+(?=pub\s+fn\s+([\w_]+)\()/g;
import { toUtf8, fromBech32, toAscii, toBech32 } from '@cosmjs/encoding';
import { sha256 } from '@cosmjs/crypto';
import { Uint64 } from '@cosmjs/math';
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate';
function increaseBytes(bytes: Uint8Array) {
for (let i = bytes.length - 1; i >= 0; --i) {
if (bytes[i] === 255) {
bytes[i] = 0;
} else {
import { Registry, decodeTxRaw } from '@cosmjs/proto-signing';
import { TextProposal } from 'cosmjs-types/cosmos/gov/v1beta1/gov';
import { fromAscii } from '@cosmjs/encoding';
import {
defaultRegistryTypes as defaultStargateTypes,
Event,
logs,
StargateClient,
} from '@cosmjs/stargate';
import { JsonObject, fromBinary, wasmTypes } from '@cosmjs/cosmwasm-stargate';