Browse Source

Test

etomic
jl777 8 years ago
parent
commit
fbf9f23fa6
  1. 2
      iguana/exchanges/LP_nativeDEX.c
  2. 9
      iguana/exchanges/LP_ordermatch.c
  3. 37
      iguana/exchanges/LP_portfolio.c
  4. 4
      iguana/exchanges/LP_utxos.c

2
iguana/exchanges/LP_nativeDEX.c

@ -52,7 +52,7 @@ uint16_t LP_fixed_pairport,LP_publicport;
int32_t LP_mybussock = -1;
int32_t LP_mypubsock = -1;
int32_t LP_mypullsock = -1;
int32_t USERPASS_COUNTER,IAMLP = 0;
int32_t LP_pendingswaps,USERPASS_COUNTER,IAMLP = 0;
uint32_t LP_sessionid;
double LP_profitratio = 1.;
bits256 LP_mypub25519,LP_mypriv25519;

9
iguana/exchanges/LP_ordermatch.c

@ -448,6 +448,7 @@ char *LP_connectedalice(cJSON *argjson) // alice
if ( (qprice= LP_quote_validate(&autxo,&butxo,&Q,0)) <= SMALLVAL )
{
LP_availableset(autxo);
LP_pendingswaps--;
printf("quote validate error %.0f\n",qprice);
return(clonestr("{\"error\":\"quote validation error\"}"));
}
@ -455,6 +456,7 @@ char *LP_connectedalice(cJSON *argjson) // alice
{
printf("this node has no price for %s/%s (%.8f %.8f)\n",Q.destcoin,Q.srccoin,bid,ask);
LP_availableset(autxo);
LP_pendingswaps--;
return(clonestr("{\"error\":\"no price set\"}"));
}
printf("%s/%s bid %.8f ask %.8f\n",Q.srccoin,Q.destcoin,bid,ask);
@ -464,10 +466,12 @@ char *LP_connectedalice(cJSON *argjson) // alice
{
printf("qprice %.8f too big vs %.8f\n",qprice,price);
LP_availableset(autxo);
LP_pendingswaps--;
return(clonestr("{\"error\":\"quote price too expensive\"}"));
}
if ( (coin= LP_coinfind(Q.destcoin)) == 0 )
{
LP_pendingswaps++;
return(clonestr("{\"error\":\"cant get alicecoin\"}"));
}
Q.privkey = LP_privkey(Q.destaddr,coin->taddr);
@ -498,11 +502,13 @@ char *LP_connectedalice(cJSON *argjson) // alice
printf("connected result.(%s)\n",jprint(retjson,0));
if ( jobj(retjson,"error") != 0 )
LP_availableset(autxo);
else LP_pendingswaps--;
return(jprint(retjson,1));
}
else
{
LP_availableset(autxo);
LP_pendingswaps--;
printf("no privkey found\n");
return(clonestr("{\"error\",\"no privkey\"}"));
}
@ -618,7 +624,7 @@ struct LP_utxoinfo *LP_bestutxo(double *ordermatchpricep,int64_t *bestsatoshisp,
if ( (qprice= LP_qprice_calc(&destsatoshis,&satoshis,(price*(100.+j))/100.,butxo->S.satoshis,txfee,autxo->payment.value,maxdestsatoshis,desttxfee)) > price+SMALLVAL )
break;
}
printf("j.%d/%d qprice %.8f vs price %.8f best.(%.8f %.8f)\n",j,n,qprice,price,dstr(satoshis),dstr(destsatoshis));
//printf("j.%d/%d qprice %.8f vs price %.8f best.(%.8f %.8f)\n",j,n,qprice,price,dstr(satoshis),dstr(destsatoshis));
if ( metric < 1.2 && destsatoshis > desttxfee && destsatoshis-desttxfee > (autxo->payment.value / LP_MINCLIENTVOL) && satoshis-txfee > (butxo->S.satoshis / LP_MINVOL) && satoshis <= butxo->payment.value-txfee )
{
printf("value %.8f price %.8f/%.8f best %.8f destsatoshis %.8f * metric %.8f -> (%f)\n",dstr(autxo->payment.value),price,bestprice,bestmetric,dstr(destsatoshis),metric,dstr(destsatoshis) * metric * metric * metric);
@ -747,6 +753,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q
}
if ( aliceutxo->S.swap == 0 )
LP_availableset(aliceutxo);
else LP_pendingswaps++;
return(jprint(bestitem,0));
}

37
iguana/exchanges/LP_portfolio.c

