panifie/PingPong.jl

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

Opened this issue · 2 comments

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.

scrapers module expects a list of base currencies, and one quote currency see how I do it here:

function symnames(s=Main.s)
String[lowercase(v) for v in (string.(getproperty.(st.assets(s), :bc)))]
end

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

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