GithubHelp home page GithubHelp logo

confessore / coinbaseat Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 131 KB

The unofficial .NET/C# client library for the Coinbase Advanced Trade API

License: MIT License

C# 100.00%
coinbase coinbase-advanced coinbase-advanced-trade coinbase-api

coinbaseat's Introduction

CoinbaseAT

Coinbase Advanced Trade

v1.1 Change Log

  • Coinbase updated in January to Coinbase Cloud
    • Now generates a jwt for authorization
    • It is now required to use a Coinbase Cloud API Key
    • Legacy API Keys are currently deprecated
    • The bits still exist to support legacy keys

Initial Release

CoinbaseAT is now initially released!

You can find the package on nuget at https://www.nuget.org/packages/CoinbaseAT/

Feel free to open pull requests or issues

Currently

v3 Signature Generator is functional and ready to sign headers

All models are created (please open an issue if there is something missing but I am pretty sure that they are all there)

ALL services are created (please open an issue if there is something missing but I am pretty sure that they are all there)

coinbaseat's People

Contributors

confessore avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

iq220

coinbaseat's Issues

`Method with optional parameter is hidden by overload` warning in `CoinbaseATService.cs`

image
Figure 1. Warning about Method with optional parameter is hidden by overload.

@confessore, This is great code, and I wish it were available for .NET Framework 4.8. I am going ahead and porting over my own adaption of the code myself,

This code has to do with the two overloads of the SendServiceCall<T> method in CoinbaseATService.cs. One overload has a signature of async Task<T> SendServiceCall<T>(HttpMethod, string string) and the other overload has the signature async Task<T> SendServiceCall<T>(HttpMethod, string string, string) but the first and second overloads both have the final string parameter as optional.

This is not an optimal way to craft the code; I wish I could come up with a solution but I don't yet know the codebase well enough to fix it.

Suggestion: Rename, e.g., `AccountsService` property of `CoinbaseATClient` to `Accounts`, etc.

Hello @confessore ,

May I make a suggestion for better semantics?

In your CoinbaseATClient class, there are properties

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IAccountsService AccountsService { get; }

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IFeesService FeesService { get; }

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IOrdersService OrdersService { get; }

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IProductsService ProductsService { get; }

I suggest they be named:

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IAccountsService Accounts { get; }

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IFeesService Fees { get; }

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IOrdersService Orders { get; }

        /// <summary>
        ///     <inheritdoc />
        /// </summary>
        public IProductsService Products { get; }

This naming style does seem to more closely resemble the convention for API clients.

Please make a version for .NET Framework 4.8 compatibility

@confessore Hi,

I frequently still like to use .NET Framework 4.8 / 4.8.1 in my projects. I respectfully request if you could please make a version of the NuGet package that has compatibility with those framework versions. Currently, the NuGet package will not install in my .NET Framework 4.8 project. Thank you.

How do i place an order?

I havethis but it is not working:
OrderConfiguration orderConfiguration = new OrderConfiguration() { Market_Market_Loc = new MarketMarketLoc(){Base_Size = "20.00"} };
var ord = await _coinbaseAtClient.OrdersService.CreateOrderAsync(Guid.NewGuid().ToString(),
"BTC-USD", "sell", orderConfiguration);

Any code samples?

Hi,
Thanks for this. Are there any simple code examples demonstrating the use of the library available, to get people started? I don't see anything in the source distribution and no Wiki. I guess people may already be familiar with the API, but, my first dabble!

Thanks.

Authentication Issue

So i am trying to use this is a Blazor Server .Net 8 Project and am having an issue getting the authentication to work. Everytime i try to submit the trade, i receive the Unauthorized response.

I am registering the service like this in my Program.cs
var configuration = new CoinbaseATConfiguration(

    apiKey, apiSecret
);

builder.Services.AddSingleton<ICoinbaseATConfiguration>(configuration);
builder.Services.AddSingleton<ICoinbaseATClient, CoinbaseATClient>();
 // builder.Services.AddSingleton<CoinbaseATClient>();

I am injecting the CoinbaseAtClient like this in my .Razor page:

@inject ICoinbaseATClient CoinbaseATClient

@code {
// ...
var result = await AtService.CreatMarketOrderAsync(Guid.NewGuid().ToString(), crypto.ProductId, OrderSide.BUY.ToString(), order_configuration);
var acct = await CoinbaseATClient.ProductsService.GetProductAsync("BTC-USD");
}

and here is my exception
---> System.Exception: Exception of type 'System.Exception' was thrown. --- End of inner exception stack trace --- at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendHttpRequestMessageAsync(HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendServiceCall[T](HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.ProductsService.GetProductAsync(String product_id) at BotTrading.Shared.CryptoComponent.CryptoComponent.SubmitPosition(String orderType, OrderSide orderSide) in C:\Users\Stephanie\source\repos\BotTrading\BotTrading\Shared\CryptoComponent\CryptoComponent.razor:line 123

When i try to query an endpoint that doesnt require authentication i get this error:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.HttpIOException: The response ended prematurely. (ResponseEnded) at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.<SendCoreAsync>g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendCoreAsync>g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendHttpRequestMessageAsync(HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendServiceCall[T](HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.ProductsService.GetProductAsync(String product_id) at BotTrading.Shared.CryptoComponent.CryptoComponent.SubmitPosition(String orderType, OrderSide orderSide) in C:\Users\Stephanie\source\repos\BotTrading\BotTrading\Shared\CryptoComponent\CryptoComponent.razor:line

I have already verified that my apiKey and apiSecret are correct and that they are being passeed into my CoinbaseATConfiguration, I am able to do api calls with these same credentials with another library package. I cant figure out what is causing this. I have the same problem in both the razor file and in the service file.

I even tried it with the ICoinbaseAtClient for good measure, and tried registering the CoinbaseAtClient independntly as well in my Program.cs to no avail. Do you have any hints on what could resolve this issue? I really love the project and how thourough it is i do not want to remove it because nothing else is this complete. Very nice work, and thank you for any help you can offer!

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.