Giter Site home page Giter Site logo

cryptodashapp.jl's Introduction

CryptoDashApp.jl

License Build status (Github Actions) Coverage Status

Interactive visualization of historical price (currently only in EUR), health metrics, candlestick and volume data for various cryptocurrencies. Data are obtained via API queries to Alpha Vantage. The app is written in Julia and makes use of Dash.jl along with its react framework to generate a dashboard style view accessible via a browser. Different moving averages are also calculated and plotted along with the daily average price data. Averaging window can be selected by the user.

Functionality of the app will be extended in the future by adding more technical indicators. Contributions are most welcome!

How to use?

API keys

  • Free AlphaVantage API key can be obtained from here.
  • Free demo key for CoinGecko API can be generated by following this guide.

Running in Julia locally

This package is available via the General registry. Add it to your working Julia environment by doing the following in the REPL:

  • Press ']' to enter Pkg prompt
pkg> add CryptoDashApp

Once all the packages are downloaded, you can make use of the CryptoDashApp module from the REPL itself or within a script by executing:

julia> using CryptoDashApp
julia> ENV["KEY_AV"] = "your_AlphaVantage_key"
julia> ENV["KEY_CG"] = "your_CoinGecko_key"
julia> load_keys()
julia> run_app(8056) # where 8056 is the port

Now, open a new tab in your browser and check if you can access http://0.0.0.0:8056/ or http://127.0.0.1:8056/

Running as a Docker container (for versions > 0.6.0)

Assuming that you have Docker installed, and have generated both API keys, a Docker image can be created using the following steps:

  • Clone this repository and cd to the directory

  • Build the Docker image (Here my_app is the name of the generated image)

docker build --build-arg key_av="YOUR_KEY" --build-arg key_cg="YOUR_KEY" -t my_app .
  • Once the image is successfully generated, start a container (port 8010 is hard-coded in the Dockerfile, can also be changed if needed):
docker run -dp 127.0.0.1:8010:8010 my_app
  • Check log output:
docker logs --follow <container id>

First plot will take a few seconds to appear, wait patiently! If you are running this app for the first time, or on a different date, new data will be retrieved from Alpha Vantage, and then saved to CSV files on disk. Keep in mind that the free API key imposes a limit of five calls/minute, which means you won't be able to load data for more than five currencies in quick succession. In case you see an error, wait for a while and then try again.

App demo

For better visual quality, visit this link.

cryptodashapp.jl's People

Contributors

vnegi10 avatar github-actions[bot] avatar

Stargazers

 avatar Luis C. Gómez avatar Shayan Davoodi avatar  avatar  avatar Dan Choon avatar  avatar Aleksey Savin avatar 是夕流芳 avatar  avatar vkam avatar  avatar

Watchers

 avatar  avatar

cryptodashapp.jl's Issues

Fix API key error

Current implementation loads the API keys during precompilation, which leads to automerge issues as seen here.

It will be better to load the keys using a function.

Save exchange volume data as a CSV file

Currently, exchange volume data is saved to a delimited (using ;) text file. Instead, we can save it as a CSV file. This will also reduce one dependency since DelimitedFiles.jl will no longer be needed.

In src/getdataCG.jl:

function get_vol_chart(exchange)
...

   open(filepath, "w") do f
        for chart in ex_vol_chart
            writedlm(f, [chart], ";")
        end
    end
...

Set up app to run inside a Docker container

A user needs to only do the following steps:

  • Install Docker
  • Create the image
  • Run the container

The app would run inside Docker. However, the URL should be accessible via a browser on the host machine.

Advantages:

  • User does not need to install Julia, this package and its dependencies.

Plot price correlation

Price movements for many cryptocurrency pairs seem to be correlated. It will be useful to measure and visualize this in a separate plot.

Use Coinbase as a new data source

API endpoints from Alpha Vantage often do not return price data or hit the request limit. We can make use of Coinbase as a fallback option to fetch the relevant data. CoinbaseProExchange.jl seems to be working okay, and can therefore be used.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Improve test framework

Current set of testers rely on the success of API calls. Very often, the expected data is not available via the API, which causes the tests to fail. This can be improved by doing the following:

Use demo key for public API

Public keyless API will be deprecated by Feb, 2024 (from Julia Ng). Instead, we will need to use a demo API with keyed authentication.

Investigate reading data from a SQLite database or MS SQL Server

Fetching data directly from the API has its own limitations:

  • Keys need to be passed every time the package is loaded
  • API fails to respond
  • Testers run into issues due to too many requests being made at once

A solution could be to have a database store all the relevant data on a daily basis. This can be achieved using an Actions workflow set to execute daily using the cron syntax. The latest version of the database then needs to be made available as an artifact when this package is installed.

False positive test case

df_ex_vol = CryptoDashApp.get_exchange_vol_data(currency, num_exchanges) also returns a DataFrame with two rows and missing values, therefore the test case will always pass.

Issue with using @error in lines 185, 186 within src/getdataCG.jl

Precompile is NOK on Julia v1.10

Precompilation gets stuck as shown below:

julia> using CryptoDashApp
Precompiling CryptoDashApp
┌ Warning: attempting to remove probably stale pidfile
│   path = "/home/vikas/.julia/compiled/v1.10/PlotlyJS/1r9Ld_Bp1s6.ji.pidfile"
└ @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:244
^C Interrupted: Exiting precompilation...            ]  0/3
  ◑ Dash Waiting for background task / IO / timer. Interrupt to inspect
  2 dependencies had output during precompilation:mer. Interrupt to inspect
┌ PlotlyJS
│  [pid 56229] waiting for IO to finish:
│   Handle type        uv_handle_t->data
│   pipe[17]           0x1aaeba0->0x7f66729ba310
│   pipe[11]           0x1761300->0x7f66729ba3b0
│   process[56277]     0x1ade8d0->0x7f6672931430
│  This means that a package has started a background task or event source that has not finished running. For precompilation to complete successfully, the event source needs to be closed explicitly. See the developer documentation on fixing precompilation hangs for more help.

Related issue (JuliaLang/julia#52685) and PR (JuliaLang/Downloads.jl#234) are currently in progress. We will need to update dependencies with the correct version later.

Messy error stack when unable to fetch data from API

The following error stack appears when price data is not available from the API. We should simply throw an error and prevent any further computation which expects such data to be present.

[ Info: Fetching DOT price/vol data from Alpha Vantage
[ Info: Could not fetch data, try again later!
┌ Error: error handling request
│   exception =
│    ArgumentError: invalid index: :Date of type Symbol
│    Stacktrace:
│      [1] to_index(i::Symbol)
│        @ Base ./indices.jl:300
│      [2] to_index(A::Vector{DataFrames.DataFrame}, i::Symbol)
│        @ Base ./indices.jl:277
│      [3] _to_indices1(A::Vector{DataFrames.DataFrame}, inds::Tuple{}, I1::Symbol)
...
 [8] plot_price_ma_trade_data(index::Int64, duration::Int64, window::Int64, key::String)
│        @ CryptoDashApp ~/.julia/packages/CryptoDashApp/kXsVa/src/plotsAV.jl:18
│      [9] plot_price_ma_trade_data(index::Int64, duration::Int64, window::Int64)
│        @ CryptoDashApp ~/.julia/packages/CryptoDashApp/kXsVa/src/plotsAV.jl:9
│     [10] (::CryptoDashApp.var"#7#14")(mode_ID::Int64, pair_ID::Int64, window_ID::Int64, duration_ID::Int64)
│        @ CryptoDashApp ~/.julia/packages/CryptoDashApp/kXsVa/src/app.jl:248

Update Dash and related deps. to newer versions

This will hopefully also solve the failing CI with Julia 1.9 on Windows, where Blink.jl fails to build.

Building Blink ───→ `C:\Users\runneradmin\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\08d0b679fd7caa49e2bca9214b131289e19808c0\build.log`
ERROR: LoadError: Unable to find 7z.exe. Try running `make win-extras` if you built Julia from source.
...
ERROR: LoadError: Error building `Blink`:

Related issue: JuliaGizmos/Blink.jl#247

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.