JKorf / HTX.Net

A C# .netstandard client library for the Huobi REST and Websocket Spot and Swap API focusing on clear usage and models
https://jkorf.github.io/HTX.Net/
MIT License
73 stars 53 forks source link

Error Placing Order #78

Closed RichardeReyes closed 2 years ago

RichardeReyes commented 2 years ago

I am having this error placing an order:

"{: order-source-invalid, invalid order source spot-api }"

this is the line i am using:

var callResult = await client.PlaceOrderAsync(accounts.Data.First().Id, "btcusdt", HuobiOrderType.MarketBuy, 0.000127m);

I created the Api Key with the Trade Permission.

Could You Help me?

JKorf commented 2 years ago

Hi, I can't reproduce this. The source parameter isn't send to the server in your example, it's only send when the source argument is provided. I tried it both with and without source parameter and it seems to work as expected for me.

mg10100 commented 2 years ago

I am having this error too. I tried this way, but does't work. var callResult = await api.PlaceOrderAsync(accountResult.Data.First().Id, order.parsymbol, // adausdt HuobiOrderType.LimitBuy, Decimal.Parse(qtdbuy), 13.000 Decimal.Parse(szbuy), 1.3000 SourceType.Spot.ToString()); // I have tried without this parameter. The error returned is: : order-source-invalid, invalid order source spot-api

mg10100 commented 2 years ago

The values 13.000 and 1.300 are "//"

mg10100 commented 2 years ago

Hi JKort. I believe that i know what's happing ... There are more than 1 account in Huobi, 1 account for spot, 1 account for otc etc.... Please, see the docs in Huobi: /v1/account/accounts The account-id defines the Identity for different business type, it can be retrieved from API /v1/account/accounts , where the account-type is the business types. The types include: spot: Spot account otc: OTC account

The first account is not spot: var callResult = await client.PlaceOrderAsync(accountResult.Data.First().Id, /// is other account. When we place an order we use this one. First().Id , but it's not correct.. (I thinking..... ) How can I take the correct Spot account ?

Thanks. Maria

RichardeReyes commented 2 years ago

Hi JKort. I believe that i know what's happing ... There are more than 1 account in Huobi, 1 account for spot, 1 account for otc etc.... Please, see the docs in Huobi: /v1/account/accounts The account-id defines the Identity for different business type, it can be retrieved from API /v1/account/accounts , where the account-type is the business types. The types include: spot: Spot account otc: OTC account

The first account is not spot: var callResult = await client.PlaceOrderAsync(accountResult.Data.First().Id, /// is other account. When we place an order we use this one. First().Id , but it's not correct.. (I thinking..... ) How can I take the correct Spot account ?

Thanks. Maria

You are right, I tried this:

long lxId = accounts.Data.ElementAt(1).Id; //takes the second account

var callResult = await client.PlaceOrderAsync(lxId, "btcusdt", HuobiOrderType.MarketBuy, 0.000127m);

It is working now

RichardeReyes commented 2 years ago

we can use this to get the Id of the Spot Account :

long lxId = 0;

foreach(var lxAcc in accounts.Data) { if(lxAcc.Type== HuobiAccountType.Spot) { lxId = lxAcc.Id; } }