@ -426,30 +426,33 @@ void prices_loop(void *ignore)
LP_portfolio_relvolume = 0.;
if ( LP_pricevalid(maxprice) > 0 )
{
printf("base buy.%s force %f, rel sell.%s force %f relvolume %f maxprice %.8f (%.8f %.8f)\n",buycoin,jdouble(retjson,"buyforce"),sellcoin,jdouble(retjson,"sellforce"),sell->relvolume,maxprice,bid,ask);
relvolume = sell->relvolume;
for (iter=0; iter<3; iter++)
printf("pending.%d base buy.%s force %f, rel sell.%s force %f relvolume %f maxprice %.8f (%.8f %.8f)\n",LP_pendingswaps,buycoin,jdouble(retjson,"buyforce"),sellcoin,jdouble(retjson,"sellforce"),sell->relvolume,maxprice,bid,ask);
if ( LP_pendingswaps == 0 )
{
requestid = quoteid = 0;
if ( LP_utxo_bestfit(sellcoin,SATOSHIDEN * relvolume) != 0 )
relvolume = sell->relvolume;
for (iter=0; iter<3; iter++)
{
if ( (retstr2= LP_autotrade(ctx,"127.0.0.1",-1,buycoin,sellcoin,maxprice,relvolume,60,24*3600)) != 0 )
requestid = quoteid = 0;
if ( LP_utxo_bestfit(sellcoin,SATOSHIDEN * relvolume) != 0 )
{
if ( (retjson2= cJSON_Parse(retstr2)) != 0 )
if ( (retstr2= LP_autotrade(ctx,"127.0.0.1",-1,buycoin,sellcoin,maxprice,relvolume,60,24*3600)) != 0 )
{
if ( (requestid= juint(retjson2,"requestid")) != 0 && (quoteid= juint(retjson2,"quoteid")) != 0 )
if ( (retjson2= cJSON_Parse(retstr2)) != 0 )
{
if ( (requestid= juint(retjson2,"requestid")) != 0 && (quoteid= juint(retjson2,"quoteid")) != 0 )
{
}
free_json(retjson2);
}
free_json(retjson2);
printf("%s relvolume %.8f LP_autotrade.(%s)\n",sellcoin,relvolume,retstr2);
free(retstr2);
}
printf("%s relvolume %.8f LP_autotrade.(%s)\n",sellcoin,relvolume,retstr2);
free(retstr2);
}
if ( requestid != 0 && quoteid != 0 )
break;
} else printf("cant find alice %.8f %s\n",relvolume,sellcoin);
relvolume *= 0.1;
if ( requestid != 0 && quoteid != 0 )
break;
} else printf("cant find alice %.8f %s\n",relvolume,sellcoin);
relvolume *= 0.1;
}
}
}
else

4
iguana/exchanges/LP_utxos.c

@ -401,7 +401,7 @@ struct LP_utxoinfo *LP_utxo_bestfit(char *symbol,uint64_t destsatoshis)
}
HASH_ITER(hh,LP_utxoinfos[0],utxo,tmp)
{
char str[65]; printf("s%u %d [%.8f vs %.8f] check %s.%s avail.%d ismine.%d >= %d\n",utxo->T.spentflag,LP_iseligible(&srcvalue,&srcvalue2,utxo->iambob,symbol,utxo->payment.txid,utxo->payment.vout,utxo->S.satoshis,utxo->fee.txid,utxo->fee.vout),dstr(destsatoshis),dstr(utxo->S.satoshis),utxo->coin,bits256_str(str,utxo->payment.txid),LP_isavailable(utxo) > 0,LP_ismine(utxo) > 0,utxo->S.satoshis >= destsatoshis);
//char str[65]; printf("s%u %d [%.8f vs %.8f] check %s.%s avail.%d ismine.%d >= %d\n",utxo->T.spentflag,LP_iseligible(&srcvalue,&srcvalue2,utxo->iambob,symbol,utxo->payment.txid,utxo->payment.vout,utxo->S.satoshis,utxo->fee.txid,utxo->fee.vout),dstr(destsatoshis),dstr(utxo->S.satoshis),utxo->coin,bits256_str(str,utxo->payment.txid),LP_isavailable(utxo) > 0,LP_ismine(utxo) > 0,utxo->S.satoshis >= destsatoshis);
if ( strcmp(symbol,utxo->coin) != 0 )
continue;
if ( LP_isavailable(utxo) > 0 && LP_ismine(utxo) > 0 )
@ -415,7 +415,7 @@ struct LP_utxoinfo *LP_utxo_bestfit(char *symbol,uint64_t destsatoshis)
continue;
}
bestutxo = utxo;
} else printf("skip alice utxo %.8f vs dest %.8f\n",dstr(utxo->S.satoshis),dstr(destsatoshis));
} //else printf("skip alice utxo %.8f vs dest %.8f\n",dstr(utxo->S.satoshis),dstr(destsatoshis));
}
}
return(bestutxo);

Loading…
Cancel
Save