@WEB3_furture: 全球最贵的金融团队都在 GitHub 上开源了什么? 普通人怎么了解量化?直接上手是最快的 Jane Street、Goldman Sachs、J.P. Morgan 等顶级量化与高频交易机构,都放出了代表性的金融/工程工具,帮助普通量化…

X AI KOLs Timeline 工具

摘要

该推文介绍了Jane Street、Goldman Sachs和J.P. Morgan等顶级量化机构开源的三个金融/工程工具:magic-trace(高精度进程追踪)、gs-quant(衍生品定价与风险管理Python包)和Perspective(实时数据可视化工具),帮助量化爱好者免费获得机构级技术能力。

全球最贵的金融团队都在 GitHub 上开源了什么? 普通人怎么了解量化?直接上手是最快的 Jane Street、Goldman Sachs、J.P. Morgan 等顶级量化与高频交易机构,都放出了代表性的金融/工程工具,帮助普通量化爱好者免费学到机构级的定价模型、实时数据可视化和高精度性能调试能力 1. Jane Street magic-trace(5.4k stars) https://github.com/janestreet/magic-trace… 基于 Intel Processor Trace 的高精度进程追踪工具。普通 profiler 看不清调用栈的时候,它能以纳秒级分辨率记录 CPU 每一条指令的完整执行过程。想深入调试性能、搞清楚程序到底卡在哪里的同学,强烈推荐试试 2. Goldman Sachs gs-quant(10.2k stars) https://github.com/goldmansachs/gs-quant… 高盛交易员日常使用的衍生品定价和风险管理 Python 工具包。包含期权、掉期等常见衍生品的完整定价模型和风险计算模块。直接 pip 安装就能用,适合想系统学习机构级量化定价的同学,实用性很强 3. Perspective(原 J.P. Morgan 项目,10.5k stars) https://github.com/perspective-dev/perspective… J.P. Morgan 开源的实时数据可视化利器,特别擅长处理海量流式行情数据。能快速搭建漂亮的交互式仪表盘和实时监控界面,支持 Jupyter,比很多付费终端还灵活。对做数据分析和行情可视化的朋友非常友好 这三个开源项目,能让你直接用上机构级的定价模型、实时行情仪表盘和高精度性能调试工具,帮普通开发者提升量化分析、数据可视化和代码优化能力,完全免费
查看原文
查看缓存全文

缓存时间: 2026/05/21 10:22

全球最贵的金融团队都在 GitHub 上开源了什么?

普通人怎么了解量化?直接上手是最快的 Jane Street、Goldman Sachs、J.P. Morgan 等顶级量化与高频交易机构,都放出了代表性的金融/工程工具,帮助普通量化爱好者免费学到机构级的定价模型、实时数据可视化和高精度性能调试能力

  1. Jane Street magic-trace(5.4k stars)

https://github.com/janestreet/magic-trace…

基于 Intel Processor Trace 的高精度进程追踪工具。普通 profiler 看不清调用栈的时候,它能以纳秒级分辨率记录 CPU 每一条指令的完整执行过程。想深入调试性能、搞清楚程序到底卡在哪里的同学,强烈推荐试试

  1. Goldman Sachs gs-quant(10.2k stars)

https://github.com/goldmansachs/gs-quant…

高盛交易员日常使用的衍生品定价和风险管理 Python 工具包。包含期权、掉期等常见衍生品的完整定价模型和风险计算模块。直接 pip 安装就能用,适合想系统学习机构级量化定价的同学,实用性很强

  1. Perspective(原 J.P. Morgan 项目,10.5k stars)

https://github.com/perspective-dev/perspective…

J.P. Morgan 开源的实时数据可视化利器,特别擅长处理海量流式行情数据。能快速搭建漂亮的交互式仪表盘和实时监控界面,支持 Jupyter,比很多付费终端还灵活。对做数据分析和行情可视化的朋友非常友好

这三个开源项目,能让你直接用上机构级的定价模型、实时行情仪表盘和高精度性能调试工具,帮普通开发者提升量化分析、数据可视化和代码优化能力,完全免费


janestreet/magic-trace

Source: https://github.com/janestreet/magic-trace


magic-trace

Overview

