# \[ANN\] Announcing Trading.jl

**URL:** <https://discourse.julialang.org/t/ann-announcing-trading-jl/97812>\
**Category:** Package Announcements\
**Tags:** package, algorithmic-trading, backtesting\
**Created:** [April 23, 2023, 11:44am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812 "2023-04-23T11:44:04Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)\
**Post date:** [May 9, 2023, 9:52pm UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/21 "2023-05-09T21:52:33Z")

</div>

@louisponet

we don’t have a strategy more a series of indications as to what the market is telling us. It’s a mix of wet (“brain”), soft ( math) and hardware. One “hint” we use is to calculate the historical volatility over 20 10 and 5 days to see what the trend is and then compare it with the implied vol to see if there’s anything interesting. Simple but effective. We also can examine the trend up or down. Sometime that pops up something interesting and we form a strategy around that.

We tend to use DataFramesMeta.jl ( all hail @bkamins ) for the math as it’s a delight to use and by reading [his blog](https://bkamins.github.io/) and reading [his book](https://www.amazon.com/Julia-Data-Analysis-Bogumil-Kaminski/dp/1633439364/ref=sr_1_1?crid=1WF430XYSVRSF&keywords=julia+for+data+analysis&qid=1683668903&sprefix=data+analysis+for+jul%2Caps%2C156&sr=8-1&ufe=app_do%3Aamzn1.fos.006c50ae-5d4c-4777-9bc0-4513d670b6bc) we can get a lot done.

We aren’t skilled in julia ( we use c, c++, python and others) but we’ll try to help out if we can.

---

<div class="post-metadata">

**Author:** ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)\
**Post date:** [May 9, 2023, 10:02pm UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/22 "2023-05-09T22:02:07Z")

</div>

excellent but please remember it’s just a suggestion. Our “system” is an trading augmentation tool. It’s function is to just give a little reality to an ongoing discussion that goes beyond a restatement of existing indicators. It’s interesting to know what the VIX is at and from it get the 1sd on the SPX but who has a guess as to the COMBINATION of factors that got the VIX to where it is? what other instruments are effecting it and how is that “guess” ratified. It’s not just some variant on the VIX calc it’s Dr Lo’s adaptive market hypothesis.

---

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [May 10, 2023, 5:13am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/23 "2023-05-10T05:13:45Z")

</div>

I will read through the examples and try to implement Binance since i primarily trade cryptocurrency over short term. Really cool work. 💪🏻

---

<div class="post-metadata">

**Author:** ![louisponet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/louisponet/32/2070_2.png) [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Post date:** [May 10, 2023, 6:54am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/24 "2023-05-10T06:54:59Z")

</div>

This sounds very cool, I’ll definitely have a look at this when I’ve got some more time and the package features are where I’d like them to be!

---

<div class="post-metadata">

**Author:** ![louisponet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/louisponet/32/2070_2.png) [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Post date:** [May 10, 2023, 6:55am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/25 "2023-05-10T06:55:29Z")

</div>

Cool! Let me know if you have any questions (also feel free to open issues on github for help with the code etc)

---

<div class="post-metadata">

**Author:** ![1153dent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1153dent/32/43968_2.png) [@1153dent](https://discourse.julialang.org/u/1153dent)\
**Post date:** [May 10, 2023, 10:48am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/26 "2023-05-10T10:48:37Z")

</div>

remember that it’s ONLY a suggestion. We only mentioned it to show how we use this information at a basic level. Sometimes it’s helpful to have industry tried and tested approach.

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [May 10, 2023, 11:21am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/27 "2023-05-10T11:21:19Z")

</div>

> [@louisponet](#):
>
> Orderbook support for example is almost there

Great news!

---

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [May 11, 2023, 11:25am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/28 "2023-05-11T11:25:59Z")

</div>

Another quick question regarding this nice package: If you would like a more complex strategy than a simple Indicator like SMA. Say we want to train a Regression model at every time step and use this regression model to predict the movement of the asset into the future and trade based on the outcome of that model. Is this something that could be done as well? I’m still struggling a little to grasp the ECS paradigm and how that would be influenced by this. 🙂

---

<div class="post-metadata">

**Author:** ![louisponet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/louisponet/32/2070_2.png) [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Post date:** [May 11, 2023, 1:12pm UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/29 "2023-05-11T13:12:30Z")

</div>

Yes! Actually the ecs paradigm is much more suited for this type of task rather than “reactive” style updates with the `new_entities` iterator.

It depends a bit on the specifics, but in essence the data is stored in Components, think of them as vectors.

`for d in asset_ledger[Open]` would give you from start to finish each actual `Open` data, which “should” be in the order of bars flowing in.

If you’d want to know explicitely the time of each of those values you can do  
`for e in @entities_in(asset_ledger, TimeStamp && Open)` which returns the `Entities` (think of them as indices into the Components that store data, that have both `TimeStamp` and `Open` data assigned to them. `e[Open]` gives you the Open data and similar for `e[TimeStamp]`. `asset_ledger[Close][e]` would give you the Close data for `e` or an error if it doesn’t have that data.

When regressing multiple assets, you’d create a strategy, then state to use it on those assets (see documentation for more info), then inside the `update` function of the strategy you’d do

`for (e1, e2) in zip(@entities_in(asset_ledgers[1], Open && TimeStamp), @entities_in(asset_ledgers[2], Open&& TimeStamp))` and regress on all the data each time new data becomes available (that’s when update is called on the strategies).

Does that make sense?

---

<div class="post-metadata">

**Author:** ![louisponet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/louisponet/32/2070_2.png) [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Post date:** [May 11, 2023, 1:15pm UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/30 "2023-05-11T13:15:46Z")

</div>

A way to conceptualize ECS is that it’s essentially identical to having a sparse table with `Entities` as rows, and `Components` as columns. With `@entities_in` the Systems can iterate over all the rows that have entries for a given set of columns. i’ve actually been thinking to make a formal `Tables` interface but haven’t got the time to do it yet :p.

---

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [May 11, 2023, 2:08pm UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/31 "2023-05-11T14:08:02Z")

</div>

Great Thanks for the detailed explanation. Yes it makes sense. I will try to digest it. I have forked your repo to prepare for a PR.

---

<div class="post-metadata">

**Author:** ![louisponet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/louisponet/32/2070_2.png) [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Post date:** [May 19, 2023, 9:34am UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/32 "2023-05-19T09:34:29Z")

</div>

Hi All,

I’ve registered v0.2.0 of Trading.jl. The main updates are:

- Both Crypto and Stock Assets can be used
- Full L3 [OrderBook](https://louisponet.github.io/Trading.jl/dev/orderbook/)

Let me know what you think!

---

<div class="post-metadata">

**Author:** ![W4C](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/w4c/32/43621_2.png) [@W4C](https://discourse.julialang.org/u/W4C)\
**Post date:** [July 7, 2023, 2:55pm UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/33 "2023-07-07T14:55:26Z")

</div>

Hi all,

Thanks @louisponet for publishing such a package.  
I’m coming from Trality (Python crypto bots) [https://www.trality.com/blog/trality-winding-down-product](https://www.trality.com/blog/trality-winding-down-product) (and ranked 1st to one of their virtual trading competition). I’m considering moving to Julia which I know a bit and like (especially because of its speed). I’m wondering what are differences with a trading library such as [GitHub - panifie/PingPong.jl: Cryptocurrency trading bot, and backtesting framework in julia](https://github.com/panifie/PingPong.jl/). Did you also try to compare to [TradingLogic.jl](https://github.com/JuliaQuant/TradingLogic.jl), Strategems.jl]([GitHub - dysonance/Strategems.jl: Quantitative systematic trading strategy development and backtesting in Julia](https://github.com/dysonance/Strategems.jl)) …

Related forum post : [Backtesting framework](https://discourse.julialang.org/t/backtesting-framework/47351/)

Kind regards

---

<div class="post-metadata">

**Author:** ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)\
**Post date:** [October 17, 2023, 11:04pm UTC](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812/34 "2023-10-17T23:04:45Z")

</div>

@louisponet - Suppose I already have a lot of historical OHLCV data on disk. If I could load that into a DataFrame or TimeArray, is there any way to make HistoricalBroker make use of that? Would a new broker type need to be created to facilitate something like this?

[Previous page](https://discourse.julialang.org/t/ann-announcing-trading-jl/97812.md?page=1)
