FlyTV

A fly brain trades bitcoin.
Spoiler: badly.

We took the measured wiring of a fruit-fly brain, ran it inside Pine Script and tested whether it holds an edge. It does not. This is the audit trail.

live: the circuits currently firing are lit
optic lobes mushroom bodies central complex giant fiber dopamine
121,325measured connections
0fitted brain weights
≈45runs, 10 hypotheses
nonetradable edge
01 / idea

The trader's action space already exists in the fly

Most connectome demos start by asking where to plug the neurons in. We never had to: biology had already answered it.

The fruit fly has command neurons whose function is known from experiments — stimulate the cell, watch what the animal does. Forward, backward, turn, escape, sit still. That is the same discrete action space a discretionary trader picks from. Not a metaphor, a structural match — and it is the main integrity argument of the project.

DNp09
walks forward
→
go long
MDN «moonwalker»
walks backward
→
exit, go short
DNa01 / DNa02
turns left / right
→
flip direction
DNp01 «giant fiber»
takes off, escapes
→
flatten now, risk-off
DNg11
grooms
→
stay flat, wait

All five are present in MaleCNS v1.0 — the complete connectome of an adult male fruit fly, released in September 2026 under CC BY 4.0.

0.00%

version 1

The map above was a claim, not a mechanism. Silencing four of these six circuits changed nothing at all, and a 313-neuron model holding only the looming detectors and the giant fiber reproduced every trade exactly.

3–32%

version 3

Each circuit was given its own sensory input. Silencing any one of the 13 circuits tested now moves between 3% and 32% of positions.

75.5%

reflex only

That same stripped model now disagrees with the full network on three quarters of its bars. The mapping above is what the network actually uses.

02 / demo

Watch it decide

Real BTCUSDT candles, H1 timeframe. The test window opens on 7 October 2018 and runs to 3 May 2026 — seven and a half years, no window shopping. The replay is deterministic and causal: on bar N the fly has only seen bars up to N. Charge builds in the giant fiber, a selloff fires it, and the position is flattened.

— speed
first bar7 Oct 2018, 00:00 UTC
last bar3 May 2026, 23:00 UTC
bars66,315 · H1
starting equity$1,000
—
GF charge · thr 30 / 3
fly equity$1,000
buy & hold$1,000
round trips0
escapes0
position—
MB bias—
dopamine—

Starting equity is $1,000, one position, long only: the fly stays long while calm and sits in cash after an escape. Amber is its equity curve, grey is the same $1,000 bought and held. Fees are excluded in the replay, exactly as in the Python reference — what they do to the result is right below. The same computation runs inside the Pine script on a live chart; here it is a playback, because bar replay in TradingView hits the platform's execution limits.

Seven and a half years — and why the result proves nothing

$1,000 → $4,231

fly equity

+323% · max drawdown 48% · exposure 44.6% · 13,958 round trips

$1,000 → $11,904

buy & hold

+1,090% · max drawdown 77% · one entry in seven and a half years

Which version this is. The replay above is version 1 of the strategy, where trades were driven by the looming detectors and the giant fiber alone. Version 3, the one published now, puts every circuit into the decision — and over the same window it returns −69.9% at a drawdown of 86.5%. Making the brain participate made the trading worse, and that is the honest result. The section below is where it is taken apart.

The first thing to say out loud: the dumbest possible benchmark wins by 2.8×. Buying bitcoin in 2018 and doing nothing beats a brain with a million synaptic contacts. On BTC, buy & hold is the benchmark any strategy has to clear, and we do not clear it.

The second: the fly's own P&L carries no information. It was long 45% of the time in an asset that went up 12×, so any process entering at that rate would also print a profit. We measured that instead of assuming it.

$7,400 ± 8,900

random entries, same exposure

Twelve runs of a coin flip at the same 44.6% exposure. The fly beat six of twelve — a coin flip about a coin flip. The dispersion of the random benchmark swallows the fly's result whole.

$1,000 → $16

with a real fee

0.02% per side — the maker fee on Binance futures.

27,915 fills: 13,958 entries and 13,957 exits, the last position still open. At two basis points a side, $1,000 of starting equity ends at $16.

So — does it make money? On paper yes, in substance no: the return is just over a third of buy & hold, statistically indistinguishable from random entries at the same exposure, and fully consumed by fees. The one result that survived every control is drawdown: lower than the random benchmark in ten runs out of twelve, and 1.6× lower than buy & hold. The effect is small, and it is about risk, not return — which is why drawdown was the project's target metric from day one.

03 / inputs

What the fly senses when it looks at a chart

The remaining job is to feed it something its neurons evolved to handle. Three channels, each riding a measured pathway.

Vision → threat

