panifie / PingPong.jl

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

[Help] How do I choose which project to execute the script in? #48

Closed janckerchen closed 2 weeks ago

janckerchen commented 2 weeks ago

In PingPong project, the following script(from the package doc) failed. Or should I Pkg.add these modules in the root of the source code? TimeTicks, Exchanges, and Fetch are all separate modules and don't seem to be visible to any single project simultaneously.

using TimeTicks
using Exchanges
using Fetch: Fetch as fe

exc = getexchange!(:kucoin)
timeframe = tf"1m"
pairs = ("BTC/USDT", "ETH/USDT")
# Will fetch the last 1000 candles, `to` can also be passed to download a specific range
fe.fetch_candles(exc, timeframe, pairs; from=-1000)

output

julia> using PingPong  # make sure PingPong module is loaded

julia> using TimeTicks
ERROR: ArgumentError: Package TimeTicks not found in current path.
- Run `import Pkg; Pkg.add("TimeTicks")` to install the TimeTicks package.
Stacktrace:
 [1] macro expansion
   @ ./loading.jl:1772 [inlined]
 [2] macro expansion
   @ ./lock.jl:267 [inlined]
 [3] __require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1753
 [4] #invoke_in_world#3
   @ ./essentials.jl:926 [inlined]
 [5] invoke_in_world
   @ ./essentials.jl:923 [inlined]
 [6] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1746
panbonker commented 2 weeks ago

in the repl should use the @environment! macro that imports most modules https://github.com/panifie/PingPong.jl/blob/8fdf2a5b491990ba1ed13b9e618d9551a9fbb8e7/PingPong/src/module.jl#L28

using PingPong
@environment!

although it doesn't export fetch_candles, only fetch_ohlcv which does cleanup and caching

if you want to import single modules you need to add the repo folder (top level PingPong.jl path) to the julia LOAD_PATH this is mostly for development though

janckerchen commented 2 weeks ago

pull request