Beispiel #1
0
/**
 * Prints a balance record to the console.
 *
 * @param propertyId  The identifier of the tally to print
 * @param bDivisible  Whether the token is divisible or indivisible
 * @return The total number of tokens of the tally
 */
int64_t CMPTally::print(uint32_t propertyId, bool bDivisible) const
{
    int64_t balance = 0;
    int64_t selloffer_reserve = 0;
    int64_t accept_reserve = 0;
    int64_t pending = 0;
    int64_t metadex_reserve = 0;

    TokenMap::const_iterator it = mp_token.find(propertyId);

    if (it != mp_token.end()) {
        const BalanceRecord& record = it->second;
        balance = record.balance[BALANCE];
        selloffer_reserve = record.balance[SELLOFFER_RESERVE];
        accept_reserve = record.balance[ACCEPT_RESERVE];
        pending = record.balance[PENDING];
        metadex_reserve = record.balance[METADEX_RESERVE];
    }

    if (bDivisible) {
        PrintToConsole("%22s [ SO_RESERVE= %22s, ACCEPT_RESERVE= %22s, METADEX_RESERVE= %22s ] %22s\n",
                FormatDivisibleMP(balance, true), FormatDivisibleMP(selloffer_reserve, true),
                FormatDivisibleMP(accept_reserve, true), FormatDivisibleMP(metadex_reserve, true),
                FormatDivisibleMP(pending, true));
    } else {
        PrintToConsole("%14d [ SO_RESERVE= %14d, ACCEPT_RESERVE= %14d, METADEX_RESERVE= %14d ] %14d\n",
                balance, selloffer_reserve, accept_reserve, metadex_reserve, pending);
    }

    return (balance + selloffer_reserve + accept_reserve + metadex_reserve);
}
Beispiel #2
0
void PrintToConsoleVariadic(MathLogChannel channel, const char *format, ...)
{
	const int capacity = 2048;
	char str[capacity];

	va_list args;
	va_start(args, format);

	vsnprintf((char *)str, capacity, format, args);
	str[capacity-1] = 0; // We only support logging a fixed-length string so don't care if we fail/truncate, just make sure we zero-terminate so there won't be any issues.
	PrintToConsole(channel, str);
}
Beispiel #3
0
static void RunTest( Aggregator& aggregator, const std::vector< Trade >& datafeed, const METRICS& result )
{
   std::cout << "Running test" << std::endl;

   aggregator.Intake( datafeed );
   PrintToConsole( aggregator );

   // TODO: Implement strict comparison

   aggregator.Reset();
   std::cout << std::endl << std::endl;
}
Beispiel #4
0
// Real datafeed
void ProcessCSV( Aggregator& aggregator )
{
   std::ifstream datafeed( "C:\\Users\\GLEBKA\\Desktop\\input.csv" );
   std::string line;
   while( std::getline( datafeed, line ) )
   {
      std::stringstream  lineStream( line );
      std::string        cell;
      int position = 0;
      Trade trade;
      while( std::getline( lineStream, cell, ',' ) )
      {
         switch( position )
         {
            case 0:
               trade.SetTimestamp( std::stoll( cell ) );
               break;

            case 1:
               trade.SetSymbol( cell );
               break;

            case 2:
               trade.SetQuantity( std::stoll( cell ) );
               break;

            case 3:
               trade.SetPrice( std::stol( cell ) );
               break;
         }

         position++;
      }

      aggregator.Intake( trade );
   }

   PrintToConsole( aggregator );
   PrintToCSV( aggregator, "C:\\Users\\GLEBKA\\Desktop\\output.csv" );
}