Skip to content

Instantly share code, notes, and snippets.

View kangchihlun's full-sized avatar
🦽
日拱一卒,功不唐捐

kang chih lun kangchihlun

🦽
日拱一卒,功不唐捐
View GitHub Profile
@kangchihlun
kangchihlun / TaiwanConsensusBuilder.sol
Created January 6, 2019 06:31
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.2+commit.1df8f40c.js&optimize=false&gist=
pragma solidity ^0.5.2;
contract TaiwanConsensusBuilder {
address public contractOwner;
//==================================
// Modifiers (Safety Checks)
//==================================
modifier ownerOnly {
@kangchihlun
kangchihlun / 101Alpha_code_1.py
Last active September 20, 2024 11:18
101Alpha_code_1.py
import numpy as np
import pandas as pd
from numpy import abs
from numpy import log
from numpy import sign
from scipy.stats import rankdata
# region Auxiliary functions
def ts_sum(df, window=10):
"""
@kangchihlun
kangchihlun / 101Alpha_code_2.py
Last active March 18, 2021 01:29
101Alpha_code_2.py
import pandas as pd
import numpy as np
from scipy import stats
def make_factors():
# (rank(Ts_ArgMax(SignedPower(((returns < 0) ? stddev(returns, 20) : close), 2.), 5)) - 0.5)
class Alpha1(CustomFactor):
inputs = [USEquityPricing.close, Returns(window_length=2)]
@kangchihlun
kangchihlun / GTJA_Alpha191.py
Created April 3, 2019 23:58
GTJA_Alpha191.py
from scipy.stats import rankdata
import scipy as sp
import numpy as np
import pandas as pd
class GTJA_191:
def __init__(self, end_date, index):
security = get_index_stocks(index)
static void Main(string[] args)
{
// getMostVisited(10, new List<int>() { 1, 5 ,10,3});
longestPalindrome(7, "bandana");
}
public static int getMostVisited(int n, List<int> sprints)
{
int ret = -1;
if (sprints.Count < 1)
return ret;
import asyncio
import aiohttp
async def get_html(session, url):
async with session.get(url) as res:
return await res.text()
async def main():
urls = [
'http://python.org',
@kangchihlun
kangchihlun / asyncio queue demo trading demo.py
Last active March 21, 2021 22:07
asyncio queue demo (can be used in calc trading signal)
# asyncq.py
import asyncio
import itertools as it
import os
import random
import time
async def makeitem(size: int = 5) -> str:
return os.urandom(size).hex()
@kangchihlun
kangchihlun / usdt_erc20_transfer_demo.js
Last active September 16, 2024 15:54
usdt(erc20) transfer demo
// Created by Chih.Lun.Kang
// 網路上找的範例大部分都不能用,後來嘗試數次只有這方法可行
// 主網的appid => 539ab33xxxx,要去Infura申請,在上面建立一個project
// #### NOTE #### : 要特別注意本身轉帳的帳號要儲備足夠數量的 eth 跟 btc
// #### 注意 #### : 目前使用人工轉換儲值手續費,建議在幣價好的時候一次換匯才划算
const USDTJSON = require('./build/contracts/USDT.json')
const Web3 = require('web3')
const Tx = require('ethereumjs-tx').Transaction
import ccxt
import pandas as pd
import time
pd.set_option('expand_frame_repr', False)
def main():
"""
主函数
@kangchihlun
kangchihlun / sup_pres_calculator.js
Created September 25, 2021 21:43
支撐壓力線計算-使用 Volume Profile 找過去一日一分鐘最大量區-10跳間隔
const okex_api = require('../../libs/okex-api')
const constant = require('../../libs/constants')
const request = require('request')
const numgrid = 100
var marketinfo = {}
const fetch_market_info = async () => {
let _mkt = await okex_api.fetch_perp_symbols(mode='all')
_mkt.forEach((inst) => {
marketinfo[inst.instrument_id] = inst