dougdellolio / coinbasepro-csharp

The unofficial .NET/C# client library for the Coinbase Pro/GDAX API
MIT License
192 stars 90 forks source link

How to use Profile/Porfolio? #244

Closed salocinx closed 4 years ago

salocinx commented 4 years ago

Hi. Is it somehow possible to place orders for a specific portfolio? When studying the API, I cannot make any sense how to use the portfolio/profiles other than querying and listing them. Do they have any other usable function within the API? I guess I misunderstand some of the concept.

dougdellolio commented 4 years ago

hi @salocinx. API keys are scoped to a specific profile (aka portfolio) so when you create an API key, you have the option to select which Portfolio to use with that key.

image

in other words, you would have different API keys for different profiles. There is no way to pass the profile name or id into the order request other than by using its corresponding keys when creating the CoinbaseProClient.

salocinx commented 4 years ago

Thanks very much for the clarification! I missed that, but now I got it 👍

Is it possible to have multiple CoinbaseProClient instances connecting to different profiles/portfolios simultaneously?

dougdellolio commented 4 years ago

no problem! and i don't see why not. You would have to create multiple instances of the authenticator and use the corresponding client for that profile to place an order

maybe something like this:

var profile1 = new Authenticator("<apiKeyProfile1>", "<apiSecretProfile1>", "<passphraseProfile1>");
var profile2 = new Authenticator("<apiKeyProfile2>", "<apiSecretProfile2>", "<passphraseProfile2>");
var profile3 = new Authenticator("<apiKeyProfile3>", "<apiSecretProfile3>", "<passphraseProfile3>");

var coinbaseProClientProfile1 = new CoinbaseProClient(profile1);
var coinbaseProClientProfile2 = new CoinbaseProClient(profile2);
var coinbaseProClientProfile3 = new CoinbaseProClient(profile3);
salocinx commented 4 years ago

Thank you! Now everything seems to work fine 👍