예제 #1
0
uint64_t TRADE(char **retstrp,struct exchange_info *exchange,char *base,char *rel,int32_t dir,double price,double volume)
{
    char payload[1024],pairstr[64],pricestr[64],*extra,*method; cJSON *json; int32_t type; uint64_t txid = 0;
    if ( (extra= *retstrp) != 0 )
        *retstrp = 0;
    if ( (dir= flipstr_for_exchange(exchange,pairstr,"%s%s",dir,&price,&volume,base,rel)) == 0 )
    {
        printf("cant find baserel (%s/%s)\n",base,rel);
        return(0);
    }
    if ( extra != 0 && strcmp(extra,"market") == 0 )
        method = (dir > 0) ? "buy_market" : "sell_market";
    else method = (dir > 0) ? "buy" : "sell", sprintf(pricestr,"&price=%.2f",price);
    if ( strcmp(pairstr,"btccny") == 0 )
        type = 1;
    else if ( strcmp(pairstr,"ltccny") == 0 )
        type = 2;
    else
    {
        printf("cant find baserel (%s/%s)\n",base,rel);
        return(0);
    }
    sprintf(payload,"&amount=%.4f&coin_type=%d%s",volume,type,pricestr);
    if ( (json= huobi_issue_auth(exchange,method,payload)) != 0 )
    {
        txid = j64bits(json,"order_id");
        free_json(json);
    }
    return(txid);
}
예제 #2
0
char *WITHDRAW(struct exchange_info *exchange,cJSON *argjson)
{
    char payload[1024],*base,*destaddr,*method; double amount;
    if ( (base= jstr(argjson,"base")) == 0 || strcmp(base,"BTC") != 0 )
        return(clonestr("{\"error\":\"base not specified or base != BTC\"}"));
    if ( (destaddr= jstr(argjson,"destaddr")) == 0 )
        return(clonestr("{\"error\":\"destaddr not specified\"}"));
    if ( (amount= jdouble(argjson,"amount")) < SMALLVAL )
        return(clonestr("{\"error\":\"amount not specified\"}"));
    method = "withdraw_coin";
    sprintf(payload,"&coin_type=1&withdraw_address=%s&withdraw_amount=%.4f",destaddr,amount);
    return(jprint(huobi_issue_auth(exchange,method,payload),1));
}
예제 #3
0
파일: huobi.c 프로젝트: Miyurz/SuperNET
char *WITHDRAW(struct exchange_info *exchange,char *base,double amount,char *destaddr,cJSON *argjson)
{
    char payload[1024],*method;
    if ( base == 0 || base[0] == 0 )
        return(clonestr("{\"error\":\"base not specified\"}"));
    if ( destaddr == 0 || destaddr[0] == 0 )
        return(clonestr("{\"error\":\"destaddr not specified\"}"));
    if ( amount < SMALLVAL )
        return(clonestr("{\"error\":\"amount not specified\"}"));
    method = "withdraw_coin";
    sprintf(payload,"&coin_type=1&withdraw_address=%s&withdraw_amount=%.4f",destaddr,amount);
    return(jprint(huobi_issue_auth(&exchange->cHandle,exchange,method,payload),1));
}
예제 #4
0
char *OPENORDERS(struct exchange_info *exchange,cJSON *argjson)
{
    return(jprint(huobi_issue_auth(exchange,"get_orders","&coin_type=1"),1));
}
예제 #5
0
char *CANCELORDER(struct exchange_info *exchange,cJSON *argjson,uint64_t quoteid)
{
    char payload[1024];
    sprintf(payload,"&id=%llu&coin_type=1",(long long)quoteid);
    return(jprint(huobi_issue_auth(exchange,"cancel_order",payload),1));
}
예제 #6
0
cJSON *BALANCES(struct exchange_info *exchange)
{
    return(huobi_issue_auth(exchange,"get_account_info",""));
}
예제 #7
0
파일: huobi.c 프로젝트: jl777/SuperNET_API
cJSON *BALANCES(void **cHandlep,struct exchange_info *exchange)
{
    return(huobi_issue_auth(cHandlep,exchange,"get_account_info",""));
}
예제 #8
0
파일: huobi.c 프로젝트: jl777/SuperNET_API
char *ORDERSTATUS(void **cHandlep,struct exchange_info *exchange,cJSON *argjson,uint64_t quoteid)
{
    char payload[1024];
    sprintf(payload,"&id=%llu&coin_type=1",(long long)quoteid);
    return(jprint(huobi_issue_auth(cHandlep,exchange,"order_info",payload),1));
}
예제 #9
0
파일: huobi.c 프로젝트: Miyurz/SuperNET
cJSON *BALANCES(struct exchange_info *exchange,cJSON *argjson)
{
    return(huobi_issue_auth(&exchange->cHandle,exchange,"get_account_info",""));
}