A selloff is an object looming toward you. Looming detectors LC4 and LPLC2 feed the giant fiber directly: 11,198 synaptic contacts, measured. In a live fly this is the fastest known route to takeoff.

The smell of the tape

Kenyon cells emit a sparse code of context — about 5% active. Mathematically that is a random projection with a threshold. We feed bar features in and get "what the market smells like right now".

Dopamine = realised P&L

A winning trade stimulates PAM neurons, a losing one PPL1. That is how reward and punishment are encoded in the animal during odour learning.

04 / architecture

Three layers, only one of them learns

Bolting conventional RL onto a connectome defeats the purpose: the moment an optimiser touches the weights, the gradient is trading, not the fly. But the animal ships with its own reinforcement-learning machinery, so we used that.

frozen
121,325

Reflexes

Measured connections in the full circuit, 17,000 in the Pine build. No reward, no gradient, no fitting — there is nothing here to overfit with.

fitted externally
~15

Body interface

Numbers the connectome does not contain: sensory gain, the threshold that turns spikes into an order. These we did fit — the brain we did not touch.

learns online
33,496

Mushroom bodies

KC→MBON synapses in the full circuit, 5,816 in the Pine build. They depress when a cell was active as dopamine arrived — the same three-factor rule the animal uses.

Learning runs bar by bar inside the backtest: on bar N the fly has only seen bars up to N. Look-ahead bias is structurally impossible.

05 / control

Is it really the wiring doing the work?

Every connectome demo runs into one question: is the fly brain responding, or the scaffolding the author wrote around it? The test is cheap — shuffle the connection weights while preserving the node degree distribution. Same neuron count, same connection count, same total activity; only the wiring diagram is randomised.

Below, one identical looming stimulus is fed to both networks. Real MaleCNS wiring on the left, shuffled on the right. Total activity is practically identical — 15,651 spikes versus 15,439 over a hundred simulation steps. Only the addressing differs. Watch the giant fiber charge.

real MaleCNS wiring 98 DNp01 spikes

The LC4/LPLC2 → DNp01 cascade is intact: 11,198 measured contacts. Charge clears the threshold, the giant fiber fires, the fly takes off. Reproducible across every seed.

shuffled weights 0 DNp01 spikes

The network is no quieter — excitation scatters to random addresses and never accumulates on the command neuron. At most one spike across the ten seeds tested.

giant fiber charge escape threshold stimulus onset animation is schematic · numbers come from a test in the code: full circuit, 100 steps, 0.6 current into LC4/LPLC2

The avoidance response disappears completely. So the "looming detected → escape" pathway rests on the measured connections, not on our scaffolding. No project in this wave of connectome demos has published such a control — and without one, "the fly brain is doing it" is just a caption. We run the same control on every hypothesis in the next section.

The control runs on the full circuit — 5,828 neurons, 121,325 connections. The pruned Pine build keeps the pathway: the distilled circuit reproduces 36 of the 39 escapes the full one produces over the same window.

The second control: read the wiring blind

Shuffling the connections asks whether the wiring matters. The other direction asks something harder — can the wiring alone tell us what a circuit is, with no anatomy supplied?

The fly steers by a ring of cells that holds its heading as a bump of activity. We never told the script which cell points where. Take the EPG subgraph, normalise its Laplacian, look at the eigenvalues: two of them come out almost equal. That near-degenerate pair is the signature of a cycle, and the matching eigenvectors give the cosine and sine of every cell's angle. Fifty cells, one ring, nothing placed by hand.

Ring of 50 EPG cells placed at the angles recovered from the connectome, coloured by body side

Then we checked the result against anatomy that never entered the computation:

  • walking the ring, the body side of each cell alternates in 16 blocks — the protocerebral bridge has 16 glomeruli, and side was not part of the calculation
  • PFL3 comes out offset by 90° from the heading cells, PFL2 by 180°, PEN by 90° — the published offsets
  • FC2, which carries the goal rather than the heading, comes out independent of it

Cyan and violet are the two sides of the body. Ticks mark where the alternation switches.

This is the part we did not have to model. The compass was already in the connectome; we only had to read it.

06 / research

We looked for an edge ten different ways. There isn't one.

This is the dull part and the important one: ten hypotheses, roughly forty-five runs. Each went through the same protocol — shuffled-weight control, honest out-of-sample split, several seeds.

50.7%

ceiling on predictability

An oracle with access to every price feature calls the sign of the next bar at this hit rate. Timing a single instrument off price alone is not predictable — for anyone, fly or not.

2.8 → 1.5

survivorship bias

Cross-sectional momentum on the top 10 coins looked like signal (t 2.8). On a 40-coin universe it decays to t 1.5. There was no effect, only selection.

17/18 → 6/18

crowd positioning

