Browse Source

test

etomic
jl777 8 years ago
parent
commit
b3af31c5a9
  1. 8
      basilisk/tradebots_SVM.h
  2. 27
      basilisk/tradebots_liquidity.c
  3. 23
      iguana/iguana_notary.c
  4. 2
      iguana/tests/notarychains
  5. 1
      includes/iguana_apideclares.h

8
basilisk/tradebots_SVM.h

@ -1041,10 +1041,10 @@ void ocas_init(struct ocas_vars *vars,int32_t c,int32_t numfeatures,int32_t star
memset(ptr->W,0,sizeof(*ptr->W) * numfeatures);
memset(ptr->oldW,0,sizeof(*ptr->oldW) * numfeatures);
vars->W0[answerind] = vars->oldW0[answerind] = 0;
#ifdef ENABLE_EXISTINGMODEL
#ifndef DISABLE_EXISTINGMODEL
double init_model(double *percp,double *W,double *oldW,int c,int answerind,int numfeatures);
vars->W0[answerind] = init_model(&vars->hwmperc[answerind],ptr->W,ptr->oldW,c,answerind,vars->numfeatures);
if ( _dbufave(ptr->W,numfeatures) != 0 && bitweight(answerindmask) == 1 )
if ( _dbufave(ptr->W,numfeatures) != 0 )
validate_ocas_model(vars,answerind,ptr->output_pred,ptr->old_output,vars->weekinds[answerind],vars->len[answerind],ptr->W,vars->W0[answerind],numfeatures,1);
#endif
//printf("%s.A%d call init ocas vars weekinds[0] %p\n",CONTRACTS[c_to_refc(c)],answerind,vars->weekinds[0]);
@ -1057,8 +1057,8 @@ int32_t ocas_gen(int32_t c,int32_t numfeatures,int32_t starti,int32_t endi)
{
int32_t i; struct ocas_vars *vars = calloc(1,sizeof(*vars));
ocas_init(vars,c,numfeatures,starti,endi);
for (i=0; i<100; i++)
ocas_iter(vars,10);
for (i=0; i<10; i++)
ocas_iter(vars,3);
ocas_purge(vars);
return(0);
}

27
basilisk/tradebots_liquidity.c

@ -513,7 +513,7 @@ float *get_features(int32_t numfeatures,int32_t refc,int32_t ind)
void tradebots_modelfname(char *modelname,char *base,char *rel,int32_t answerind,int32_t numfeatures)
{
sprintf(modelname,"%s/SVM/models/%s_%s_%d.A%d",GLOBAL_DBDIR,base,rel,numfeatures,answerind);
sprintf(modelname,"SVM/models/%s_%s_%d.A%d",base,rel,numfeatures,answerind);
OS_portable_path(modelname);
}
@ -563,7 +563,7 @@ int save_model(int refc,int answerind,double *W,int numfeatures,double W0,double
{
FILE *fp; char modelname[512];
tradebots_modelfname(modelname,Arbpairs[refc].base,Arbpairs[refc].rel,answerind,numfeatures);
//printf("modelname.%s m.%p predabs %f\n",modelname,m,predabs);
printf("save model.(%s)\n",modelname);
if ( (fp= fopen(modelname,"wb")) != 0 )
{
//printf("save %s %.f%% posA.%d negA.%d\n",modelname,perc,posA,negA);
@ -578,6 +578,29 @@ int save_model(int refc,int answerind,double *W,int numfeatures,double W0,double
return(-1);
}
double init_model(double *percp,double *W,double *oldW,int c,int answerind,int numfeatures)
{
int32_t j,posA,negA,nonz=0; double *bestmodel=0;
memset(oldW,0,sizeof(*oldW)*numfeatures);
memset(W,0,sizeof(*W)*numfeatures);
if ( load_model(&posA,&negA,W,c,answerind,numfeatures) > 0 )
{
bestmodel = W;
if ( bestmodel != 0 )
{
for (j=0; j<=numfeatures; j++)
{
if ( bestmodel[j] != 0 )
nonz++;
oldW[j] = W[j];
}
if ( nonz != 0 )
return(bestmodel[numfeatures]);
}
}
return(0.);
}
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 perc = (100. * (double)(len - bad)) / len;

23
iguana/iguana_notary.c

@ -432,12 +432,23 @@ STRING_ARG(iguana,addnotary,ipaddr)
return(clonestr("{\"result\":\"notary node added\"}"));
}
char NOTARY_CURRENCIES[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD",
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW", "MVP" };
ZERO_ARGS(dpow,notarychains)
{
int32_t i; cJSON *array = cJSON_CreateArray();
jaddistr(array,"KMD");
jaddistr(array,"BTC");
for (i=0; i<sizeof(NOTARY_CURRENCIES)/sizeof(*NOTARY_CURRENCIES); i++)
jaddistr(array,NOTARY_CURRENCIES[i]);
return(jprint(array,1));
}
STRING_AND_INT(dpow,fundnotaries,symbol,numblocks)
{
int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height);
char CURRENCIES[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW", "MVP" };
uint8_t pubkeys[64][33]; cJSON *infojson; char coinaddr[64],cmd[1024]; uint64_t signedmask; int32_t i,j,sendflag=0,current=0,height; FILE *fp; double vals[64],sum,val = 0.01;
int32_t n = komodo_notaries("KMD",pubkeys,114000);
if ( symbol != 0 && strcmp(symbol,"BTC") == 0 && (coin= iguana_coinfind("KMD")) != 0 )
@ -490,14 +501,14 @@ STRING_AND_INT(dpow,fundnotaries,symbol,numblocks)
}
else return(clonestr("{\"error\":\"cant find BTC\"}"));
}
for (i=0; i<sizeof(CURRENCIES)/sizeof(*CURRENCIES); i++)
for (i=0; i<sizeof(NOTARY_CURRENCIES)/sizeof(*NOTARY_CURRENCIES); i++)
{
if ( symbol == 0 || symbol[0] == 0 || strcmp(symbol,CURRENCIES[i]) == 0 )
if ( symbol == 0 || symbol[0] == 0 || strcmp(symbol,NOTARY_CURRENCIES[i]) == 0 )
{
for (j=0; j<n; j++)
{
bitcoin_address(coinaddr,60,pubkeys[j],33);
sprintf(cmd,"./komodo-cli -ac_name=%s sendtoaddress %s %f\n",CURRENCIES[i],coinaddr,val);
sprintf(cmd,"./komodo-cli -ac_name=%s sendtoaddress %s %f\n",NOTARY_CURRENCIES[i],coinaddr,val);
if ( system(cmd) != 0 )
printf("ERROR with (%s)\n",cmd);
}

2
iguana/tests/notarychains

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dpow\",\"method\":\"notarychains\"}"

1
includes/iguana_apideclares.h

@ -21,6 +21,7 @@ ZERO_ARGS(dpow,cancelratify);
THREE_STRINGS(iguana,passthru,asset,function,hex);
STRING_ARG(dpow,bindaddr,ipaddr);
STRING_AND_INT(dpow,fundnotaries,symbol,numblocks);
ZERO_ARGS(dpow,notarychains);
TWO_STRINGS(dex,send,hex,handler);
HASH_AND_STRING(dex,gettransaction,txid,symbol);

Loading…
Cancel
Save