Skip to content

Instantly share code, notes, and snippets.

View nguyenhieuec's full-sized avatar

m_fx nguyenhieuec

  • Viet Nam
View GitHub Profile

Adding 4swap to CCXT

This is the first time we’re integrating an exchange on the Mixin network into CCXT, but the process is actually more straightforward than expected.

Overview

CCXT started as an SDK to simplify connecting to various centralized exchanges. However, with the recent addition of Hyperliquid—a decentralized exchange on an EVM network—CCXT is expanding its reach, paving the way for more DEX integrations across different networks.

To add a new exchange to CCXT, we create a file under /ts/src/ named [exchange-name].ts. This file defines the methods available when initializing an instance of the exchange. It inherits the base class in /ts/src/base/Exchange.ts, which contains all possible methods for an exchange. We implement only the necessary ones for the new exchange in the new file.

@nguyenhieuec
nguyenhieuec / arbitrage.py
Created October 5, 2023 15:55 — forked from noxx3xxon/arbitrage.py
CFMM Routing Arbitrage Example
import numpy as np
import cvxpy as cp
import itertools
# Problem data
global_indices = list(range(4))
# 0 = TOKEN-0
# 1 = TOKEN-1
# 2 = TOKEN-2
@nguyenhieuec
nguyenhieuec / gist:a99580963c26ef9156d97437be1628d8
Created November 21, 2022 09:58 — forked from jagregory/gist:710671
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork [email protected]
# https://www.quantopian.com/posts/technical-analysis-indicators-without-talib-code
import numpy
import pandas as pd
import math as m
#Moving Average
def MA(df, n):
MA = pd.Series(pd.rolling_mean(df['Close'], n), name = 'MA_' + str(n))
df = df.join(MA)
curl 'https://finance.vietstock.vn/derivatives/cwtradinginfo' \
-X 'POST' \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'Accept: */*' \
-H 'Accept-Language: en-us' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Host: finance.vietstock.vn' \
-H 'Origin: https://finance.vietstock.vn' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15' \
-H 'Connection: keep-alive' \
@nguyenhieuec
nguyenhieuec / faster_toPandas.py
Created November 13, 2020 05:37 — forked from joshlk/faster_toPandas.py
PySpark faster toPandas using mapPartitions
import pandas as pd
def _map_to_pandas(rdds):
""" Needs to be here due to pickling issues """
return [pd.DataFrame(list(rdds))]
def toPandas(df, n_partitions=None):
"""
Returns the contents of `df` as a local `pandas.DataFrame` in a speedy fashion. The DataFrame is
repartitioned if `n_partitions` is passed.
@nguyenhieuec
nguyenhieuec / make_gdrive_index.py
Created August 9, 2020 04:42 — forked from cmungall/make_gdrive_index.py
Generate HTML index of a synced google drive folder. For me this is faster to search and navigate than the clunky slow google web interface. Pretty hacky code but it works for me
#!/usr/bin/env python3
import os
import re
import logging
import click
# don't index these
excludes = {
'single_files',
'Icon',
@nguyenhieuec
nguyenhieuec / hashingsomecol.py
Created July 10, 2020 11:36
Create a hash column in pandas elegent way
df['hash'] = (
(df['col1'].astype(str) + df['col2'].astype(str) + df['col3'].astype(str))
.pipe(pd.util.hash_pandas_object)
)
@nguyenhieuec
nguyenhieuec / query_builder.py
Created June 5, 2020 03:52 — forked from richiefrost/query_builder.py
Simple use of the builder pattern to create a SQL query generator
class QueryBuilder:
def __init__(self):
self.select_value = ''
self.from_table_name = ''
self.where_value = ''
self.groupby_value = ''
def select(self, select_arg):
self.select_value = select_arg
return self
import requests
from bs4 import BeautifulSoup
page = requests.get('https://tiki.vn/dien-thoai-may-tinh-bang/c1789?src=c.1789.hamburger_menu_fly_out_banner&_lc=Vk4wMjMwMDcwMTA=')
soup = BeautifulSoup(page.text, 'html.parser')
with open("tiki_page.html", mode='w') as f:
f.write(soup.prettify())
rating = soup.findAll('p', {"class": "rating"})
for p in rating: