@ -47,7 +47,7 @@ static char *Yahoo_metals[] = { YAHOO_METALS };
char CURRENCIES [ ] [ 8 ] = { " USD " , " EUR " , " JPY " , " GBP " , " AUD " , " CAD " , " CHF " , " NZD " , // major currencies
char CURRENCIES [ ] [ 8 ] = { " 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 " , // end of 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 " , // end of currencies
" XAU " , " XAG " , " XPT " , " XPD " , // metals, gold must be first
" XAU " , " XAG " , " XPT " , " XPD " , // metals, gold must be first
" BTCD " , " BTC " , " NXT " , " ETC " , " ETH " , " STEEM " , " BTS " , " MAID " , " XCP " , " XMR " // cryptos
" BTCD " , " BTC " , " NXT " , " ETC " , " ETH " , " KMD " , " BTS " , " MAID " , " XCP " , " XMR " // cryptos
} ;
} ;
char CONTRACTS [ ] [ 16 ] = { " NZDUSD " , " NZDCHF " , " NZDCAD " , " NZDJPY " , " GBPNZD " , " EURNZD " , " AUDNZD " , " CADJPY " , " CADCHF " , " USDCAD " , " EURCAD " , " GBPCAD " , " AUDCAD " , " USDCHF " , " CHFJPY " , " EURCHF " , " GBPCHF " , " AUDCHF " , " EURUSD " , " EURAUD " , " EURJPY " , " EURGBP " , " GBPUSD " , " GBPJPY " , " GBPAUD " , " USDJPY " , " AUDJPY " , " AUDUSD " , " USDCNY " , " USDHKD " , " USDMXN " , " USDZAR " , " USDTRY " , " EURTRY " , " TRYJPY " , " USDSGD " , " EURNOK " , " USDNOK " , " USDSEK " , " USDDKK " , " EURSEK " , " EURDKK " , " NOKJPY " , " SEKJPY " , " USDPLN " , " EURPLN " , " USDILS " , // no more currencies
char CONTRACTS [ ] [ 16 ] = { " NZDUSD " , " NZDCHF " , " NZDCAD " , " NZDJPY " , " GBPNZD " , " EURNZD " , " AUDNZD " , " CADJPY " , " CADCHF " , " USDCAD " , " EURCAD " , " GBPCAD " , " AUDCAD " , " USDCHF " , " CHFJPY " , " EURCHF " , " GBPCHF " , " AUDCHF " , " EURUSD " , " EURAUD " , " EURJPY " , " EURGBP " , " GBPUSD " , " GBPJPY " , " GBPAUD " , " USDJPY " , " AUDJPY " , " AUDUSD " , " USDCNY " , " USDHKD " , " USDMXN " , " USDZAR " , " USDTRY " , " EURTRY " , " TRYJPY " , " USDSGD " , " EURNOK " , " USDNOK " , " USDSEK " , " USDDKK " , " EURSEK " , " EURDKK " , " NOKJPY " , " SEKJPY " , " USDPLN " , " EURPLN " , " USDILS " , // no more currencies
@ -197,10 +197,10 @@ void PAX_btcprices(struct peggy_info *PEGS,int32_t enddatenum,int32_t numdates)
{
{
int32_t i , n , year , month , day , seconds , datenum ; char url [ 1024 ] , date [ 64 ] , * dstr , * str ;
int32_t i , n , year , month , day , seconds , datenum ; char url [ 1024 ] , date [ 64 ] , * dstr , * str ;
uint32_t timestamp , utc32 [ MAX_SPLINES ] ; struct tai t ;
uint32_t timestamp , utc32 [ MAX_SPLINES ] ; struct tai t ;
cJSON * coindesk , * quandl , * btc dhist, * bpi , * array , * item ;
cJSON * coindesk , * quandl , * km dhist, * bpi , * array , * item ;
double btc ddaily[ MAX_SPLINES ] , cdaily [ MAX_SPLINES ] , qdaily [ MAX_SPLINES ] , ask , high , low , bid , close , vol , quotevol , open , price = 0. ;
double km ddaily[ MAX_SPLINES ] , cdaily [ MAX_SPLINES ] , qdaily [ MAX_SPLINES ] , ask , high , low , bid , close , vol , quotevol , open , price = 0. ;
coindesk = url_json ( " http://api.coindesk.com/v1/bpi/historical/close.json " ) ;
coindesk = url_json ( " http://api.coindesk.com/v1/bpi/historical/close.json " ) ;
sprintf ( url , " https://poloniex.com/public?command=returnChartData¤cyPair=BTC_BTC D&start=%ld&end=9999999999&period=86400 " , ( long ) ( time ( NULL ) - numdates * 3600 * 24 ) ) ;
sprintf ( url , " https://poloniex.com/public?command=returnChartData¤cyPair=BTC_KM D&start=%ld&end=9999999999&period=86400 " , ( long ) ( time ( NULL ) - numdates * 3600 * 24 ) ) ;
if ( ( bpi = jobj ( coindesk , " bpi " ) ) ! = 0 )
if ( ( bpi = jobj ( coindesk , " bpi " ) ) ! = 0 )
{
{
datenum = enddatenum ;
datenum = enddatenum ;
@ -248,11 +248,13 @@ void PAX_btcprices(struct peggy_info *PEGS,int32_t enddatenum,int32_t numdates)
}
}
PAX_genspline ( & PEGS - > splines [ MAX_CURRENCIES + 1 ] , MAX_CURRENCIES + 1 , " quandl " , utc32 , qdaily , n < MAX_SPLINES ? n : MAX_SPLINES , qdaily ) ;
PAX_genspline ( & PEGS - > splines [ MAX_CURRENCIES + 1 ] , MAX_CURRENCIES + 1 , " quandl " , utc32 , qdaily , n < MAX_SPLINES ? n : MAX_SPLINES , qdaily ) ;
}
}
btc dhist = url_json ( url ) ;
km dhist = url_json ( url ) ;
//{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204},
//{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204},
if ( ( array = jarray ( & n , btc dhist, 0 ) ) ! = 0 )
if ( ( array = jarray ( & n , km dhist, 0 ) ) ! = 0 )
{
{
memset ( utc32 , 0 , sizeof ( utc32 ) ) , memset ( btcddaily , 0 , sizeof ( btcddaily ) ) ;
memset ( utc32 , 0 , sizeof ( utc32 ) ) , memset ( kmddaily , 0 , sizeof ( kmddaily ) ) ;
for ( i = 0 ; i < MAX_SPLINES ; i + + )
kmddaily [ i ] = 0.0001 * 100. ;
//printf("GOT.(%s)\n",cJSON_Print(array));
//printf("GOT.(%s)\n",cJSON_Print(array));
for ( i = 0 ; i < n ; i + + )
for ( i = 0 ; i < n ; i + + )
{
{
@ -262,13 +264,13 @@ void PAX_btcprices(struct peggy_info *PEGS,int32_t enddatenum,int32_t numdates)
//printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price);
//printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price);
if ( Debuglevel > 2 )
if ( Debuglevel > 2 )
printf ( " [%u %d %f] " , timestamp , OS_conv_unixtime ( & t , & seconds , timestamp ) , price ) ;
printf ( " [%u %d %f] " , timestamp , OS_conv_unixtime ( & t , & seconds , timestamp ) , price ) ;
utc32 [ i ] = timestamp - 12 * 3600 , btc ddaily[ i ] = price * 100. ;
utc32 [ i ] = timestamp - 12 * 3600 , km ddaily[ i ] = price * 100. ;
}
}
if ( Debuglevel > 2 )
if ( Debuglevel > 2 )
printf ( " poloniex.%d \n " , n ) ;
printf ( " poloniex.%d \n " , n ) ;
PAX_genspline ( & PEGS - > splines [ MAX_CURRENCIES + 2 ] , MAX_CURRENCIES + 2 , " btc dhist" , utc32 , btc ddaily, n < MAX_SPLINES ? n : MAX_SPLINES , btc ddaily) ;
PAX_genspline ( & PEGS - > splines [ MAX_CURRENCIES + 2 ] , MAX_CURRENCIES + 2 , " km dhist" , utc32 , km ddaily, n < MAX_SPLINES ? n : MAX_SPLINES , km ddaily) ;
}
}
// https://poloniex.com/public?command=returnChartData¤cyPair=BTC_BTC D&start=1405699200&end=9999999999&period=86400
// https://poloniex.com/public?command=returnChartData¤cyPair=BTC_KM D&start=1405699200&end=9999999999&period=86400
}
}
int32_t PAX_ecbparse ( char * date , double * prices , char * url , int32_t basenum )
int32_t PAX_ecbparse ( char * date , double * prices , char * url , int32_t basenum )
@ -397,19 +399,19 @@ int32_t ecb_matrix(double matrix[32][32],char *date)
return ( datenum ) ;
return ( datenum ) ;
}
}
void PAX_update ( struct peggy_info * PEGS , double * btcusdp , double * btc dbtcp)
void PAX_update ( struct peggy_info * PEGS , double * btcusdp , double * km dbtcp)
{
{
int32_t i , n , seconds , datenum ; uint32_t timestamp ; char url [ 1024 ] , * dstr , * str ;
int32_t i , n , seconds , datenum ; uint32_t timestamp ; char url [ 1024 ] , * dstr , * str ;
double btc ddaily= 0. , btcusd = 0. , ask , high , low , bid , close , vol , quotevol , open , price = 0. ;
double km ddaily= 0. , btcusd = 0. , ask , high , low , bid , close , vol , quotevol , open , price = 0. ;
//cJSON *btcdtrades,*btc dtrades2,*,*bitcoincharts,;
//cJSON *kmdtrades,*km dtrades2,*,*bitcoincharts,;
cJSON * quandl , * btc dhist, * array , * item , * bitcoinave , * blockchaininfo , * coindesk = 0 ;
cJSON * quandl , * km dhist, * array , * item , * bitcoinave , * blockchaininfo , * coindesk = 0 ;
//btc dtrades = url_json("https://poloniex.com/public?command=returnTradeHistory¤cyPair=BTC_BTCD ");
//km dtrades = url_json("https://poloniex.com/public?command=returnTradeHistory¤cyPair=BTC_kmd ");
//btcdtrades2 = url_json("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-BTC D&count=50");
//kmdtrades2 = url_json("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-KM D&count=50");
bitcoinave = url_json ( " https://api.bitcoinaverage.com/ticker/USD/ " ) ;
bitcoinave = url_json ( " https://api.bitcoinaverage.com/ticker/USD/ " ) ;
//bitcoincharts = url_json("http://api.bitcoincharts.com/v1/weighted_prices.json");
//bitcoincharts = url_json("http://api.bitcoincharts.com/v1/weighted_prices.json");
blockchaininfo = url_json ( " https://blockchain.info/ticker " ) ;
blockchaininfo = url_json ( " https://blockchain.info/ticker " ) ;
coindesk = url_json ( " http://api.coindesk.com/v1/bpi/historical/close.json " ) ;
coindesk = url_json ( " http://api.coindesk.com/v1/bpi/historical/close.json " ) ;
sprintf ( url , " https://poloniex.com/public?command=returnChartData¤cyPair=BTC_BTC D&start=%ld&end=9999999999&period=86400 " , ( long ) ( time ( NULL ) - 2 * 3600 * 24 ) ) ;
sprintf ( url , " https://poloniex.com/public?command=returnChartData¤cyPair=BTC_KM D&start=%ld&end=9999999999&period=86400 " , ( long ) ( time ( NULL ) - 2 * 3600 * 24 ) ) ;
quandl = url_json ( " https://www.quandl.com/api/v1/datasets/BAVERAGE/USD.json?rows=1 " ) ;
quandl = url_json ( " https://www.quandl.com/api/v1/datasets/BAVERAGE/USD.json?rows=1 " ) ;
if ( quandl ! = 0 & & ( str = jstr ( quandl , " updated_at " ) ) ! = 0 & & ( datenum = conv_date ( & seconds , str ) ) > 0 & & ( array = jarray ( & n , quandl , " data " ) ) ! = 0 )
if ( quandl ! = 0 & & ( str = jstr ( quandl , " updated_at " ) ) ! = 0 & & ( datenum = conv_date ( & seconds , str ) ) > 0 & & ( array = jarray ( & n , quandl , " data " ) ) ! = 0 )
{
{
@ -430,20 +432,20 @@ void PAX_update(struct peggy_info *PEGS,double *btcusdp,double *btcdbtcp)
{
{
double avebid , aveask , bidvol , askvol ; struct exchange_quote sortbuf [ 512 ] ;
double avebid , aveask , bidvol , askvol ; struct exchange_quote sortbuf [ 512 ] ;
struct supernet_info * myinfo = SuperNET_MYINFO ( 0 ) ; cJSON * argjson = cJSON_Parse ( " {} " ) ;
struct supernet_info * myinfo = SuperNET_MYINFO ( 0 ) ; cJSON * argjson = cJSON_Parse ( " {} " ) ;
aveask = instantdex_aveprice ( myinfo , sortbuf , ( int32_t ) ( sizeof ( sortbuf ) / sizeof ( * sortbuf ) ) , & askvol , " BTC D" , " BTC " , 1 , argjson ) ;
aveask = instantdex_aveprice ( myinfo , sortbuf , ( int32_t ) ( sizeof ( sortbuf ) / sizeof ( * sortbuf ) ) , & askvol , " KM D" , " BTC " , 1 , argjson ) ;
avebid = instantdex_aveprice ( myinfo , sortbuf , ( int32_t ) ( sizeof ( sortbuf ) / sizeof ( * sortbuf ) ) , & bidvol , " BTC D" , " BTC " , - 1 , argjson ) ;
avebid = instantdex_aveprice ( myinfo , sortbuf , ( int32_t ) ( sizeof ( sortbuf ) / sizeof ( * sortbuf ) ) , & bidvol , " KM D" , " BTC " , - 1 , argjson ) ;
if ( avebid > SMALLVAL & & aveask > SMALLVAL )
if ( avebid > SMALLVAL & & aveask > SMALLVAL )
{
{
price = ( avebid * bidvol + aveask * askvol ) / ( bidvol + askvol ) ;
price = ( avebid * bidvol + aveask * askvol ) / ( bidvol + askvol ) ;
* btc dbtcp = price ;
* km dbtcp = price ;
printf ( " set BTC D price %f \n " , price ) ;
printf ( " set KM D price %f \n " , price ) ;
PEGS - > btc dbtc = price ;
PEGS - > km dbtc = price ;
}
}
else
else
{
{
btc dhist = url_json ( url ) ;
km dhist = url_json ( url ) ;
//{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204},
//{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204},
if ( btc dhist ! = 0 & & ( array = jarray ( & n , btc dhist, 0 ) ) ! = 0 )
if ( km dhist ! = 0 & & ( array = jarray ( & n , km dhist, 0 ) ) ! = 0 )
{
{
//printf("GOT.(%s)\n",cJSON_Print(array));
//printf("GOT.(%s)\n",cJSON_Print(array));
for ( i = 0 ; i < 1 ; i + + )
for ( i = 0 ; i < 1 ; i + + )
@ -453,14 +455,14 @@ void PAX_update(struct peggy_info *PEGS,double *btcusdp,double *btcdbtcp)
close = jdouble ( item , " close " ) , vol = jdouble ( item , " volume " ) , quotevol = jdouble ( item , " quoteVolume " ) , price = jdouble ( item , " weightedAverage " ) ;
close = jdouble ( item , " close " ) , vol = jdouble ( item , " volume " ) , quotevol = jdouble ( item , " quoteVolume " ) , price = jdouble ( item , " weightedAverage " ) ;
//printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price);
//printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price);
//printf("[%u %d %f]",timestamp,OS_conv_unixtime(&seconds,timestamp),price);
//printf("[%u %d %f]",timestamp,OS_conv_unixtime(&seconds,timestamp),price);
btc ddaily = price ;
km ddaily = price ;
if ( btc ddaily ! = 0 )
if ( km ddaily ! = 0 )
PEGS - > btcdbtc = * btcdbtcp = btc ddaily;
PEGS - > kmdbtc = * kmdbtcp = km ddaily;
}
}
//printf("poloniex.%d\n",n);
//printf("poloniex.%d\n",n);
}
}
if ( btc dhist ! = 0 )
if ( km dhist ! = 0 )
free_json ( btc dhist) ;
free_json ( km dhist) ;
}
}
}
}
if ( bitcoinave ! = 0 )
if ( bitcoinave ! = 0 )
@ -524,19 +526,19 @@ void _crypto_update(struct peggy_info *PEGS,double cryptovols[2][9][2],struct PA
{
{
char * cryptonatorA = " https://www.cryptonator.com/api/full/%s-%s " ; //unity-btc
char * cryptonatorA = " https://www.cryptonator.com/api/full/%s-%s " ; //unity-btc
char * cryptocoinchartsB = " http://api.cryptocoincharts.info/tradingPair/%s_%s " ; //bts_btc
char * cryptocoinchartsB = " http://api.cryptocoincharts.info/tradingPair/%s_%s " ; //bts_btc
char * cryptostrs [ 9 ] = { " btc " , " nxt " , " unity " , " eth " , " steem " , " xmr " , " bts " , " xcp " , " etc " } ;
char * cryptostrs [ 9 ] = { " btc " , " nxt " , " unity " , " eth " , " kmd " , " xmr " , " bts " , " xcp " , " etc " } ;
int32_t iter , i , j ; double btcusd , btc dbtc, cnyusd , prices [ 9 ] [ 2 ] , volumes [ 9 ] [ 2 ] ;
int32_t iter , i , j ; double btcusd , km dbtc, cnyusd , prices [ 9 ] [ 2 ] , volumes [ 9 ] [ 2 ] ;
char base [ 16 ] , rel [ 16 ] , url [ 512 ] , * str ; cJSON * jsonA , * jsonB ;
char base [ 16 ] , rel [ 16 ] , url [ 512 ] , * str ; cJSON * jsonA , * jsonB ;
if ( peggyflag ! = 0 )
if ( peggyflag ! = 0 )
{
{
cnyusd = PEGS - > cnyusd ;
cnyusd = PEGS - > cnyusd ;
btcusd = PEGS - > btcusd ;
btcusd = PEGS - > btcusd ;
btc dbtc = PEGS - > btc dbtc;
km dbtc = PEGS - > km dbtc;
//printf("update with btcusd %f btcd %f cnyusd %f cnybtc %f\n",btcusd,btc dbtc,cnyusd,cnyusd/btcusd);
//printf("update with btcusd %f kmd %f cnyusd %f cnybtc %f\n",btcusd,km dbtc,cnyusd,cnyusd/btcusd);
if ( btcusd < SMALLVAL | | btc dbtc < SMALLVAL )
if ( btcusd < SMALLVAL | | km dbtc < SMALLVAL )
{
{
PAX_update ( PEGS , & btcusd , & btc dbtc) ;
PAX_update ( PEGS , & btcusd , & km dbtc) ;
printf ( " PAX_update with btcusd %f btc d %f \n " , btcusd , btc dbtc) ;
printf ( " PAX_update with btcusd %f km d %f \n " , btcusd , km dbtc) ;
}
}
memset ( prices , 0 , sizeof ( prices ) ) ;
memset ( prices , 0 , sizeof ( prices ) ) ;
memset ( volumes , 0 , sizeof ( volumes ) ) ;
memset ( volumes , 0 , sizeof ( volumes ) ) ;
@ -553,7 +555,7 @@ void _crypto_update(struct peggy_info *PEGS,double cryptovols[2][9][2],struct PA
for ( iter = 0 ; iter < 1 ; iter + + )
for ( iter = 0 ; iter < 1 ; iter + + )
{
{
if ( i = = 0 & & iter = = 0 )
if ( i = = 0 & & iter = = 0 )
strcpy ( base , " btc d" ) , strcpy ( rel , " btc " ) ;
strcpy ( base , " km d" ) , strcpy ( rel , " btc " ) ;
else strcpy ( base , str ) , strcpy ( rel , iter = = 0 ? " btc " : " cny " ) ;
else strcpy ( base , str ) , strcpy ( rel , iter = = 0 ? " btc " : " cny " ) ;
//if ( selector == 0 )
//if ( selector == 0 )
{
{
@ -587,10 +589,10 @@ void _crypto_update(struct peggy_info *PEGS,double cryptovols[2][9][2],struct PA
void PAX_RTupdate ( struct peggy_info * PEGS , double cryptovols [ 2 ] [ 9 ] [ 2 ] , double RTmetals [ 4 ] , double * RTprices , struct PAX_data * dp )
void PAX_RTupdate ( struct peggy_info * PEGS , double cryptovols [ 2 ] [ 9 ] [ 2 ] , double RTmetals [ 4 ] , double * RTprices , struct PAX_data * dp )
{
{
char * cryptostrs [ 9 ] = { " btc " , " nxt " , " unity " , " eth " , " etc " , " steem " , " xmr " , " bts " , " xcp " } ;
char * cryptostrs [ 9 ] = { " btc " , " nxt " , " unity " , " eth " , " etc " , " kmd " , " xmr " , " bts " , " xcp " } ;
int32_t iter , i , c , baserel , basenum , relnum ; double cnyusd , btcusd , btc dbtc, bid , ask , price , vol , prices [ 8 ] [ 2 ] , volumes [ 8 ] [ 2 ] ;
int32_t iter , i , c , baserel , basenum , relnum ; double cnyusd , btcusd , km dbtc, bid , ask , price , vol , prices [ 8 ] [ 2 ] , volumes [ 8 ] [ 2 ] ;
char base [ 16 ] , rel [ 16 ] ;
char base [ 16 ] , rel [ 16 ] ;
PAX_update ( PEGS , & btcusd , & btc dbtc) ;
PAX_update ( PEGS , & btcusd , & km dbtc) ;
memset ( prices , 0 , sizeof ( prices ) ) ;
memset ( prices , 0 , sizeof ( prices ) ) ;
memset ( volumes , 0 , sizeof ( volumes ) ) ;
memset ( volumes , 0 , sizeof ( volumes ) ) ;
for ( i = 0 ; i < sizeof ( cryptostrs ) / sizeof ( * cryptostrs ) ; i + + )
for ( i = 0 ; i < sizeof ( cryptostrs ) / sizeof ( * cryptostrs ) ; i + + )
@ -600,10 +602,10 @@ void PAX_RTupdate(struct peggy_info *PEGS,double cryptovols[2][9][2],double RTme
volumes [ i ] [ iter ] = cryptovols [ 1 ] [ i ] [ iter ] ;
volumes [ i ] [ iter ] = cryptovols [ 1 ] [ i ] [ iter ] ;
}
}
if ( prices [ 0 ] [ 0 ] > SMALLVAL )
if ( prices [ 0 ] [ 0 ] > SMALLVAL )
dxblend ( & btc dbtc, prices [ 0 ] [ 0 ] , .9 ) ;
dxblend ( & km dbtc, prices [ 0 ] [ 0 ] , .9 ) ;
dxblend ( & dp - > btcdbtc , btc dbtc, .995 ) ;
dxblend ( & dp - > kmdbtc , km dbtc, .995 ) ;
if ( PEGS - > btc dbtc < SMALLVAL )
if ( PEGS - > km dbtc < SMALLVAL )
PEGS - > btc dbtc = dp - > btc dbtc;
PEGS - > km dbtc = dp - > km dbtc;
if ( ( cnyusd = PEGS - > cnyusd ) > SMALLVAL )
if ( ( cnyusd = PEGS - > cnyusd ) > SMALLVAL )
{
{
if ( prices [ 0 ] [ 1 ] > SMALLVAL )
if ( prices [ 0 ] [ 1 ] > SMALLVAL )
@ -633,15 +635,15 @@ void PAX_RTupdate(struct peggy_info *PEGS,double cryptovols[2][9][2],double RTme
}
}
}
}
btcusd = PEGS - > btcusd ;
btcusd = PEGS - > btcusd ;
btc dbtc = PEGS - > btc dbtc;
km dbtc = PEGS - > km dbtc;
if ( Debuglevel > 2 )
if ( Debuglevel > 2 )
printf ( " update with btcusd %f btc d %f \n " , btcusd , btc dbtc) ;
printf ( " update with btcusd %f km d %f \n " , btcusd , km dbtc) ;
if ( btcusd < SMALLVAL | | btc dbtc < SMALLVAL )
if ( btcusd < SMALLVAL | | km dbtc < SMALLVAL )
{
{
PAX_update ( PEGS , & btcusd , & btc dbtc) ;
PAX_update ( PEGS , & btcusd , & km dbtc) ;
if ( Debuglevel > 2 )
if ( Debuglevel > 2 )
printf ( " price777_update with btcusd %f btc d %f \n " , btcusd , btc dbtc) ;
printf ( " price777_update with btcusd %f km d %f \n " , btcusd , km dbtc) ;
} else PEGS - > btcusd = btcusd , PEGS - > btcdbtc = btc dbtc;
} else PEGS - > btcusd = btcusd , PEGS - > kmdbtc = km dbtc;
for ( c = 0 ; c < sizeof ( CONTRACTS ) / sizeof ( * CONTRACTS ) ; c + + )
for ( c = 0 ; c < sizeof ( CONTRACTS ) / sizeof ( * CONTRACTS ) ; c + + )
{
{
for ( iter = 0 ; iter < 3 ; iter + + )
for ( iter = 0 ; iter < 3 ; iter + + )
@ -708,7 +710,7 @@ struct exchange_info *PAX_bidasks(char *exchangestr,uint32_t *timestamps,double
int32_t PAX_idle ( struct peggy_info * PEGS , int32_t peggyflag , int32_t idlegap )
int32_t PAX_idle ( struct peggy_info * PEGS , int32_t peggyflag , int32_t idlegap )
{
{
static double lastupdate , lastdayupdate ; static int32_t didinit ; static portable_mutex_t mutex ;
static double lastupdate , lastdayupdate ; static int32_t didinit ; static portable_mutex_t mutex ;
struct exchange_info * exchange ; struct exchange_quote bidasks [ 2 ] ; double btc dbtc, btcusd ;
struct exchange_info * exchange ; struct exchange_quote bidasks [ 2 ] ; double km dbtc, btcusd ;
int32_t i , datenum , contractnum , seconds ; struct tai t ; struct PAX_data * dp = & PEGS - > tmp ;
int32_t i , datenum , contractnum , seconds ; struct tai t ; struct PAX_data * dp = & PEGS - > tmp ;
* dp = PEGS - > data ;
* dp = PEGS - > data ;
if ( didinit = = 0 )
if ( didinit = = 0 )
@ -717,7 +719,7 @@ int32_t PAX_idle(struct peggy_info *PEGS,int32_t peggyflag,int32_t idlegap)
//prices777_init(BUNDLE.jsonstr,peggyflag);
//prices777_init(BUNDLE.jsonstr,peggyflag);
didinit = 1 ;
didinit = 1 ;
datenum = OS_conv_unixtime ( & t , & seconds , ( uint32_t ) time ( NULL ) ) ;
datenum = OS_conv_unixtime ( & t , & seconds , ( uint32_t ) time ( NULL ) ) ;
expand_datenum ( PEGS - > data . edate , datenum ) ;
expand_datenum ( dp - > edate , datenum ) ;
if ( peggyflag ! = 0 )
if ( peggyflag ! = 0 )
{
{
//int32_t opreturns_init(uint32_t blocknum,uint32_t blocktimestamp,char *path);
//int32_t opreturns_init(uint32_t blocknum,uint32_t blocktimestamp,char *path);
@ -752,15 +754,15 @@ int32_t PAX_idle(struct peggy_info *PEGS,int32_t peggyflag,int32_t idlegap)
dp - > itimestamps [ contractnum ] = bidasks [ 0 ] . timestamp ;
dp - > itimestamps [ contractnum ] = bidasks [ 0 ] . timestamp ;
}
}
}
}
PAX_update ( PEGS , & btcusd , & btc dbtc) ;
PAX_update ( PEGS , & btcusd , & km dbtc) ;
if ( btcusd > SMALLVAL )
if ( btcusd > SMALLVAL )
dxblend ( & dp - > btcusd , btcusd , 0.99 ) ;
dxblend ( & dp - > btcusd , btcusd , 0.99 ) ;
if ( btc dbtc > SMALLVAL )
if ( km dbtc > SMALLVAL )
dxblend ( & dp - > btcdbtc , btc dbtc, 0.99 ) ;
dxblend ( & dp - > kmdbtc , km dbtc, 0.99 ) ;
if ( dp - > btcusd = = 0 )
if ( dp - > btcusd = = 0 )
dp - > btcusd = dp - > btcusd ;
dp - > btcusd = dp - > btcusd ;
if ( dp - > btc dbtc = = 0 )
if ( dp - > km dbtc = = 0 )
dp - > btc dbtc = dp - > btc dbtc;
dp - > km dbtc = dp - > km dbtc;
if ( dp - > ecbmatrix [ USD ] [ USD ] > SMALLVAL & & dp - > ecbmatrix [ CNY ] [ CNY ] > SMALLVAL )
if ( dp - > ecbmatrix [ USD ] [ USD ] > SMALLVAL & & dp - > ecbmatrix [ CNY ] [ CNY ] > SMALLVAL )
PEGS - > cnyusd = ( dp - > ecbmatrix [ CNY ] [ CNY ] / dp - > ecbmatrix [ USD ] [ USD ] ) ;
PEGS - > cnyusd = ( dp - > ecbmatrix [ CNY ] [ CNY ] / dp - > ecbmatrix [ USD ] [ USD ] ) ;
portable_mutex_lock ( & mutex ) ;
portable_mutex_lock ( & mutex ) ;