panifie / PingPong.jl

Cryptocurrency trading bot, and backtesting framework in julia
https://panifie.github.io/PingPong.jl/
GNU General Public License v3.0
34 stars 9 forks source link

bn.binancedownload(pairs) raises ERROR: ArgumentError: No symbols found matching SubString{String}["BTC/USDT", "ETH/USDT", "SOL/USDT"] #33

Open femtotrader opened 2 months ago

femtotrader commented 2 months ago

Hello,

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.
panbonker commented 2 months ago

scrapers module expects a list of base currencies, and one quote currency see how I do it here: https://github.com/panifie/PingPong.jl/blob/b986fc0823f868514e5dc2f14cda4bcd3084afe3/PingPongDev/src/module.jl#L30-L32

symbols like "BTC/USDT" are in the ccxt unified scheme regex which is parsed from the exchange market id:

using Exchanges
e = getexchange!(:binance)
e.markets["BTC/USDT:USDT"]["id"]

I made it so you can also pass the ids now

panbonker commented 2 months ago

it's also possible to download using the Fetch module but downloading 1m candles from exchanges requires lots of calls which is usually slow, maybe it would be better for quickstart to use an Example1D strat that uses 1d timeframes such that one call per asset using fetch_ohlcv is enough, like

# fetch directly from the exchange
# `sandbox=false` because we don't want fake candles
e = getexchange!(exchangeid(s), sandbox=false)
fetch_ohlcv(e, "1d", raw.(s.universe)) # fetches ohlcv candles from the exchange `e`, saves to storage
fill!(s) # fills all the assets in the strategy universe loading candles from storage