Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
public class Book
{
public string Region { get; set; }
public double AUM { get; set; }
}
@normanlmfung
normanlmfung / json
Created March 28, 2024 05:03
csharp_json_orderbook_data
{
"Pairs": {
"BTCUSD": {
"Bids": [45000.0, 44990.0, 44980.0, 44970.0, 44960.0, 44950.0, 44940.0, 44930.0, 44920.0, 44910.0, 44900.0, 44890.0, 44880.0, 44870.0, 44860.0, 44850.0, 44840.0, 44830.0, 44820.0, 44810.0, 44800.0, 44790.0, 44780.0, 44770.0, 44760.0, 44750.0, 44740.0, 44730.0, 44720.0, 44710.0, 44700.0, 44690.0, 44680.0, 44670.0, 44660.0, 44650.0, 44640.0, 44630.0, 44620.0, 44610.0, 44600.0, 44590.0, 44580.0, 44570.0, 44560.0, 44550.0, 44540.0, 44530.0, 44520.0, 44510.0],
"Asks": [45100.0, 45110.0, 45120.0, 45130.0, 45140.0, 45150.0, 45160.0, 45170.0, 45180.0, 45190.0, 45200.0, 45210.0, 45220.0, 45230.0, 45240.0, 45250.0, 45260.0, 45270.0, 45280.0, 45290.0, 45300.0, 45310.0, 45320.0, 45330.0, 45340.0, 45350.0, 45360.0, 45370.0, 45380.0, 45390.0, 45400.0, 45410.0, 45420.0, 45430.0, 45440.0, 45450.0, 45460.0, 45470.0, 45480.0, 45490.0, 45500.0, 45510.0, 45520.0, 45530.0, 45540.0, 45550.0, 45560.0, 45570.0, 45580.0, 45590.0, 45600.0]
},
"ETHUSD": {
"Bids": [3
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json; // dotnet add package Newtonsoft.Json
class Program
{
static void Main(string[] args)
{
// Read JSON order book from file
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
public delegate void MessageArrivedHandler(string message);
class Publisher
{
private event MessageArrivedHandler _messageArrived = delegate {};
using System.Net;
class Program {
static async Task Main(string[] args)
{
// Example 1. await-foreach
static async IAsyncEnumerable<int> YieldReturnNumbers(List<int> numbers)
{
foreach (int number in numbers)
{
await Task.Delay(1000);
using System;
using System.Security.Cryptography;
using System.Text;
class Program
{
static void Main()
{
// Define a password, salt, and iteration count for key derivation
string password = "ThisIsAStrongPassword";
@normanlmfung
normanlmfung / gist:22e7c7a4bdfdc951f06b8441ef0acfb7
Last active September 26, 2023 20:32
Crypto Market Making scans for opportunities
from datetime import datetime
import time
from itertools import combinations
import pandas as pd
from ccxt import bybit
from ccxt import okx
from ccxt import gateio
CANDIDATE_FILE_NAME = "mm_candidates.csv"
import time
from web3 import Web3
from dydx3 import Client
from dydx3.constants import API_HOST_MAINNET
from dydx3.constants import NETWORK_ID_MAINNET
from dydx3.constants import MARKET_BTC_USD
from dydx3.constants import ORDER_SIDE_BUY
from dydx3.constants import ORDER_TYPE_LIMIT
WEB_PROVIDER_URL = 'https://mainnet.infura.io/v3/????????????????????????????'
@normanlmfung
normanlmfung / gist:8a49197fdd26d4a5b145f409f116dcc4
Created November 16, 2022 05:11
aptos query transactions under given wallets
import time
import json
import requests
from datetime import datetime
# https://fullnode.mainnet.aptoslabs.com/v1/spec#/operations/get_account_transactions
all_transactions = []
for wallet in wallets:
try:
url = f"https://fullnode.mainnet.aptoslabs.com/v1/accounts/{wallet.address()}/transactions"
D:\dev\samples\py>pypy -mpip install aptos_sdk
Defaulting to user installation because normal site-packages is not writeable
Collecting aptos_sdk
Using cached aptos_sdk-0.4.1-py3-none-any.whl (18 kB)
Collecting httpx
Using cached httpx-0.23.0-py3-none-any.whl (84 kB)
Collecting pynacl
Using cached PyNaCl-1.5.0.tar.gz (3.4 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done