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

Pluto notebook #18

Open
untoreh opened this issue Apr 3, 2023 · 5 comments
Open

Pluto notebook #18

untoreh opened this issue Apr 3, 2023 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@untoreh
Copy link
Collaborator

untoreh commented Apr 3, 2023

Write a pluto notebook to showcase features

@untoreh untoreh added the documentation Improvements or additions to documentation label Apr 3, 2023
@femtotrader
Copy link
Contributor

femtotrader commented Apr 15, 2024

I'd be pleased to help on this when I will understand PingPong.jl features.

Here is what I did to have a Pluto notebook running with PingPong and a Docker configuration (thanks to #19)

I created a custom/Dockerfile file like so

FROM docker.io/panifie/pingpong-precomp-interactive
RUN julia -e 'using Pkg; Pkg.add("Pluto")' 
ENTRYPOINT [ "julia", "-e", "using Pluto; Pluto.run(; host=\"0.0.0.0\")"]

I create a docker-compose.yml like so

services:
  pingpong:
    #image: pingpong-precomp-interactive
    build:
      context: custom
      dockerfile: Dockerfile
    #restart: unless-stopped
    volumes:
      - ./user:/pingpong/user
    ports:
      - 127.0.0.1:1234:1234

I ran this container using

docker compose up

I looked at logs, browsed to http://127.0.0.1:1234/?secret=XXXXXX and created a new notebook with the following content

begin
    import Pkg
    # activate a temporary environment
    #Pkg.activate(mktempdir())
	Pkg.activate("/pingpong")
	#Pkg.add("Term")
	Pkg.instantiate()
end

unfortunately

using PingPong

raised

ArgumentError: Package PingPong not found in current path.

- Run `import Pkg; Pkg.add("PingPong")` to install the PingPong package.

@panbonker
Copy link
Collaborator

/pingpong is the main repo path. Package directories are camel cased, so you want to do

begin
    import Pkg
    Pkg.activate("/pingpong/PingPongInteractive") # or "/pingpong/PingPong"
    using PingPongInteractive
end

@femtotrader
Copy link
Contributor

femtotrader commented Apr 16, 2024

Thanks @panbonker .

Can't understand why I didn't found that myself! Thanks

Here's a work in progress

# v0.19.41

using Markdown
using InteractiveUtils

# ╔═╡ 24d485ab-9bc8-4110-aaa4-cc084324efc3
begin
    import Pkg
    Pkg.activate("/pingpong/PingPongInteractive")
    Pkg.instantiate()
end

# ╔═╡ b1830dda-6bc8-4f30-a36e-81406010dd58
begin
    using PingPong
    using Strategies: Strategies as st
    using Scrapers: Scrapers as scr
    using Data: Data as data
    using SimMode: SimMode as sm
    using Instruments: Instruments as ins
    using Data: Data as da
end

# ╔═╡ 3ed5e59a-ca10-4a13-aa6d-41752b34f8f5
s = st.strategy(:Example) # `st` is the `Strategies` module

# ╔═╡ 74a70750-d11c-47da-b090-9567c541af68
begin
    pairs = ins.raw.(s.universe.data.asset) # `ins` is the Instruments module
    const bn = scr.BinanceData  # `scr` is the Scrapers module
    bn.binancedownload(pairs)
end

# ╔═╡ b616952e-7756-4918-b9e5-2e56879eaba2
let data = bn.binanceload(pairs)
    da.stub!(s.universe, data) # `da` is the `Data` module
end

# ╔═╡ Cell order:
# ╠═24d485ab-9bc8-4110-aaa4-cc084324efc3
# ╠═b1830dda-6bc8-4f30-a36e-81406010dd58
# ╠═3ed5e59a-ca10-4a13-aa6d-41752b34f8f5
# ╠═74a70750-d11c-47da-b090-9567c541af68
# ╠═b616952e-7756-4918-b9e5-2e56879eaba2

but #33 is blocking

@femtotrader
Copy link
Contributor

My opinion it that a very basic notebook with a simple strategy such as MA cross with one symbol, no margin should be written.
Ideally this strategy should be exchange independant and use simply daily data from an exchange which provide enough data.

@panbonker
Copy link
Collaborator

you can pass a different exchange (and any other config) with st.strategy(:Example, exchange=:exc but a real exchange is always necessary because there is tight integration with information which is exchange specific, like precision, limits, leverage tiers, fees...

if you really wanted, you could use an exchange built with an empty symbol (getexchange!(Symbol())), try to run a backtest, and specialize functions with arbitrary default value until it stops throwing method errors...the exchange api is not well packed in one module currently

in absence of a specific exchange there are also api wrappers for coingecko/coinpaprika for getting ohlcv data

anyway I have updated the docs with the 1D strategy SimpleStrategy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants