Skip to content

Instantly share code, notes, and snippets.

@normanlmfung
normanlmfung / csv
Created April 25, 2024 05:04
BTCUSDT_candles_2021-01-01-00-00-00_2024-04-24-00-00-00_1d.csv
,exchange,symbol,timestamp_ms,open,high,low,close,volume,is_dummy,datetime_utc,datetime,year,month,day,datetime_diff_sec,hour,minute,candle_height,pct_change_close,ema_short_periods,ema_long_periods,ema_close,std,h_l,h_pc,l_pc,tr,atr,hurst_exp,boillenger_upper,boillenger_lower,close_delta,up,down,rsi,macd,signal,macd_minus_signal,ema_short_slope,ema_long_slope,gap_close_vs_ema,close_above_or_below_ema,close_vs_ema_inflection
1,okx_linear,BTC/USDT:USDT,1609459200000.0,28914.2,29637.8,28620.0,29333.6,2520243.0,False,2021-01-01,2021-01-01 08:00:00,2021,1,1,28800.0,8,0,1017.7999999999993,,29333.6,29333.6,29333.6,,1017.7999999999993,,,1017.7999999999993,,,,,,,,,0.0,0.0,0.0,,,0.0,,0.0
2,okx_linear,BTC/USDT:USDT,1609545600000.0,29329.9,33367.9,28953.1,32166.9,5881082.0,False,2021-01-02,2021-01-02 08:00:00,2021,1,2,86400.0,8,0,4414.800000000003,9.658889464641241,29551.546153846157,29408.160526315787,29408.160526315787,,4414.800000000003,4034.300000000003,380.5,4414.800000000003,,,,,2833.300000000003,2833.300000000003
import os
import sys
import json
from datetime import datetime
import logging
import arrow
from typing import Dict, List
import enum
import math
import pandas as pd
@normanlmfung
normanlmfung / gist:3ac0f0d66f1a3fca34a2839b03a28cc3
Created April 1, 2024 22:39
csharp_thread_start_processor_affinity
// https://stackoverflow.com/questions/2510593/how-can-i-set-processor-affinity-to-a-thread-or-a-task-in-net
using System;
using System.Diagnostics;
using System.Threading;
static void Fibonacci(int n)
{
int a = 0, b = 1, c = 0;
for (int i = 0; i < n; i++)
{
using Newtonsoft.Json;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
/*
@normanlmfung
normanlmfung / txt
Created April 1, 2024 04:21
dotnet commands
List the kind of applications you can create:
dotnet new list
To create a new 'console' app (.NET Core Console):
dotnet new console --framework net6.0 -n CSharpDotnetCoreConsole
To create a new 'webapi' project (Not 'webapp', please note):
dotnet new webapi --framework net6.0 -n Commander
To install packages from command prompt:
@normanlmfung
normanlmfung / gist:4d879722685e497226a0e50f28deaf61
Created April 1, 2024 04:16
python_syntax_regular_expression
import re
def main():
# Email validation
email_address = "[email protected]"
email_pattern = r'^\w+@[a-zA-Z_]+\.[a-zA-Z]{2,3}$'
if re.match(email_pattern, email_address):
print("Valid email address.")
else:
import aiohttp
import asyncio
'''
OKX API
OKX REST API addresses:
REST: https://www.okx.com/
Public WebSocket: wss://ws.okx.com:8443/ws/v5/public
Private WebSocket: wss://ws.okx.com:8443/ws/v5/private
@normanlmfung
normanlmfung / gist:b4a0354d3f8fcba440d9b3716f407be0
Last active May 9, 2024 07:34
python_syntax_ws_pinned_memory
import asyncio
import json
import struct
from websockets import connect
'''
https://gist.github.com/normanlmfung/b4a0354d3f8fcba440d9b3716f407be0
OKX API
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
/*
'AllocateMemory' will allocate byte[] pinned in memory. You'd only do this ONCE. Pinned memory will not be garbage collected, reducing performance impact from GC.
@normanlmfung
normanlmfung / gist:d36d43129437fd34fbd86d193517e5fb
Last active March 30, 2024 23:14
python_syntax_asyncio_blocking_task
import asyncio
import threading
from datetime import datetime
'''
https://stackoverflow.com/questions/76856816/python-how-to-create-cpu-load-that-block-asyncio-event-loop?noredirect=1#comment135492684_76856816
'''
def log(msg):
print(f"{datetime.now()} {msg}")