Skip to content

Commit

Permalink
Added conditional ws streams to Poloniex and Kraken.
Browse files Browse the repository at this point in the history
████ ███  To request new features or in case this commit breaks something for you,
████ ███  please, create a new github issue with all possible information for me,
▓███▀█▄   but never share your API Keys!
▒▓██ ███
░▒▓█ ███  Signed-off-by: Carles Tubio <ctubio@users.noreply.github.com>
 _______________________________
/ Hello, WORLD!                 \
|                               |
\ pssst.. 1 BTC = 33043.34 EUR. /
 -------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
  • Loading branch information
ctubio committed Jun 14, 2021
1 parent f8edbc0 commit 4f17736
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ K ?= K.sh
MAJOR = 0
MINOR = 6
PATCH = 2
BUILD = 6
BUILD = 7

OBLIGATORY = DISCLAIMER: This is strict non-violent software: \n$\
if you hurt other living creatures, please stop; \n$\
Expand Down
27 changes: 22 additions & 5 deletions src/bin/+portfolios/+portfolios.data.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,34 @@
//! \brief Welcome user! (just a manager of portfolios).

namespace analpaper {
class Engine {
private:
Levels levels;
struct Wallets {
map<string, Wallet> wallet;
private_ref:
const KryptoNinja &K;
public:
Engine(const KryptoNinja &bot)
Wallets(const KryptoNinja &bot)
: K(bot)
{};
void read_from_gw(const Wallet &raw) {
wallet[raw.currency] = raw;
};
bool ready() const {
const bool err = wallet.empty();
if (err and Tspent > 21e+3)
K.logWar("QE", "Unable to display portfolios, missing wallet data", 3e+3);
return !err;
};
};

class Engine {
private:
Wallets wallet;
public:
Engine(const KryptoNinja &bot)
: wallet(bot)
{};
void read(const Wallet &rawdata) {
cout << ((json)rawdata).dump() << endl;
wallet.read_from_gw(rawdata);
};
};
}
7 changes: 3 additions & 4 deletions src/lib/Krypto.ninja-apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ namespace ₿ {
async.wallet.wait_for(loop, [&]() { return sync_wallet(); });
};
void ask_for_never_async_data(const unsigned int &tick) {
if (!(tick % 15)) balance();
if (async.wallet.write and !(tick % 15)) balance();
};
};

Expand Down Expand Up @@ -477,12 +477,11 @@ namespace ₿ {
GwApiWs::connect();
if (GwApiWs::connected()) {
CURLcode rc;
if (CURLE_OK == (rc = WebSocketTwin::connect(twin(ws)))) {
if (CURLE_OK == (rc = WebSocketTwin::connect(twin(ws))))
WebSocketTwin::start(GwExchangeData::loopfd, [&]() {
wait_for_async_data();
});
print("WS Streaming orders");
} else reconnect(string("CURL connect Error: ") + curl_easy_strerror(rc));
else reconnect(string("CURL connect Error: ") + curl_easy_strerror(rc));
}
};
void disconnect() override {
Expand Down

0 comments on commit 4f17736

Please sign in to comment.