Git Product home page Git Product logo

coinbasepro.jl's Introduction

CoinbasePro

A basic API for getting Coinbase data into Julia.

This package provides a Julia interface for the market data functions listed here: https://docs.pro.coinbase.com/

Under Development

  • Non market data based functions.

Getting Started

Install the package in Julia using the Pkg REPL:

julia> ]
pkg> add CoinbasePro

or

using Pkg
Pkg.add("CoinbasePro")

Functions

Market Data Functions

Information on all currency pairs for trading or a specific currency pair.

products()
products("BTC-USD")
produces("ETH", "USD")

Get the orderbook for a product.

  • Level 1: Best Bid and Ask
  • Level 2: Full order book aggregated
  • Level 3: Full order book not aggregated.

Change the level with the 2nd argument to the function.

#level 1
book("BTC-USD", 1)
#level 3
book("BTC-USD", 3)
  • ticker Get the last trade, best bid/offer and 24 hour volume for a product.
ticker("BTC-USD")
  • trades Get a list of trades of a product. Paginated so will return both the data and a pagination cursor. using lasttrades to get the last n trades of a product.
trades("BTC-USD")
lasttrades("BTC-USD", 100)
  • candles Historical rates for a product in terms of open, high, low, and close (OHLC).
    1 minute, 5 minute, 15 minute, 1 hour, 6 hour and 1 day granularity available.
# 1 minute bars
using DateTime
candles("BTC-USD", now() - Hour(1), now(), 60)
  • stats OHLC and volume data from the last 24 hours and 30 day average volume.
stats("BTC-USD")

A tutorial on the various functions can be found here.

coinbasepro.jl's People

Contributors

dm13450 avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

coinbasepro.jl's Issues

CoinbasePro.lasttrades("BTC-USD",10) -> ArgumentError: input string is empty or only contains whitespace

Hello dm13450,

Thanks for the package. I recently updated to Julia 1.10.2, in doing so an error occurs where it did not in 1.7.0.

CoinbasePro.lasttrades("BTC-USD",10) and CoinbasePro.trades("BTC-USD") return:

ArgumentError: input string is empty or only contains whitespace
Stacktrace:
[1] tryparse_internal(::Type{Int64}, s::String, startpos::Int64, endpos::Int64, base_::Int64, raise::Bool)
@ Base ./parse.jl:115
[2] parse(::Type{Int64}, s::String; base::Nothing)
@ Base ./parse.jl:254
[3] parse
@ ./parse.jl:253 [inlined]
[4] _broadcast_getindex_evalf
@ ./broadcast.jl:709 [inlined]
[5] _broadcast_getindex
@ ./broadcast.jl:692 [inlined]
[6] #31
@ ./broadcast.jl:1118 [inlined]
[7] ntuple
@ ./ntuple.jl:49 [inlined]
[8] copy(bc::Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple}, Nothing, typeof(parse), Tuple{Base.RefValue{Type{Int64}}, Tuple{String, String}}})
@ Base.Broadcast ./broadcast.jl:1118
[9] materialize
@ ./broadcast.jl:903 [inlined]
[10] get_pages(resp::HTTP.Messages.Response)
@ CoinbasePro ~/.julia/packages/CoinbasePro/c2X4C/src/utils.jl:5
[11] _get_trades(url::String)
@ CoinbasePro ~/.julia/packages/CoinbasePro/c2X4C/src/trades.jl:14
[12] trades
@ ~/.julia/packages/CoinbasePro/c2X4C/src/trades.jl:20 [inlined]
[13] lasttrades(ccy::String, n::Int64)
@ CoinbasePro ~/.julia/packages/CoinbasePro/c2X4C/src/trades.jl:33
[14] top-level scope
@ In[98]:1

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!

Inexact conversion error when getting CoinbasePro.trades

First of all, thanks for making the package and writing up the blog post! Really helpful tutorial.

I run into an issue when I get to the "Last 1000 Trades" section. Running the command from the blog post yields the following:

