Skip to content

Commit

Permalink
Merge pull request #408 from CCKRK/Krakenfix
Browse files Browse the repository at this point in the history
Just going to merge this it's pretty non-contentious
  • Loading branch information
CCKRK authored Feb 14, 2018
2 parents 0335f1a + db3d22c commit f15004a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/exchanges/kraken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace Kraken
// Initialise internal variables
static unique_json krakenTicker = nullptr;
static bool krakenGotTicker = false;
static unique_json krakenLimPrice = nullptr;
static bool krakenGotLimPrice = false;


static RestApi &queryHandle(Parameters &params)
{
Expand Down Expand Up @@ -173,14 +172,9 @@ double getActivePos(Parameters &params)

double getLimitPrice(Parameters &params, double volume, bool isBid)
{
if (!krakenGotLimPrice)
{
auto &exchange = queryHandle(params);
krakenLimPrice.reset(exchange.getRequest("/0/public/Depth?pair=XXBTZUSD"));
}
krakenGotLimPrice = !krakenGotLimPrice;
auto root = krakenLimPrice.get();
auto branch = json_object_get(json_object_get(root, "result"), "XXBTZUSD");
auto &exchange = queryHandle(params);
unique_json root { exchange.getRequest("/0/public/Depth?pair=XXBTZUSD") };
auto branch = json_object_get(json_object_get(root.get(), "result"), "XXBTZUSD");
branch = json_object_get(branch, isBid ? "bids" : "asks");

// loop on volume
Expand Down

0 comments on commit f15004a

Please sign in to comment.