Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from calumrussell:main #31

Merged
merged 100 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
3a19b89
Update derive_more requirement from 0.99.17 to 1.0.0
dependabot[bot] Aug 12, 2024
2724177
Update zip requirement from 0.6.2 to 2.2.0
dependabot[bot] Aug 26, 2024
947abe5
convert between hyperliquid source and athena
Aug 29, 2024
52d24ec
tidy
Aug 29, 2024
2d95c12
make server submodule in http/uist_v2 public
Aug 29, 2024
34b5f60
add uist_server_v2 binary
Aug 29, 2024
8e45512
fmt
Aug 29, 2024
af8fc37
Merge pull request #95 from calumrussell/hyperliquid-binary-from-file
calumrussell Sep 5, 2024
35455de
add http client for snek
Sep 5, 2024
e393eb3
clean up broker, using http
Sep 5, 2024
149ef39
added test client for http client
Sep 6, 2024
5239d34
Merge pull request #98 from calumrussell/97-add-http-client-to-snek
calumrussell Sep 8, 2024
b9566b2
Merge pull request #94 from calumrussell/dependabot/cargo/zip-2.2.0
calumrussell Sep 8, 2024
81ae00b
add features flag to Cargo.toml
Sep 8, 2024
64e80d2
Merge pull request #93 from calumrussell/dependabot/cargo/derive_more…
calumrussell Sep 8, 2024
e1bed6c
backtest_id stored in HttpClient rather than Broker, updated HttpTest…
Sep 8, 2024
b772275
basic Broker impl with BrokerBuilder and Order struct
Sep 8, 2024
04c6360
insert_order, tick Broker impl
Sep 8, 2024
e3c0013
can remove test client impl now
Sep 8, 2024
2d3421b
test of main loop
Sep 8, 2024
414fa44
fix fetch_quotes unpacking
Sep 12, 2024
939231a
new main file
Sep 12, 2024
5702f69
uist v2 now returns BBO rather than Depth
Sep 12, 2024
a6c13d4
bug fix, add tracking for value
Sep 14, 2024
7ff15c9
Merge pull request #99 from calumrussell/97-implement-portfolio-tracking
calumrussell Sep 14, 2024
4404dcd
Merge pull request #100 from calumrussell/97-implement-portfolio-trac…
calumrussell Sep 14, 2024
44eb57a
basic functionality working
calumrussell Sep 28, 2024
bfd95f3
Merge pull request #101 from calumrussell/97-pull-hl-data
calumrussell Sep 28, 2024
ae9830a
improvements
calumrussell Sep 29, 2024
0d5e997
bug fix
calumrussell Sep 29, 2024
19f76aa
now writes into month files
calumrussell Sep 29, 2024
d4b2025
Merge pull request #102 from calumrussell/97-pull-h1-data-bugfix
calumrussell Sep 29, 2024
2af358a
hyperliquid data pull operates over dir/{coin}
calumrussell Sep 29, 2024
001e755
fmt
calumrussell Sep 29, 2024
251dcdf
Merge pull request #103 from calumrussell/97-uistv2-operates-on-dir
calumrussell Sep 29, 2024
5aa6af1
rename example_clients
calumrussell Oct 27, 2024
98ab1d4
rework file structure, rename
calumrussell Oct 27, 2024
46b4a54
cleaning deps
calumrussell Oct 27, 2024
d60a0b9
remove unneeded benchmark
calumrussell Oct 27, 2024
3913b59
move test client into client crate, removed unneeded tests from perf
calumrussell Oct 27, 2024
7383bd7
clippy
calumrussell Oct 27, 2024
ff3c7ba
Merge pull request #104 from calumrussell/general-tidy
calumrussell Oct 27, 2024
55575c2
remove jura
calumrussell Oct 27, 2024
cccf3ac
remove trailing ref
calumrussell Oct 27, 2024
bd1ac9a
Merge pull request #105 from calumrussell/remove-hyperliquid
calumrussell Oct 27, 2024
a621fdc
delete deep nesting project, add logging, fix logic bugs
calumrussell Oct 27, 2024
587a049
a few more checks
calumrussell Oct 27, 2024
7e4b71a
finish immediately
calumrussell Oct 27, 2024
ab9e556
Merge pull request #107 from calumrussell/106-refine-python
calumrussell Oct 27, 2024
5ca490f
added InnerOrder struct for uistv2, passing this back to clients
calumrussell Oct 27, 2024
335ad45
added test case covering oid unique/incrementing within orderbook
calumrussell Oct 27, 2024
9cdd0d4
failing test case showing that executed orders aren't cleared from or…
calumrussell Oct 27, 2024
036af6d
fixed bug in exchange where orderbook wasn't flushing executed orders
calumrussell Oct 27, 2024
33cfc5a
fixing order validation logic in python client
calumrussell Oct 27, 2024
7cb563e
python client removed order log and replaced with order inserted on l…
calumrussell Oct 27, 2024
4519ad8
added order id to trade
calumrussell Oct 29, 2024
ab7efb3
add order id to trade struct, adds order tracking to broker
calumrussell Oct 29, 2024
5490d53
fix for enum creation from json
calumrussell Oct 29, 2024
a075429
Merge pull request #108 from calumrussell/106-adding-orderid-uistv2
calumrussell Oct 30, 2024
0b3c5fb
refactored DateQuotes to DateDepth
calumrussell Oct 30, 2024
f7ae676
added new fetch_depth to http
calumrussell Oct 30, 2024
17672cd
added new fetch_depth to client
calumrussell Oct 30, 2024
df5a30e
add new route to binary
calumrussell Oct 30, 2024
b16c455
add fetch_depth to python client loop and http client
calumrussell Oct 30, 2024
aa29f75
add depth tracker to python client example
calumrussell Oct 30, 2024
915c52c
Merge pull request #109 from calumrussell/106-return-depth-from-uistv2
calumrussell Oct 30, 2024
25f2b04
added anyhow
calumrussell Oct 30, 2024
3f696d6
added modify/cancel order to orderbook, testing, error conditions
calumrussell Oct 30, 2024
9b855d6
modify/cancel order added to exchange executing immediately
calumrussell Oct 30, 2024
a150ab0
order modification enum created, buffer to hold these events
calumrussell Oct 30, 2024
866632c
order modifications stored on the exchange and run after insertion
calumrussell Oct 30, 2024
37ea320
add cancel and modify to http
calumrussell Nov 1, 2024
458bb92
added to client
calumrussell Nov 1, 2024
a33dfd3
add routes to binary
calumrussell Nov 1, 2024
3dec0c1
clippy
calumrussell Nov 1, 2024
5b12b84
added modify and cancel to python client
calumrussell Nov 1, 2024
7aa6953
tick returns modified orders
calumrussell Nov 1, 2024
aa06d78
return modified orders through http/client
calumrussell Nov 1, 2024
607f27a
clippy
calumrussell Nov 1, 2024
1bb95be
Merge pull request #110 from calumrussell/106-implement-cancel-modify
calumrussell Nov 1, 2024
aae8840
implement very basic grid
calumrussell Nov 2, 2024
b9c617b
Merge pull request #113 from calumrussell/106-more-complex-grid-strategy
calumrussell Nov 2, 2024
3c9086f
111 fetch quotes depth removal (#115)
calumrussell Nov 2, 2024
bfb9b81
111 consolidate modification into order (#116)
calumrussell Nov 3, 2024
0b8ed28
111 insert groups orders (#117)
calumrussell Nov 6, 2024
a706a4d
111 removing mutex from http (#118)
calumrussell Nov 8, 2024
a029b80
111 http perf python fix (#119)
calumrussell Nov 9, 2024
8155aa6
impl basic db connection (#120)
calumrussell Nov 11, 2024
dae324a
112 no position by position (#121)
calumrussell Nov 14, 2024
c51f413
112 tick returns time (#122)
calumrussell Nov 14, 2024
1a5fd6d
112 tick returns time (#124)
calumrussell Nov 27, 2024
bed6746
112 exchange logic includes trades (#126)
calumrussell Dec 7, 2024
407827e
Update pyo3 requirement from 0.22.1 to 0.23.2 (#125)
dependabot[bot] Dec 7, 2024
1d65eba
112 last fixes (#128)
calumrussell Dec 24, 2024
57eb1a5
Update env_logger requirement from 0.10.0 to 0.11.6 (#127)
dependabot[bot] Dec 24, 2024
1f3407b
Fixes bug when lifting multiple levels and in Minerva depth dataset (…
calumrussell Dec 29, 2024
d10ff55
Adding support for multiple exchanges (#130)
calumrussell Dec 29, 2024
c2a5f2c
Add docker for uist_server_v2 (#131)
calumrussell Dec 29, 2024
27b3a08
http returns taker_trades as flat list (#132)
calumrussell Jan 1, 2025
9b431c9
fix (#133)
calumrussell Jan 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
*.csv
/.vscode
Cargo.lock
data/venv/
rotala-python/venv/
test_data/
*__pycache__*
.env
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[workspace]

resolver = "2"
members = [
"rotala",
"example_clients/alator"
]
members = ["rotala", "rotala-client", "rotala-http"]
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM rust:1.83-bullseye

COPY . .

RUN cargo build --release
92 changes: 92 additions & 0 deletions data/hl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import argparse
import os
import boto3
from botocore import UNSIGNED
from botocore.config import Config
import lz4framed
import datetime


def path_builder(date, hour, coin):
return f"market_data/{date}/{hour}/l2Book/{coin}.lz4"


def parse_date(string):
return (string[0:4], string[4:6])


def zero_padding(number):
if number < 10:
return "0" + str(number)
return str(number)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="HL Data Fetcher",
description="Downloads data from HL, unzips and places into directory",
)

parser.add_argument("-o", "--outdir")
parser.add_argument("-c", "--coin")
parser.add_argument("-s", "--start")

args = parser.parse_args()

max_year = 2024
hours = list(range(0, 24))
days = list(range(1, 32))
months = list(range(1, 13))
client = boto3.client("s3", config=Config(signature_version=UNSIGNED))
bucket_name = "hyperliquid-archive"
now = datetime.datetime.now()

os.makedirs(f"{args.outdir}/{args.coin}", exist_ok=True)

(start_year, start_month) = parse_date(args.start)
for year in range(int(start_year), max_year + 1):
iter_start = int(start_month) if int(year) == int(start_year) else 1

for month in range(iter_start, 13):
chunks = []
file_path = f"{args.outdir}/{args.coin}/{month}"
if os.path.exists(file_path):
continue

for day in days:
try:
then = datetime.datetime(year, month, day)
except ValueError:
# Occurs if date isn't valid
continue

if then > now:
print("Reached the present")
print(file_path)
with open(f"{file_path}", "w") as f:
for chunk in chunks:
f.write(chunk)
exit(1)

for hour in hours:
date_string = str(year) + zero_padding(month) + zero_padding(day)
key = path_builder(date_string, hour, args.coin)

try:
response = client.get_object(
Bucket=bucket_name,
Key=key,
)
contents = response["Body"].read()
except Exception:
print(f"Didn't find - {key}")
continue

uncompressed = lz4framed.decompress(contents)
print(f"Took - {key}")
chunks.append(uncompressed.decode("utf-8"))

print(file_path)
with open(f"{file_path}", "w") as f:
for chunk in chunks:
f.write(chunk)
2 changes: 2 additions & 0 deletions data/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
boto3==1.35.29
py-lz4framed==0.14.0
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.9'

services:

uist_v2:
build: .
ports:
- 0.0.0.0:3000:${PORT}
command: cargo run --bin uist_server_v2 0.0.0.0 ${PORT} ${DB_HOST} ${DB_USER} ${DB_PWD} ${DB_NAME
73 changes: 0 additions & 73 deletions example_clients/alator/benches/sim_benchmark.rs

This file was deleted.

2 changes: 0 additions & 2 deletions example_clients/snek/.gitignore

This file was deleted.

65 changes: 0 additions & 65 deletions example_clients/snek/src/broker.py

This file was deleted.

44 changes: 0 additions & 44 deletions example_clients/snek/src/main.py

This file was deleted.

File renamed without changes.
24 changes: 11 additions & 13 deletions example_clients/alator/Cargo.toml → rotala-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "alator"
name = "rotala-client"
version = "0.4.1"
authors = ["Calum Russell <[email protected]>"]
edition = "2021"
Expand All @@ -14,22 +14,20 @@ time = { version = "0.3.17", features = ["macros", "parsing"] }
rand = "0.8.4"
rand_distr = "0.4.1"
log = "0.4.17"
env_logger = "0.11.0"
pyo3 = { version = "0.22.1", optional = true }
async-trait = "0.1.73"
pyo3 = { version = "0.23.2", optional = true }
tokio = { version = "1.32.0", features = ["full"] }
futures = "0.3.28"
rotala = { path = "../../rotala/" }
rotala = { path = "../rotala/" }
rotala-http = { path = "../rotala-http/" }
anyhow = "1.0.86"
reqwest = { version = "0.12.5", features = ["blocking", "json"] }
env_logger = "0.11.5"

[dev-dependencies]
reqwest = { version = "0.12.5", features = ["blocking"] }
zip = "0.6.2"
zip = "2.2.0"
csv = "1.1.6"
criterion = { version = "0.5.1", features = ["async_tokio"] }

[lib]
bench = false

[[bench]]
name = "sim_benchmark"
harness = false
[[bin]]
name = "uist_client_test"
path = "./src/bin/uist_client_test.rs"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::io::Result;

use rotala::exchange::uist_v1::Order;
use rotala::http::uist_v1::{Client, HttpClient};
use rotala_client::client::uist_v1::HttpClient;
use rotala_http::http::uist_v1::Client;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
Loading