|
|
@ -837,7 +837,8 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru |
|
|
|
qp = newqp; |
|
|
|
if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) |
|
|
|
return(0); |
|
|
|
//printf("LP_trades_gotrequest %s/%s %.8f\n",qp->srccoin,qp->destcoin,LP_trades_bobprice(&bid,&ask,qp));
|
|
|
|
if ( strcmp(qp->srccoin,"GRS") == 0 || strcmp(qp->destcoin,"GRS") == 0 ) |
|
|
|
printf("LP_trades_gotrequest %s/%s myprice %.8f\n",qp->srccoin,qp->destcoin,LP_trades_bobprice(&bid,&ask,qp)); |
|
|
|
if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) |
|
|
|
return(0); |
|
|
|
autxo = &A; |
|
|
@ -856,7 +857,8 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru |
|
|
|
memset(&qp->txid2,0,sizeof(qp->txid2)); |
|
|
|
qp->vout = qp->vout2 = -1; |
|
|
|
} else return(0); |
|
|
|
//printf("LP_trades_gotrequest qprice %.8f vs myprice %.8f\n",qprice,myprice);
|
|
|
|
if ( strcmp(qp->srccoin,"GRS") == 0 || strcmp(qp->destcoin,"GRS") == 0 ) |
|
|
|
printf("LP_trades_gotrequest qprice %.8f vs myprice %.8f\n",qprice,myprice); |
|
|
|
if ( qprice > myprice ) |
|
|
|
{ |
|
|
|
r = (LP_rand() % 100); |
|
|
@ -893,6 +895,8 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru |
|
|
|
} |
|
|
|
if ( (qprice= LP_trades_pricevalidate(qp,coin,myprice)) < 0. ) |
|
|
|
return(0); |
|
|
|
if ( strcmp(qp->srccoin,"GRS") == 0 || strcmp(qp->destcoin,"GRS") == 0 ) |
|
|
|
printf("final checks\n"); |
|
|
|
if ( LP_allocated(qp->txid,qp->vout) == 0 && LP_allocated(qp->txid2,qp->vout2) == 0 ) |
|
|
|
{ |
|
|
|
reqjson = LP_quotejson(qp); |
|
|
@ -1232,6 +1236,8 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, |
|
|
|
if ( strcmp(method,"request") == 0 ) |
|
|
|
{ |
|
|
|
bestprice = LP_bob_competition(&counter,aliceid,qprice,-1); |
|
|
|
if ( strcmp(Q.srccoin,"GRS") == 0 || strcmp(Q.destcoin,"GRS") == 0 ) |
|
|
|
printf("%s lag %ld: aliceid.%llu price %.8f -> bestprice %.8f\n",jprint(argjson,0),Q.quotetime - (time(NULL)-20),(long long)aliceid,qprice,bestprice); |
|
|
|
if ( Qtrades == 0 ) |
|
|
|
LP_trades_gotrequest(ctx,&Q,&Q2,jstr(argjson,"pair")); |
|
|
|
else LP_tradecommandQ(&Q,jstr(argjson,"pair"),LP_REQUEST); |
|
|
|