panifie / pingpong.jl Goto Github PK
View Code? Open in Web Editor NEWCryptocurrency trading bot, and backtesting framework in julia
Home Page: https://panifie.github.io/PingPong.jl/
License: GNU General Public License v3.0
Cryptocurrency trading bot, and backtesting framework in julia
Home Page: https://panifie.github.io/PingPong.jl/
License: GNU General Public License v3.0
Could use https://github.com/JuliaMath/DecFP.jl
but it states 50x slowdown...would need a PoC with some benchmarks to see how much a backtest would be affected
There is https://github.com/JuliaCN/Py2Jl which could be used to bootstrap the julia base classes from python base classes.
Looking at the regex at https://github.com/ccxt/ccxt/blob/master/build/transpile.js seems like most of the translations are doable, translating the isinstance
and is None
ones from python, and the common ones from PHP, because julia lacks dotcall syntax
Basically all functions with arguments any combination of Strategy
AssetInstance
Order
Trade
etc... have "loose" signatures. Meaning for example that you could call them with arguments where the strategy refers to an exchange, and an asset refers to another...
They would have to be rewritten for example like:
function position!(
s::IsolatedStrategy{Sim}, ai::MarginInstance, t::PositionTrade{P};
) where {P<:PositionSide}
to
function position!(
s::Strategy{X,N,E,Isolated,C}, ai::AssetInstance{A,E,Isolated}, t::Trade{O,A,E,P};
) where {X,N,E<:ExchangeID,C,A<:AbstractAsset,O,P<:PositionSide}
OctoBot (ccxt based): https://github.com/Drakkar-Software/OctoBot-Tentacles/tree/master/Trading/Exchange
Humming bot connectors (non ccxt based): https://github.com/hummingbot/hummingbot/tree/master/hummingbot/connector/exchange
I am more inclined on using octo-bot ones since ccxt based, and ccxt added websockets recently anyway
v1 is tagged
The test suite is mostly passing, although there are still 1 or 2 flapping tests.
The pre built images are on the docker registry
v1 will only receive bug fixes and new adhoc functions for better exchange support.
v2 is not currently being worked on, this is a list of things that need to happen for a v2 release and other things that would be nice to have:
ExchangeApi
module. Currently it is mostly split into the Exchanges and LiveMode modules. It is fine to model it over the ccxt api but this needs to happen to make ccxt swappable.Millisecond
as time unitSome strategies work based on past profitability, so they require a way to calc the profits of previous trades. Because ping pong does not make assumptions about execution of trades (buys and sells are not necessarily interleaved) a module for ensuring that the strategy executes only 1 trade at a time is required. And the method to track profitability should be implemented in such module
Remove the PairData
type, and instead rely on DataFrames
metadata for info.
Replace the current progressbar with Term.jl
Hello,
According doc
But
julia> const bn = scr.BinanceData
ERROR: UndefVarError: `scr` not defined
Any idea how to fix this?
how to use the package, how to get information, like profit, sharp ratio, and other stuffs in backtrader in python
openat,closeat,etc...
that could be memoizedgetproperty
for asset instances and strategies or replace all dot accessors within SimMode with some getfield
wrapper function. Because the getproperty accessor is slower than getfield if it is customizedCcxtTrade
, CcxtTicker
), in cases where full parsing is not required, the python data should be parsed more lazilycopyto!
(starting from Data)Period
with FixedPeriod
to see if union splitting improves performanceHello,
Currently following documentation but
julia> using PingPong
julia> @environment!
julia> s = st.strategy(:Example)
Name: Example (Sim)
Config: No Margin, 10.0(USDT)(Base Size), 100.0(USDT)(Initial Cash)
Universe: 3 instances, 1 exchanges
Trades: 0 ~ 0(longs) ~ 0(shorts) ~ 0(liquidations)
Holdings: 0
Pending buys: 0
Pending sells: 0
USDT: 100.0 (on phemex) (Cash)
USDT: 100.0 (Total)
julia> pairs = im.raw.(s.universe.data.asset)
3-element Vector{SubString{String}}:
"BTC/USDT"
"ETH/USDT"
"SOL/USDT"
julia> using Scrapers: Scrapers as scr
julia> const bn = scr.BinanceData
Scrapers.BinanceData
julia> bn.binancedownload(pairs)
ERROR: ArgumentError: No symbols found matching SubString{String}["BTC/USDT", "ETH/USDT", "SOL/USDT"]
Stacktrace:
[1] binancedownload(syms::Vector{…}; zi::Data.ZarrInstance{…}, quote_currency::String, reset::Bool, kwargs::@Kwargs{})
@ Scrapers.BinanceData /pingpong/Scrapers/src/binance.jl:239
[2] binancedownload(syms::Vector{SubString{String}})
@ Scrapers.BinanceData /pingpong/Scrapers/src/binance.jl:233
[3] top-level scope
@ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.
Although not really recommended, embedding python strategies is a very easy task.
The backtest could be made more interactive by either:
Make dockerfile with prebuilt packages, consider static compilation
The main goal of this would be to allow to backtesting runs on a GPU, and in particular allow to run backtests using online jupyter instances that offer GPU computing like colab or kaggle.
Since we mostly target online notebooks, and they are all nvidia, we would be using CUDA.jl
Making the backtest GPU compatible mostly means building structure adaptors for these types:
The Exchange
type is a wrapper for a ccxt exchange, it is already discouraged to call python from a strategy, and the backtest itself never calls any python code, so this is not an issue per se, however it should be made abudantly clear in the documentation that a GPUStrategy cannot use python code.
This is however not enough:
To achieve parallelizability we have to run 1 backtest per GPU core, which means that the strategy has to be implemented as a kernel, in particular the main ping!
function and whatever the function calls, needs to be a kernel. Of course we should provide example implementations and warn about the complexities of gpu programming.
A test should be done to compare loading times between a repository version where everything is imported from one main modules and compare it to the current multi project version
Split up dependencies for:
Symbols are currently parsed through some regex. We could instead query ccxt.market["info"]
Ccxt also provides the feeCurrency
but is not necessarily useful for backtesting as much as for live trading
Write a pluto notebook to showcase features
currently all arrays are stored in a flat structure in the ZarrInstance
main group, whereas they should be saved according to their path
in a subgroup
Currently we only consider the executor under the pingpong model. That is that the strategy has to deal with its own data feeds.
If the pingpong model also accounted for data updates, a pong!
call within the strategy could branch into a Watcher
instance in live mode and a prefetched dataframe in sim mode.
However since a strategy has always carte blanche, the benefits of managing data for the strategy are very small (we can't manage every piece of data, so managing only a few doesn't improve the status quo).
Moreover the main ping!
function works with a timestamp as primary input, so there is never any ambiguity on the time context of execution and whatever data the strategy uses, should already be time context aware because of this.
Hello,
Trality, a Python crypto trading bot will stop. See https://www.trality.com/blog/trality-winding-down-product
I'm considering moving to Julia and an open source trading environment.
Converting some Trality examples to PingPong.jl could help to attract new users.
Here are some examples https://gist.github.com/c0indev3l/855381f07865dfca079e8252e736ae35
and documentation https://docs.trality.com/
Kind regards
Watcher
an abstract subtype of the Rocket
actorWatcher
abstract typeUsing watchers, when fetching candles, we call fetchOHLCV
et similar, but in case candles are emulated we shouldn't call it, and instead process from trades directly since we already do it in other cases. So we have to ensure exc.has["fetchOHCLV"]
is not emulated
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.