Skip to content

Commit

Permalink
show_fills + README + version update
Browse files Browse the repository at this point in the history
  • Loading branch information
vnegi10 committed Jul 12, 2021
1 parent 5c51126 commit 53ea610
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CoinbaseProExchange"
uuid = "06c3450d-869c-4596-88b4-6f9fb82f72bd"
authors = ["Vikas Negi <[email protected]>"]
version = "0.1.1"
version = "0.1.2"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Examples of available functions along with expected output are shown below. Deta

### Available functions

show_historical_data, show_server_time, show_all_products, show_latest_trades, show_product_data, show_all_accounts, show_account_info, place_market_order, place_limit_order, show_open_orders, show_single_order, show_exchange_limits, cancel_order, cancel_all_orders
show_historical_data, show_server_time, show_all_products, show_latest_trades, show_product_data, show_all_accounts, show_account_info, place_market_order, place_limit_order, show_open_orders, show_single_order, show_exchange_limits, show_fills, cancel_order, cancel_all_orders

### Public endpoints (Coinbase account is not necessary)

Expand Down Expand Up @@ -222,6 +222,20 @@ julia> show_exchange_limits(user_data, "ETH")
5 │ paypal_withdrawal 11.7138 1 11.7138
```
```julia
julia> show_fills(user_data, "ETH-EUR")

7×13 DataFrame
Row │ created_at fee liquidity order_id price
│ String String String String String
─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
12021-07-04T21:54:09.902Z 0.0746268391200000 T d275ae2b-4f34-4ce9-98a7-1147bccf 2003.90
22021-07-04T15:43:54.115Z 0.0733968750000000 T 7a019bf8-bee8-4001-bb34-e3d6f3e6 1957.25
32021-07-04T15:42:35.808Z 0.0597014279730000 T 2a8814f1-76d3-4fa2-bb0a-6f25e050 1956.42
42021-07-04T15:28:06.005Z 0.0599999776075000 T 9971744a-d308-4481-950d-e2ada197 1953.35
```
Expand Down
2 changes: 2 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ cancel_order(order_id::String, user_data::UserInfo)
cancel_all_orders(user_data::UserInfo)
show_exchange_limits(user_data::UserInfo, currency::String)
show_fills(user_data::UserInfo, pair::String)
```


Expand Down
2 changes: 1 addition & 1 deletion src/CoinbaseProExchange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export show_historical_data, show_server_time, show_all_products,
show_latest_trades, show_product_data, show_all_accounts,
show_account_info, place_market_order, place_limit_order,
show_open_orders, show_single_order, show_exchange_limits,
cancel_order, cancel_all_orders, UserInfo
show_fills, cancel_order, cancel_all_orders, UserInfo

using DataFrames, HTTP, JSON, CSV, Dates, Statistics, Query, Base64, Nettle

Expand Down
8 changes: 8 additions & 0 deletions src/GetDataFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ function get_exchange_limits(auth_data::CoinbaseProAuth, currency::String)
return df_limits
end

function get_fills(auth_data::CoinbaseProAuth)

account_dict = get_data_dict(auth_data::CoinbaseProAuth)

return vcat(DataFrame.(account_dict)...)
end





Expand Down
41 changes: 41 additions & 0 deletions src/ShowDataFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,47 @@ function show_exchange_limits(user_data::UserInfo, currency::String)
return df_limits
end

"""
show_fills(user_data::UserInfo, pair::String)
Get a list of recent fills of the API key's profile for a given pair.
# Arguments
- `user_data::UserInfo` : API data
- `pair::String` : "ETH-EUR" etc.
# Example
```julia-repl
julia> show_fills(user_data, "ETH-EUR")
7×13 DataFrame
Row │ created_at fee liquidity order_id price ⋯
│ String String String String String ⋯
─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ 2021-07-04T21:54:09.902Z 0.0746268391200000 T d275ae2b-4f34-4ce9-98a7-1147bccf… 2003.90 ⋯
2 │ 2021-07-04T15:43:54.115Z 0.0733968750000000 T 7a019bf8-bee8-4001-bb34-e3d6f3e6… 1957.25
3 │ 2021-07-04T15:42:35.808Z 0.0597014279730000 T 2a8814f1-76d3-4fa2-bb0a-6f25e050… 1956.42
4 │ 2021-07-04T15:28:06.005Z 0.0599999776075000 T 9971744a-d308-4481-950d-e2ada197… 1953.35
```
"""
function show_fills(user_data::UserInfo, pair::String)
auth_data = CoinbaseProAuth("/fills?product_id=$(pair)", user_data.api_key, user_data.secret_key, user_data.passphrase, "GET", "")

df_fills = DataFrame()
try
df_fills = get_fills(auth_data)
catch e
if isa(e, HTTP.ExceptionRequest.StatusError)
@info "404 Not Found - Check if the input data is valid"
else
@info "Could not retrieve data, try again!"
end
end

return df_fills
end






Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ df_account_history = show_account_info(user_data, "ETH", "history")
df_limits = show_exchange_limits(user_data, "ETH")
@test isa(df_limits, DataFrame)
df_fills = show_fills(user_data, "ETH-EUR")
@test isa(df_fills, DataFrame)
end =#


Expand Down

2 comments on commit 53ea610

@vnegi10
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • Added new function 'show_fills'
  • Fixed documentation

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/40764

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.2 -m "<description of version>" 53ea6102dcceb85da8a5d5e2670ee1d91d7894f8
git push origin v0.1.2

Please sign in to comment.