Browse Source

test

etomic
jl777 8 years ago
parent
commit
29314923f5
  1. 89
      basilisk/tradebots_liquidity.c
  2. 6
      iguana/dpow/dpow_tx.c

89
basilisk/tradebots_liquidity.c

@ -511,6 +511,95 @@ double set_ocas_model(int refc,int answerind,double *W,double W0,int numfeatures
return(W0);
}
/*double load_model(register int *posAp,register int *negAp,register double *W,register int refc,register int answerind,register int numfeatures)
{
int j;
FILE *fp;
double perc;
char modelname[512];
#ifdef __APPLE__
sprintf(modelname,"/Volumes/SSD/models/%s_%d.A%c%c",CONTRACTS[refc],numfeatures,(answerind/10)+'0',(answerind%10)+'0');
#else
sprintf(modelname,"/media/raptor/models/%s_%d.A%c%c",CONTRACTS[refc],numfeatures,(answerind/10)+'0',(answerind%10)+'0');
#endif
if ( (fp= fopen(modelname,"rb")) != 0 )
{
//printf("load file\n");
j = (int)fread(W,sizeof(*W),numfeatures+1,fp);
//fread(&W0,1,sizeof(W0),fp);
if ( fread(&perc,1,sizeof(perc),fp) == sizeof(perc) )
j++;
if ( fread(posAp,1,sizeof(*posAp),fp) == sizeof(*posAp) )
j++;
if ( fread(negAp,1,sizeof(*negAp),fp) == sizeof(*negAp) )
j++;
fclose(fp);
//printf("loaded %s bias %9.6f | %5.2f%%\n",modelname,W[numfeatures],perc);
return(perc);
}
#ifndef DISABLE_EXISTINGMODEL
else if ( 0 )
{
sprintf(modelname,"/media/raptor/models/%s_%d.A%c%c",CONTRACTS[0],numfeatures,(answerind/10)+'0',(answerind%10)+'0');
if ( (fp= fopen(modelname,"rb")) != 0 )
{
j = (int)fread(W,sizeof(*W),numfeatures+1,fp);
if ( fread(&perc,1,sizeof(perc),fp) == sizeof(perc) )
j++;
if ( fread(posAp,1,sizeof(*posAp),fp) == sizeof(*posAp) )
j++;
if ( fread(negAp,1,sizeof(*negAp),fp) == sizeof(*negAp) )
j++;
fclose(fp);
printf("Using backup model for %s loaded %s bias %9.6f | %5.2f%%\n",CONTRACTS[refc],modelname,W[numfeatures],perc);
return(perc * .9);
}
}
#endif
else printf("couldn't load (%s)\n",modelname);
return(-1);
}
int save_model(int refc,int answerind,double *W,int numfeatures,double W0,double perc,int posA,int negA)
{
FILE *fp;
char modelname[512];
sprintf(modelname,"/media/raptor/models/%s_%d.A%c%c",CONTRACTS[refc],numfeatures,(answerind/10)+'0',(answerind%10)+'0');
//printf("modelname.%s m.%p predabs %f\n",modelname,m,predabs);
if ( (fp= fopen(modelname,"wb")) != 0 )
{
//printf("save %s %.f%% posA.%d negA.%d\n",modelname,perc,posA,negA);
fwrite(W,sizeof(*W),numfeatures,fp);
fwrite(&W0,1,sizeof(W0),fp);
fwrite(&perc,1,sizeof(perc),fp);
fwrite(&posA,1,sizeof(posA),fp);
fwrite(&negA,1,sizeof(negA),fp);
fclose(fp);
return(0);
}
return(-1);
}
double set_ocas_model(int refc,int answerind,double *W,double W0,int numfeatures,int firstweekind,int len,int bad,double dist,double predabs,int posA,int negA,double answerabs,double aveanswer)
{
double fileperc,perc = (100. * (double)(len - bad)) / len;
#ifndef DISABLE_EXISTINGMODEL
int _posA,_negA;
double tmpW[MAX_OCAS_FEATURES+2],fileperc;
if ( (fileperc= load_model(&_posA,&_negA,tmpW,refc_to_c(refc),answerind,numfeatures)) > perc )
{
if ( (_posA+_negA) != 0 && _posA >= posA && _negA >= negA )
{
memcpy(W,tmpW,sizeof(*W)*numfeatures);
printf("%s.A%02d numfeatures.%d posA.%d negA.%d saved model %f is better than %f +A%d -A%d\n",CONTRACTS[refc],answerind,numfeatures,_posA,_negA,fileperc,perc,posA,negA);
return(tmpW[numfeatures]);
}
}
#endif
save_model(refc,answerind,W,numfeatures,W0,perc,posA,negA);
return(W0);
}*/
#ifndef _WIN
#include "tradebots_SVM.h"
#endif

6
iguana/dpow/dpow_tx.c

@ -565,13 +565,13 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 )
{
signedtxid = dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified);
//printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx);
printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx);
bp->state = 1;
if ( bits256_nonz(signedtxid) != 0 && numsigs == bp->minsigs )
{
if ( (retstr= dpow_sendrawtransaction(myinfo,coin,bp->signedtx)) != 0 )
{
//printf("sendrawtransaction.(%s)\n",retstr);
printf("sendrawtransaction.(%s)\n",retstr);
if ( is_hexstr(retstr,0) == sizeof(txid)*2 )
{
decode_hex(txid.bytes,sizeof(txid),retstr);
@ -594,7 +594,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
printf("complete statemachine.%s ht.%d state.%d (%x %x)\n",coin->symbol,bp->height,bp->state,bp->hashmsg.uints[0],txid.uints[0]);
}
} else printf("sendtxid mismatch got %s instead of %s\n",bits256_str(str,txid),bits256_str(str2,signedtxid));
}
} else printf("dpow_sigscheck: mismatched txid.%s vs %s\n",bits256_str(str,txid),retstr);
free(retstr);
retstr = 0;
}

Loading…
Cancel
Save