magic-trace collects and displays high-resolution traces of what a process is doing. People have used it to:

  • figure out why an application running in production handles some requests slowly while simultaneously handling a sea of uninteresting requests,
  • look at what their code is actually doing instead of what they think it’s doing,
  • get a history of what their application was doing before it crashed, instead of a mere stacktrace at that final instant,
  • …and much more!

magic-trace:

  • has 2%-10% overhead,
  • doesn’t require application changes to use,
  • traces every function call with ~40ns resolution, and
  • renders a timeline of call stacks going back (a configurable) ~10ms.

You use it like perf: point it to a process and off it goes. The key difference from perf is that instead of sampling call stacks throughout time, magic-trace uses Intel Processor Trace to snapshot a ring buffer of all control flow leading up to a chosen point in time1. Then, you can explore an interactive timeline of what happened.

You can point magic-trace at a function such that when your application calls it, magic-trace takes a snapshot. Alternatively, attach it to a running process and detach it with Ctrl+C, to see a trace of an arbitrary point in your program.

1

perf can do this too, but that’s not how most people use it. In fact, if you peek under the hood you’ll see that magic-trace uses perf to drive Intel PT.

Testimonials

“Magic-trace is one of the simplest command-line debugging tools I have ever used.”

  • Francis Ricci, Jane Street

“Magic-trace is not just for performance. The tool gives insight directly into what happens in your program, when, and why. Consider using it for all your introspective goals!”

  • Andrew Hunter, Jane Street

I use perf a ton, and I think that both perf and magic-trace give perspectives that the other doesn’t. The benefit I got from magic-trace was entirely based on the fact that it works in slices at any zoom level, so I was able to see all the function calls that a 70ns function was performing, which was invisible in perf.

  • Doug Patti, Jane Street

more testimonials…

Install

  1. Make sure the system you want to trace is supported. The constraints that most commonly trip people up are: VMs are mostly not supported, Intel only (Skylake2 or later), Linux only.

  2. Grab a release binary from the latest release page.

    1. If downloading the prebuilt binary (not package), chmod +x magic-trace3
    2. If downloading the package, run sudo dpkg -i magic-trace*.deb

    Then, test it by running magic-trace -help, which should bring up some help text.

2

Strictly speaking, anything newer than Broadwell, but this is not a platform we regularly test on, and timing resolution is worse (~1us).

3

https://github.com/actions/upload-artifact/issues/38

Getting started

  1. Here’s a sample C program to try out. It’s a slightly modified version of the example in man 3 dlopen. Download that, build it with gcc demo.c -ldl -o demo, then leave it running ./demo. We’re going to use that program to learn how dlopen works.

  2. Run magic-trace attach -pid $(pidof demo). When you see the message that it’s successfully attached, wait a couple seconds and Ctrl+C magic-trace. It will output a file called trace.fxt.gz in your working directory.

  1. Open magic-trace.org, click “Open trace file” in the top-left-hand and give it the trace file generated in the previous step.

  1. That should have expanded into a trace. Zoom in until you can see an individual loop through dlopen/dlsym/cos/printf/dlclose.
    • W zooms into wherever your mouse cursor is pointed (you’ll need to zoom in a bunch to see anything useful),
    • S zooms out,
    • A moves left,
    • D moves right, and
    • scroll wheel moves your viewport up and down the stack. You’ll only need to scroll to see particularly deep stack traces, it’s probably not useful for this example.

  1. Click and drag on the white space around the call stacks to measure. Plant flags by clicking in the timeline along the top. Using the measurement tool, measure how long it takes to run cos. On my screen it takes ~5.7us.

Congratulations, you just magically traced your first program!

In contrast to traditional perf workflows, magic-trace excels at hypothesis generation. For example, you might notice that taking 6us to run cos is a really long time! If you zoom in even more, you’ll see that there’s actually five pink “[untraced]” cells in there. If you re-run magic-trace with root and pass it -trace-include-kernel, you’ll see stacktraces for those. They’re page fault handlers! The demo program actually calls cos twice. If you zoom in even more near the end of the 6us cos call, you’ll see that the second call takes far less time and does not page fault.

How to use it

magic-trace continuously records control flow into a ring buffer. Upon some sort of trigger, it takes a snapshot of that buffer and reconstructs call stacks.

There are two ways to take a snapshot:

We just did this one: Ctrl+C magic-trace. If magic-trace terminates without already having taken a snapshot, it takes a snapshot of the end of the program.

You can also trigger snapshots when the application calls a function. To do so, pass magic-trace the -trigger flag.

  • -trigger '?' brings up a fuzzy-finding selector that lets you choose from all symbols in your executable,
  • -trigger SYMBOL selects a specific, fully mangled, symbol you know ahead of time, and
  • -trigger . selects the default symbol magic_trace_stop_indicator.

Stop indicators are powerful. Here are some ideas for where you might want to place one:

  • If you’re using an asynchronous runtime, any time a scheduler cycle takes too long.
  • In a server, when a request takes a surprisingly long time.
  • After the garbage collector runs, to see what it’s doing and what it interrupted.
  • After a compiler pass has completed.

You may leave the stop indicator in production code. It doesn’t need to do anything in particular, magic-trace just needs the name. It is just an empty, but not inlined, function. It will cost ~10us to call, but only when magic-trace actually uses it to take a snapshot.

Documentation

More documentation is available on the magic-trace wiki.

Discussion

Join us on Discord to chat synchronously, or the GitHub discussion group to do so asynchronously.

Contributing

If you’d like to contribute:

  1. read the build instructions,
  2. set up your editor,
  3. take a quick tour through the codebase, then
  4. hit up the issue tracker for a good starter project.

Privacy policy

magic-trace does not send your code or derivatives of your code (including traces) anywhere.

magic-trace.org is a lightly modified fork of Perfetto, and runs entirely in your browser. As far as we can tell, it does not send your trace anywhere. If you’re worried about that changing one day, set up your own local copy of the Perfetto UI and use that instead.

Acknowledgements

Tristan Hume is the original author of magic-trace. He wrote it while working at Jane Street, who currently maintains it.

Intel PT is the foundational technology upon which magic-trace rests. We’d like to thank the people at Intel for their years-long efforts to make it available, despite its slow uptake in the greater software community.

magic-trace would not be possible without perfs extensive support for Intel PT. perf does most of the work in interpreting Intel PT’s output, and magic-trace likely wouldn’t exist were it not for their efforts. Thank you, perf developers.

magic-trace.org is a fork of Perfetto, with minor modifications. We’d like to thank the people at Google responsible for it. It’s a high quality codebase that solves a hard problem well.

The ideas behind magic-trace are in no way unique. We’ve written down a list of prior art that has influenced its design.

相似文章

@eastweb3eth: Github 美股量化合集----聪明人必用的工具 自从有了 Github,普通人也能玩量化了。但是别一上来就自己吭哧吭哧写回测引擎,真的,大部分人写的还不如 GitHub 上一个三年前的仓库抗造。 虽然仓库很多,我已经帮你筛选好了,这4…

X AI KOLs Timeline

推荐4个开源量化交易工具/框架(VeighNa、AI-Trader、StockSharp、QuantDinger),强调它们适合普通用户进行美股量化交易,帮助解放双手、将交易交给模型。

@KKaWSB: 送人送到西,兄弟们,GitHub 上的量化交易项目已经卷到这个地步了,有很多拿来就用的好策略可以练手(合集送上)。 华尔街团队年薪百万干的事,这些开源项目免费给你,还带教程。 Qlib(微软官方) AI 量化投资平台,从挖因子、训模型到回…

X AI KOLs Timeline

A curated list of open-source quantitative trading projects on GitHub, including AI-powered platforms like Qlib and FinGPT, multi-agent frameworks, and backtesting tools, all with tutorials and ready-to-use strategies.

@waveking1314: 有人把量化基金常用的工具,全部整理进了一个免费的GitHub仓库。 定价引擎、回测框架、订单簿、实时行情、风险模型,几乎一套配齐。 里面的项目多到有点离谱: 期权定价库 用来计算期权和衍生品价值,覆盖多种定价模型与风险指标。 完整回测框架…

X AI KOLs Timeline

A user curated a free GitHub repository aggregating numerous open-source quantitative finance tools, including pricing engines, backtesting frameworks, order book simulators, and risk models, making institutional-grade research tools accessible to individuals at minimal cost.