julia> trades, pages = CoinbasePro.trades("BTC-USD")
ERROR: InexactError: convert(Dates.Decimal3, 981)
Stacktrace:
  [1] tryparsenext
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/io.jl:153 [inlined]
  [2] tryparsenext
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/io.jl:41 [inlined]
  [3] macro expansion
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/parse.jl:64 [inlined]
  [4] tryparsenext_core(str::SubString{String}, pos::Int64, len::Int64, df::Dates.DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.sss"), Tuple{Dates.DatePart{'y'}, Dates.Delim{Char, 1}, Dates.DatePart{'m'}, Dates.Delim{Char, 1}, Dates.DatePart{'d'}, Dates.Delim{Char, 1}, Dates.DatePart{'H'}, Dates.Delim{Char, 1}, Dates.DatePart{'M'}, Dates.Delim{Char, 1}, Dates.DatePart{'S'}, Dates.Delim{Char, 1}, Dates.DatePart{'s'}}}, raise::Bool)
    @ Dates /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/parse.jl:38
  [5] macro expansion
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/parse.jl:150 [inlined]
  [6] tryparsenext_internal
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/parse.jl:125 [inlined]
  [7] parse(::Type{Dates.DateTime}, str::SubString{String}, df::Dates.DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.sss"), Tuple{Dates.DatePart{'y'}, Dates.Delim{Char, 1}, Dates.DatePart{'m'}, Dates.Delim{Char, 1}, Dates.DatePart{'d'}, Dates.Delim{Char, 1}, Dates.DatePart{'H'}, Dates.Delim{Char, 1}, Dates.DatePart{'M'}, Dates.Delim{Char, 1}, Dates.DatePart{'S'}, Dates.Delim{Char, 1}, Dates.DatePart{'s'}}})
    @ Dates /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/parse.jl:282
  [8] DateTime
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Dates/src/io.jl:483 [inlined]
  [9] _broadcast_getindex_evalf
    @ ./broadcast.jl:648 [inlined]
 [10] _broadcast_getindex
    @ ./broadcast.jl:621 [inlined]
 [11] getindex
    @ ./broadcast.jl:575 [inlined]
 [12] macro expansion
    @ ./broadcast.jl:984 [inlined]
 [13] macro expansion
    @ ./simdloop.jl:77 [inlined]
 [14] copyto!
    @ ./broadcast.jl:983 [inlined]
 [15] copyto!
    @ ./broadcast.jl:936 [inlined]
 [16] copy
    @ ./broadcast.jl:908 [inlined]
 [17] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{Dates.DateTime}, Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(chop), Tuple{Vector{String}}}, Base.RefValue{Dates.DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.sss"), Tuple{Dates.DatePart{'y'}, Dates.Delim{Char, 1}, Dates.DatePart{'m'}, Dates.Delim{Char, 1}, Dates.DatePart{'d'}, Dates.Delim{Char, 1}, Dates.DatePart{'H'}, Dates.Delim{Char, 1}, Dates.DatePart{'M'}, Dates.Delim{Char, 1}, Dates.DatePart{'S'}, Dates.Delim{Char, 1}, Dates.DatePart{'s'}}}}}})
    @ Base.Broadcast ./broadcast.jl:883
 [18] _get_trades(url::String)
    @ CoinbasePro ~/.julia/packages/CoinbasePro/LqTjF/src/trades.jl:9
 [19] trades(ccy::String)
    @ CoinbasePro ~/.julia/packages/CoinbasePro/LqTjF/src/trades.jl:18
 [20] top-level scope
    @ REPL[1]:1

Here's my versioninfo()

julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, icelake-client)
Environment:
  JULIA_EDITOR = "/home/yenson/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/node"
  JULIA_NUM_THREADS = 

I might go and debug it later bug just wanted to give you a heads up in case you know a quick way to fix it. Thanks!

CoinbasePro.book("btc-usd", 2) throws ArgumentError

Running Julia on Windows 10

julia> CoinbasePro.book("btc-usd", 2) 
ERROR: ArgumentError: New columns must have the same length as old columns
Stacktrace:
 [1] insert_single_column!(df::DataFrame, v::Vector{Int64}, col_ind::Symbol)
  @ DataFrames ... \dataframe.jl:598
[2] setindex!(df::DataFrame, v::Vector{Int64}, #unused#::typeof(!), col_ind::Symbol)
  @ DataFrames ... \dataframe.jl:628
[3] hcat!(df1::DataFrame, df2::DataFrame; makeunique::Bool, copycols::Bool)
   @ DataFrames ... \dataframe.jl:1038

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.