double getAvail(Parameters& params, std::string currency) { json_t* root = authRequest(params, "https://api.gemini.com/v1/balances", "balances", ""); while (json_object_get(root, "message") != NULL) { sleep(1.0); *params.logFile << "<Gemini> Error with JSON: " << json_dumps(root, 0) << ". Retrying..." << std::endl; root = authRequest(params, "https://api.gemini.com/v1/balances", "balances", ""); } // go through the list size_t arraySize = json_array_size(root); double availability = 0.0; std::string currencyAllCaps; if (currency.compare("btc") == 0) { currencyAllCaps = "BTC"; } else if (currency.compare("usd") == 0) { currencyAllCaps = "USD"; } for (size_t i = 0; i < arraySize; i++) { std::string tmpCurrency = json_string_value(json_object_get(json_array_get(root, i), "currency")); if (tmpCurrency.compare(currencyAllCaps.c_str()) == 0) { availability = atof(json_string_value(json_object_get(json_array_get(root, i), "amount"))); } } json_decref(root); return availability; }
bool isOrderComplete(Parameters& params, int orderId) { json_t* root = authRequest(params, "https://api.kraken.com", "/0/private/OpenOrders"); // no open order: return true root = json_object_get(json_object_get(root, "result"), "open"); if (json_object_size(root) == 0) { *params.logFile << "No order exists" << std::endl; return true; } *params.logFile << json_dumps(root, 0) << std::endl; std::string transaction_id = (*id_to_transaction)[orderId]; root = json_object_get(root, transaction_id.c_str()); // open orders exist but specific order not found: return true if (json_object_size(root) == 0) { *params.logFile << "Order " << transaction_id << " does not exist" << std::endl; return true; // open orders exist and specific order was found: return false } else { *params.logFile << "Order " << transaction_id << " still exists!" << std::endl; return false; } }
double getAvail(Parameters& params, std::string currency) { std::ostringstream oss; oss << "api_key=" << params.okcoinApi << "&secret_key=" << params.okcoinSecret; std::string signature(oss.str()); oss.clear(); oss.str(""); oss << "api_key=" << params.okcoinApi; std::string content(oss.str()); json_t* root = authRequest(params, "https://www.okcoin.com/api/v1/userinfo.do", signature, content); double availability = 0.0; const char* returnedText; if (currency.compare("usd") == 0) { returnedText = json_string_value(json_object_get(json_object_get(json_object_get(json_object_get(root, "info"), "funds"), "free"), "usd")); } else if (currency.compare("btc") == 0) { returnedText = json_string_value(json_object_get(json_object_get(json_object_get(json_object_get(root, "info"), "funds"), "free"), "btc")); } else { returnedText = "0.0"; } if (returnedText != NULL) { availability = atof(returnedText); } else { *params.logFile << "<OKCoin> Error with the credentials." << std::endl; availability = 0.0; } json_decref(root); return availability; }
bool isOrderComplete(Parameters& params, int orderId) { if (orderId == 0) { return true; } // signature std::ostringstream oss; oss << "api_key=" << params.okCoinApi << "&order_id=" << orderId << "&symbol=btc_usd" << "&secret_key=" << params.okCoinSecret; std::string signature = oss.str(); oss.clear(); oss.str(""); // content oss << "api_key=" << params.okCoinApi << "&order_id=" << orderId << "&symbol=btc_usd"; std::string content = oss.str(); json_t* root = authRequest(params, "https://www.okcoin.com/api/v1/order_info.do", signature, content); int status = json_integer_value(json_object_get(json_array_get(json_object_get(root, "orders"), 0), "status")); json_decref(root); if (status == 2) { return true; } else { return false; } }
static void dispatch_operation(struct session *session, DNDSMessage_t *msg) { dnop_PR operation; DNMessage_get_operation(msg, &operation); switch (operation) { case dnop_PR_provRequest: provRequest(session, msg); break; case dnop_PR_authRequest: authRequest(session, msg); break; case dnop_PR_netinfoRequest: handle_netinfo_request(session, msg); break; /* TerminateRequest is a special case since * it has no Response message associated with it, * simply disconnect the client */ case dnop_PR_NOTHING: default: case dnop_PR_terminateRequest: session_terminate(session); break; } }
double getAvail(Parameters& params, std::string currency) { json_t* root = authRequest(params, "https://www.bitstamp.net/api/balance/", ""); while (json_object_get(root, "message") != NULL) { sleep(1.0); *params.logFile << "<Bitstamp> Error with JSON: " << json_dumps(root, 0) << ". Retrying..." << std::endl; root = authRequest(params, "https://www.bitstamp.net/api/balance/", ""); } double availability = 0.0; if (currency.compare("btc") == 0) { availability = atof(json_string_value(json_object_get(root, "btc_balance"))); } else if (currency.compare("usd") == 0) { availability = atof(json_string_value(json_object_get(root, "usd_balance"))); } json_decref(root); return availability; }
int sendOrder(Parameters& params, std::string direction, double quantity, double price) { // define limit price to be sure to be executed double limPrice; if (direction.compare("buy") == 0) { limPrice = getLimitPrice(params, quantity, false); } else if (direction.compare("sell") == 0) { limPrice = getLimitPrice(params, quantity, true); } // signature std::ostringstream oss; oss << "amount=" << quantity << "&api_key=" << params.okCoinApi << "&price=" << limPrice << "&symbol=btc_usd&type=" << direction << "&secret_key=" << params.okCoinSecret; std::string signature = oss.str(); oss.clear(); oss.str(""); // content oss << "amount=" << quantity << "&api_key=" << params.okCoinApi << "&price=" << limPrice << "&symbol=btc_usd&type=" << direction; std::string content = oss.str(); *params.logFile << "<OKCoin> Trying to send a \"" << direction << "\" limit order: " << quantity << "@$" << limPrice << "..." << std::endl; json_t *root = authRequest(params, "https://www.okcoin.com/api/v1/trade.do", signature, content); int orderId = json_integer_value(json_object_get(root, "order_id")); *params.logFile << "<OKCoin> Done (order ID: " << orderId << ")\n" << std::endl; json_decref(root); return orderId; }
int sendOrder(Parameters& params, std::string direction, double quantity, double price) { double limPrice; // define limit price to be sure to be executed if (direction.compare("buy") == 0) { limPrice = getLimitPrice(params, quantity, false); } else if (direction.compare("sell") == 0) { limPrice = getLimitPrice(params, quantity, true); } *params.logFile << "<Bitstamp> Trying to send a \"" << direction << "\" limit order: " << quantity << "@$" << limPrice << "..." << std::endl; std::ostringstream oss; oss << "https://www.bitstamp.net/api/" << direction << "/"; std::string url = oss.str(); oss.clear(); oss.str(""); oss << "amount=" << quantity << "&price=" << std::fixed << std::setprecision(2) << limPrice; std::string options = oss.str(); json_t* root = authRequest(params, url, options); int orderId = json_integer_value(json_object_get(root, "id")); if (orderId == 0) { *params.logFile << "<Bitstamp> Order ID = 0. Message: " << json_dumps(root, 0) << std::endl; } *params.logFile << "<Bitstamp> Done (order ID: " << orderId << ")\n" << std::endl; json_decref(root); return orderId; }
int sendLongOrder(Parameters& params, std::string direction, double quantity, double price) { *params.logFile << "<Gemini> Trying to send a \"" << direction << "\" limit order: " << quantity << "@$" << price << "..." << std::endl; std::ostringstream oss; oss << "\"symbol\":\"BTCUSD\", \"amount\":\"" << quantity << "\", \"price\":\"" << price << "\", \"side\":\"" << direction << "\", \"type\":\"exchange limit\""; std::string options = oss.str(); json_t* root = authRequest(params, "https://api.gemini.com/v1/order/new", "order/new", options); int orderId = atoi(json_string_value(json_object_get(root, "order_id"))); *params.logFile << "<Gemini> Done (order ID: " << orderId << ")\n" << std::endl; json_decref(root); return orderId; }
void AdminAuth() { Zimbra::Rpc::AdminAuthRequest authRequest(lpAdminUser, lpAdminPwd, L""); Zimbra::Rpc::AdminConnection *m_pAdminConnection; Zimbra::Util::ScopedInterface<IXMLDOMDocument2> pResponseXml; m_pAdminConnection = new Zimbra::Rpc::AdminConnection(lpServerAddress, nAdminPort, TRUE, 0, L""); m_pAdminConnection->SetCurrentUser((LPWSTR)lpAccountUser); m_pAdminConnection->SendRequest(authRequest, pResponseXml.getref()); }
void Client::startTrack() { if (!m_authentificated) emit authRequest(); else if (!m_timer->isActive()) { m_timer->start(m_trackInterval*1000); if (m_additionalTimer->isActive()) m_additionalTimer->stop(); } }
double getActivePos(CURL *curl, Parameters params) { json_t *root = authRequest(curl, params, "https://api.bitfinex.com/v1/positions", "positions", ""); double position; if (json_array_size(root) == 0) { std::cout << "<Bitfinex> WARNING: BTC position not available, return 0.0" << std::endl; position = 0.0; } else { position = atof(json_string_value(json_object_get(json_array_get(root, 0), "amount"))); } json_decref(root); return position; }
double getAvail(Parameters& params, std::string currency){ json_t* root= authRequest(params,"https://796.com/v2/user/get_balance","balances",""); while (json_object_get(root, "message") != NULL) { sleep(1.0); *params.logFile << "<SevenNintySix> Error with JSON in getAvail: " << json_dumps(root, 0) << ". Retrying..." << std::endl; root = authRequest(params,"https://796.com/v2/user/get_balance","balances",""); } double availability = 0.0; if (currency.compare("btc") == 0) { availability = atof(json_string_value(json_object_get(root, "btc_balance"))); } else if (currency.compare("mri") == 0) { availability = atof(json_string_value(json_object_get(root, "mri_balance"))); } else if (currency.compare("asicminer") == 0) { availability = atof(json_string_value(json_object_get(root, "asicminer_balance"))); } json_decref(root); return availability; }
bool isOrderComplete(Parameters& params, int orderId) { if (orderId == 0) { return true; } std::ostringstream oss; oss << "\"order_id\":" << orderId; std::string options = oss.str(); json_t* root = authRequest(params, "https://api.gemini.com/v1/order/status", "order/status", options); bool isComplete = !json_boolean_value(json_object_get(root, "is_live")); json_decref(root); return isComplete; }
void repayBtc(Parameters& params, int borrowId) { std::ostringstream oss; oss << "api_key=" << params.okcoinApi << "&borrow_id=" << borrowId << "&secret_key=" << params.okcoinSecret; std::string signature = oss.str(); oss.clear(); oss.str(""); oss << "api_key=" << params.okcoinApi << "&borrow_id=" << borrowId; std::string content = oss.str(); json_t* root = authRequest(params, "https://www.okcoin.com/api/v1/repayment.do", signature, content); std::cout << "<OKCoin> Repay borrowed BTC:\n" << json_dumps(root, 0) << std::endl; json_decref(root); }
void getBorrowInfo(Parameters& params) { std::ostringstream oss; oss << "api_key=" << params.okcoinApi << "&symbol=btc_usd&secret_key=" << params.okcoinSecret; std::string signature = oss.str(); oss.clear(); oss.str(""); oss << "api_key=" << params.okcoinApi << "&symbol=btc_usd"; std::string content = oss.str(); json_t* root = authRequest(params, "https://www.okcoin.com/api/v1/borrows_info.do", signature, content); std::cout << "<OKCoin> Borrow info:\n" << json_dumps(root, 0) << std::endl; json_decref(root); }
double getAvail(Parameters& params, std::string currency) { json_t* root = authRequest(params, "https://api.bitfinex.com/v1/balances", "balances", ""); while (json_object_get(root, "message") != NULL) { sleep(1.0); *params.logFile << "<Bitfinex> Error with JSON: " << json_dumps(root, 0) << ". Retrying..." << std::endl; root = authRequest(params, "https://api.bitfinex.com/v1/balances", "balances", ""); } // go through the list (order not preserved for some reason) size_t arraySize = json_array_size(root); double availability = 0.0; for (size_t i = 0; i < arraySize; i++) { std::string tmpType = json_string_value(json_object_get(json_array_get(root, i), "type")); std::string tmpCurrency = json_string_value(json_object_get(json_array_get(root, i), "currency")); if (tmpType.compare("trading") == 0 && tmpCurrency.compare(currency.c_str()) == 0) { availability = atof(json_string_value(json_object_get(json_array_get(root, i), "amount"))); } } // json_array_clear(root); json_decref(root); return availability; }
std::string AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element)); std::string value; boost::optional<ByteArray> message = authRequest->getMessage(); if (message) { if ((*message).isEmpty()) { value = "="; } else { value = Base64::encode(*message); } } return "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">" + value + "</auth>"; }
SafeByteArray AuthRequestSerializer::serialize(boost::shared_ptr<ToplevelElement> element) const { boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element)); SafeByteArray value; boost::optional<SafeByteArray> message = authRequest->getMessage(); if (message) { if ((*message).empty()) { value = createSafeByteArray("="); } else { value = Base64::encode(*message); } } return concat(createSafeByteArray("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">"), value, createSafeByteArray("</auth>")); }
double getAvail(CURL *curl, Parameters params, std::string currency) { /*https://www.bitstamp.net/api/balance/ - Account balance*/ json_t *root = authRequest(curl, params, "https://www.bitstamp.net/api/balance/", ""); while (json_object_get(root, "message") != NULL) { sleep(1.0); std::cout << "<Bitstamp> Error with JSON in getAvail: " << json_dumps(root, 0) << ". Retrying..." << std::endl; /*root a pointer to json_t data structure would take value returned by authrequest to balance bitstamp API*/ root = authRequest(curl, params, "https://www.bitstamp.net/api/balance/", ""); } double availability = 0.0; /*currency is a string supplied as parameter to the function getAvail*/ /*http://www.cplusplus.com/reference/string/string/compare/ if <std::string> str1.compare("str2")==0 then strings equal*/ if (currency.compare("btc") == 0) { /*"btc_balance" is a key in the JSON object returned by json_object_get"*/ availability = atof(json_string_value(json_object_get(root, "btc_balance"))); } else if (currency.compare("usd") == 0) { /*"usd_balance" is a key in the JSON object returned by json_object_get"*/ availability = atof(json_string_value(json_object_get(root, "usd_balance"))); } json_decref(root); return availability; }
double getAvail(Parameters& params, std::string currency) { json_t* root = authRequest(params, "https://api.kraken.com", "/0/private/Balance"); json_t* result = json_object_get(root, "result"); while (json_object_size(result) == 0) { sleep(1.0); *params.logFile << "<Kraken> Error with JSON: " << json_dumps(root, 0) << ". Retrying..." << std::endl; root = authRequest(params, "https://api.kraken.com", "/0/private/Balance"); result = json_object_get(root, "result"); } double available = 0.0; if (currency.compare("usd") == 0) { const char * avail_str = json_string_value(json_object_get(result, "ZUSD")); available = avail_str ? atof(avail_str) : 0.0; } else if (currency.compare("btc") == 0) { const char * avail_str = json_string_value(json_object_get(result, "XXBT")); available = avail_str ? atof(avail_str) : 0.0; } else { *params.logFile << "Currency not supported" << std::endl; } return available; }
bool isOrderComplete(Parameters& params, int orderId) { if (orderId == 0) { return true; } std::ostringstream oss; oss << "id=" << orderId; std::string options = oss.str(); json_t* root = authRequest(params, "https://www.bitstamp.net/api/order_status/", options); std::string status = json_string_value(json_object_get(root, "status")); json_decref(root); if (status.compare("Finished") == 0) { return true; } else { return false; } }
void UserAuth() { Zimbra::Util::ScopedInterface<IXMLDOMDocument2> pResponseXml; m_pConnection = new Zimbra::Rpc::Connection(L"migration", lpServerAddress, nPort, false, 0, L""); m_pConnection->SetCurrentUser((LPWSTR)lpAccountUser); Zimbra::Rpc::AuthRequest authRequest(lpAccountUser, lpAccountUserPwd, lpServerAddress); m_pConnection->SendRequest(authRequest, pResponseXml.getref()); Zimbra::Util::ScopedPtr<Zimbra::Rpc::Response> pResponse( Zimbra::Rpc::Response::Manager::NewResponse(pResponseXml.get())); }
int sendLongOrder(Parameters& params, std::string direction, double quantity, double price) { // signature std::ostringstream oss; oss << "amount=" << quantity << "&api_key=" << params.okcoinApi << "&price=" << price << "&symbol=btc_usd&type=" << direction << "&secret_key=" << params.okcoinSecret; std::string signature = oss.str(); oss.clear(); oss.str(""); // content oss << "amount=" << quantity << "&api_key=" << params.okcoinApi << "&price=" << price << "&symbol=btc_usd&type=" << direction; std::string content = oss.str(); *params.logFile << "<OKCoin> Trying to send a \"" << direction << "\" limit order: " << quantity << "@$" << price << "..." << std::endl; json_t *root = authRequest(params, "https://www.okcoin.com/api/v1/trade.do", signature, content); int orderId = json_integer_value(json_object_get(root, "order_id")); *params.logFile << "<OKCoin> Done (order ID: " << orderId << ")\n" << std::endl; json_decref(root); return orderId; }
/*To send order to bitstamp - direction is buy or sell*/ int sendOrder(CURL *curl, Parameters params, std::string direction, double quantity, double price) { /*Before sending order to bitstamp API, first get limitprice of the buy or sell order for the specific quantity*/ double limPrice; // define limit price to be sure to be executed if (direction.compare("buy") == 0) { limPrice = getLimitPrice(curl, quantity, false); } else if (direction.compare("sell") == 0) { limPrice = getLimitPrice(curl, quantity, true); } std::cout << "<Bitstamp> Trying to send a \"" << direction << "\" limit order: " << quantity << "@$" << limPrice << "..." << std::endl; /*class std::ostringstream : Output stream class to operate on strings. Objects of this class use a string buffer that contains a sequence of characters. This sequence of characters can be accessed directly as a string object, using member str.*/ std::ostringstream oss; oss << "https://www.bitstamp.net/api/" << direction << "/"; /* public member function std::ostringstream::str 1.string str() const; 2.void str (const string& s); Get/set content The first form (1) returns a string object with a copy of the current contents of the stream. The second form (2) sets s as the contents of the stream, discarding any previous contents. The object preserves its open mode: if this includes ios_base::ate, the writing position is moved to the end of the new sequence. */ std::string url = oss.str(); oss.clear(); oss.str(""); /*This operator (<<) applied to an output stream is known as insertion operator. It will insert objects into the output stream*/ oss << "amount=" << quantity << "&price=" << std::fixed << std::setprecision(2) << limPrice; std::string options = oss.str(); /*oss will return amount=&price=<limPrice value with precision = 2>*/ /*url used as argument to function below stores the https://www.bitstamp.net/api/" << direction API address*/ json_t *root = authRequest(curl, params, url, options);/*root will get assigned with this authRequest*/ /*"id" is a key in root JSON object. We are fetching its value*/ int orderId = json_integer_value(json_object_get(root, "id")); if (orderId == 0) { std::cout << "<Bitstamp> Order ID = 0. Message: " << json_dumps(root, 0) /*json_dumps returns the JSON form of root. 0 is a used for indentation*/ << std::endl; } std::cout << "<Bitstamp> Done (order ID: " << orderId << ")\n" << std::endl; json_decref(root); return orderId; }
int borrowBtc(Parameters& params, double amount) { int borrowId = 0; bool isBorrowAccepted = false; std::ostringstream oss; oss << "api_key=" << params.okcoinApi << "&symbol=btc_usd&days=fifteen&amount=" << 1 << "&rate=0.0001&secret_key=" << params.okcoinSecret; std::string signature = oss.str(); oss.clear(); oss.str(""); oss << "api_key=" << params.okcoinApi << "&symbol=btc_usd&days=fifteen&amount=" << 1 << "&rate=0.0001"; std::string content = oss.str(); json_t* root = authRequest(params, "https://www.okcoin.com/api/v1/borrow_money.do", signature, content); std::cout << "<OKCoin> Borrow " << amount << " BTC:\n" << json_dumps(root, 0) << std::endl; isBorrowAccepted = json_boolean_value(json_object_get(root, "result")); if (isBorrowAccepted) { borrowId = json_integer_value(json_object_get(root, "borrow_id")); } json_decref(root); return borrowId; }
void ClientImpl::initiateAuthentication(PendingConnection* pc, struct bufferevent *bev)throw (voltdb::LibEventException) { logMessage(ClientLogger::DEBUG, "ClientImpl::initiateAuthentication"); FreeBEVOnFailure protector(bev); bufferevent_setwatermark( bev, EV_READ, 4, HIGH_WATERMARK); bufferevent_setwatermark( bev, EV_WRITE, 8192, 262144); if (bufferevent_enable(bev, EV_READ)) { throw voltdb::LibEventException(); } AuthenticationRequest authRequest( m_username, "database", m_passwordHash, m_hashScheme ); ScopedByteBuffer bb(authRequest.getSerializedSize()); authRequest.serializeTo(&bb); struct evbuffer *evbuf = bufferevent_get_output(bev); if (evbuffer_add( evbuf, bb.bytes(), static_cast<size_t>(bb.remaining()))) { throw voltdb::LibEventException(); } protector.success(); }
int sendOrder(Parameters& params, std::string direction, double quantity, double price){ double limPrice; // define limit price to be sure to be executed if (direction.compare("buy") == 0) { limPrice = getLimitPrice(params, quantity, false); } else if (direction.compare("sell") == 0) { limPrice = getLimitPrice(params, quantity, true); } *params.logFile << "<SevenNintySix> Trying to send a \"" << direction << "\" limit order: " << quantity << "@$" << limPrice << "..." << std::endl; std::ostringstream oss; oss << "\"symbol\":\"btcusd\", \"amount\":\"" << quantity << "\", \"price\":\"" << limPrice << "\", \"exchange\":\"bitfinex\", \"side\":\"" << direction << "\", \"type\":\"limit\""; std::string options = oss.str(); json_t* root= authRequest(params, "https://796.com/v2/weeklyfutures/orders", "order/new", options); int orderId = json_integer_value(json_object_get(root, "id")); *params.logFile << "<SevenNintySix> Done (order ID: " << orderId << ")\n" << std::endl; json_decref(root); return orderId; }
int sendOrder(Parameters& params, std::string direction, double quantity, double price) { if (direction.compare("buy") != 0 && direction.compare("sell") != 0) { *params.logFile << "Error: Neither \"buy\" nor \"sell\" selected" << std::endl; return 0; } double limPrice; // define limit price to be sure to be executed if (direction.compare("buy") == 0) { limPrice = getLimitPrice(params, quantity, false); } else { limPrice = getLimitPrice(params, quantity, true); } *params.logFile << "<Kraken> Trying to send a \"" << direction << "\" limit order: " << quantity << " @ $" << limPrice << "..." << std::endl; std::string pair = "XXBTZUSD"; std::string type = direction; std::string ordertype = "limit"; std::string pricelimit = patch::to_string(limPrice); std::string volume = patch::to_string(quantity); std::string options = "pair=" + pair + "&type=" + type + "&ordertype=" + ordertype + "&price=" + pricelimit + "&volume=" + volume; json_t* res = authRequest(params, "https://api.kraken.com", "/0/private/AddOrder", options); json_t* root = json_object_get(res, "result"); if (json_is_object(root) == 0) { *params.logFile << json_dumps(res, 0) << std::endl; exit(0); } std::string txid = json_string_value(json_array_get(json_object_get(root, "txid"), 0)); int max_id = id_to_transaction->size(); (*id_to_transaction)[max_id] = txid; *params.logFile << "<Kraken> Done (transaction ID: " << txid << ")\n" << std::endl; json_decref(root); return max_id; }
double getAvail(Parameters& params, std::string currency) { std::ostringstream oss; oss << "api_key=" << params.okCoinApi << "&secret_key=" << params.okCoinSecret; std::string signature(oss.str()); oss.clear(); oss.str(""); oss << "api_key=" << params.okCoinApi; std::string content(oss.str()); json_t* root = authRequest(params, "https://www.okcoin.com/api/v1/userinfo.do", signature, content); double available; if (currency.compare("usd") == 0) { available = atof(json_string_value(json_object_get(json_object_get(json_object_get(json_object_get(root, "info"), "funds"), "free"), "usd"))); } else if (currency.compare("btc") == 0) { available = atof(json_string_value(json_object_get(json_object_get(json_object_get(json_object_get(root, "info"), "funds"), "free"), "btc"))); } else { available = 0.0; } json_decref(root); return available; }