Browse Source

Test

etomic
jl777 8 years ago
parent
commit
70d2b9d49f
  1. 46
      iguana/exchanges/LP_ordermatch.c

46
iguana/exchanges/LP_ordermatch.c

@ -585,34 +585,42 @@ char *LP_autotrade(char *myipaddr,int32_t mypubsock,double profitmargin,char *ba
return(clonestr("{\"error\":\"cant set ordermatch quote info\"}")); return(clonestr("{\"error\":\"cant set ordermatch quote info\"}"));
price = LP_query(myipaddr,mypubsock,profitmargin,"request",&Q); price = LP_query(myipaddr,mypubsock,profitmargin,"request",&Q);
bestitem = LP_quotejson(&Q); bestitem = LP_quotejson(&Q);
if ( price <= maxprice ) if ( price > SMALLVAL )
{ {
price = LP_query(myipaddr,mypubsock,profitmargin,"connect",&Q); if ( price <= maxprice )
LP_requestinit(&Q.R,Q.srchash,Q.desthash,base,Q.satoshis,Q.destcoin,Q.destsatoshis,Q.timestamp,Q.quotetime,DEXselector);
expiration = (uint32_t)time(NULL) + timeout;
while ( time(NULL) < expiration )
{ {
if ( autxo->S.swap != 0 ) price = LP_query(myipaddr,mypubsock,profitmargin,"connect",&Q);
break; LP_requestinit(&Q.R,Q.srchash,Q.desthash,base,Q.satoshis,Q.destcoin,Q.destsatoshis,Q.timestamp,Q.quotetime,DEXselector);
sleep(1); expiration = (uint32_t)time(NULL) + timeout;
while ( time(NULL) < expiration )
{
if ( autxo->S.swap != 0 )
break;
sleep(1);
}
if ( autxo->S.swap == 0 )
{
jaddstr(bestitem,"status","couldnt establish connection");
LP_availableset(autxo);
}
else jaddstr(bestitem,"status","connected");
jaddnum(bestitem,"quotedprice",price);
jaddnum(bestitem,"maxprice",maxprice);
jaddnum(bestitem,"requestid",Q.R.requestid);
jaddnum(bestitem,"quoteid",Q.R.quoteid);
printf("Alice r.%u q.%u\n",Q.R.requestid,Q.R.quoteid);
} }
if ( autxo->S.swap == 0 ) else
{ {
jaddstr(bestitem,"status","couldnt establish connection"); jaddnum(bestitem,"quotedprice",price);
LP_availableset(autxo); jaddnum(bestitem,"maxprice",maxprice);
jaddstr(bestitem,"status","too expensive");
} }
else jaddstr(bestitem,"status","connected");
jaddnum(bestitem,"quotedprice",price);
jaddnum(bestitem,"maxprice",maxprice);
jaddnum(bestitem,"requestid",Q.R.requestid);
jaddnum(bestitem,"quoteid",Q.R.quoteid);
printf("Alice r.%u q.%u\n",Q.R.requestid,Q.R.quoteid);
} }
else else
{ {
jaddnum(bestitem,"quotedprice",price);
jaddnum(bestitem,"maxprice",maxprice); jaddnum(bestitem,"maxprice",maxprice);
jaddstr(bestitem,"status","too expensive"); jaddstr(bestitem,"status","no response to request");
} }
return(jprint(bestitem,0)); return(jprint(bestitem,0));
} }

Loading…
Cancel
Save