The retail long/short account ratio worked convincingly in-sample and fell apart out-of-sample. The effect is non-stationary.

H0–H5
reflexes and mushroom bodies on price inputs
no signal
H8
cross-section: signal exists in the data, learning fails to extract it
partial
synthetic
on a synthetic task the plasticity does learn — the mechanism is sound
works
H10–H11
non-price senses: funding, open interest, crowd positioning
failed out-of-sample

The result we publish as a result: no configuration beat a random benchmark reliably on price inputs. Drawdown came in below buy & hold — but that is the arithmetic of running 44.6% exposure, not evidence about the wiring, and we tested that separately.

A negative result is a result. None of the five preceding projects on this connectome published one.

07 / distillation

Fitting a brain into Pine Script

The full circuit is 5,828 neurons and 121,325 connections. The budget on a live chart is roughly a thousand neurons and seventeen thousand connections. Six sevenths had to go.

121,325connections in the full circuit
schematic · click the canvas to pause
14.0%

connections kept

17,000 of 121,325

0.968

decision agreement

the distilled circuit reproduces the full one's positions, BTC H1 2022–2026

36 / 39

escapes preserved

over the same window; on history from 2018 there are 219

Most of the brain did not fit into TradingView, and the decisions barely moved. The reusable by-product: a recipe for porting a network with measured weights into Pine — packing the edge list into string literals, event-driven propagation instead of a full sweep, and a budget of about a hundred million operations per run. None of that is specific to flies.

08 / pine script

Why this lives on a chart, not in a notebook

The whole thing could have stayed in Python. Three reasons it did not, and each mattered more than expected.

It runs, it isn't a video

Every other connectome demo is a recording — Doom, Minecraft, Beat Saber. This one is source code you paste into the Pine Editor: it computes on your instrument, your timeframe, your history. The difference between watching and running.

Open source is the default

TradingView's Community Scripts expect the source to be published and moderated. For a project whose entire argument is "we checked it, here is the control", that is not a constraint — it is the precondition.

The data is already wired in

Beyond price, Pine reaches 20+ non-price feeds — funding, open interest, the retail long/short account ratio. We tested an entire round of hypotheses on them without a single API key.

TradingView Pine Script™ v6 strategy · 1,325 neurons · 17,000 connections
runs on a live chart
//@version=6
strategy("FlyTV 🪰 Fly Brain", "FlyTV", overlay = false,
         initial_capital = 10000, process_orders_on_close = false)

// network state survives between bars — that is what var arrays are for
var int[]   pot = array.new_int(N, 0)      // membrane potential per cell
var float[] kcw = array.new_float(E, 1.0)  // KC→MBON — the only thing that learns

// the network steps once per closed bar — otherwise it re-runs on every tick
if barstate.isconfirmed
    loom   = math.max(0.0, -ret) * loomGain   // candle → current into LC4 / LPLC2
    spikes = stepNetwork(loom, STEPS)
    if spikes >= gfMin
        strategy.close("L", comment = "escape")  // the giant fiber fired

That is the whole shape of it: var arrays keep the membrane potential and the learned weights alive from bar to bar, barstate.isconfirmed makes the network step exactly once per closed bar, and a giant-fiber spike becomes strategy.close(). Everything a Pine author already knows — applied to 17,000 measured synapses instead of a moving average.

The platform limits turned out to be the useful part. They are a budget you cannot buy your way out of, and they are what forced us to distil 121,325 connections down to 17,000 and then prove the decisions had not moved. In Python that discipline never appears: there is always more hardware.

500 msper bar
20 sper whole run
100karray elements
1 tokenper string literal

That last one is the trick the whole port hangs on: a string literal costs a single token no matter how long it is, so the edge list ships inside the script as packed text and is expanded on the first bar.

So the reusable by-product of a fruit-fly joke is a fairly general recipe: how to carry a network with measured weights into Pine Script and keep it inside the execution budget. If you write Pine, the useful page here is the code, and the script itself is published on TradingView.

09 / integrity

What is measured and what we made up

measured
  • Wiring: 1,325 neurons and 17,000 connections in the Pine build, 5,828 and 121,325 in the full one
  • The LC4/LPLC2 → DNp01 pathway, 11,198 contacts
  • Connection signs from predicted neurotransmitters
  • Identification of the command cells
  • The KC→MBON plasticity rule and MBON valence, derived from data and matching the literature
modelled
  • Neuron dynamics: leaky integrate-and-fire
  • Sensory tuning — absent from the annotations entirely
  • The entire market ↔ sensory-organ mapping
  • Turning spikes into an order
  • No retinotopy: every cell receives the same stimulus

A connectome is a static anatomical snapshot, not a living brain. We are not claiming to have validated physiology, and certainly not that a fly can trade. Nothing here is investment advice.