Skip to content

Commit

Permalink
Fixed depleted state to resolve #1117.
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 = 25270.39 EUR. /
 -------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
  • Loading branch information
ctubio committed Jul 20, 2021
1 parent b7dd723 commit 52303f0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 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 = 4
BUILD = 21
BUILD = 22

OBLIGATORY = DISCLAIMER: This is strict non-violent software: \n$\
if you hurt other living creatures, please stop; \n$\
Expand Down
23 changes: 13 additions & 10 deletions src/bin/+portfolios/+portfolios.client/Wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ export class WalletsComponent {
private addRowData = (o: any) => {
if (!this.grid.api) return;
var sum = 0;
var pin_sum = document.getElementById('balance_pin');
if (o === null) {
this.grid.api.setRowData([]);
this.selection = null;
Expand Down Expand Up @@ -257,20 +256,24 @@ export class WalletsComponent {
.concat(Shared.resetRowData('held', held, node))
.concat(Shared.resetRowData('total', total, node))
});
});

this.grid.api.onFilterChanged();

if (!this.grid.api.getSelectedNodes().length)
this.grid.api.onSortChanged();
if (!this.grid.api.getSelectedNodes().length)
this.grid.api.onSortChanged();

if (pin_sum) {
var el = document.getElementById('balance_percent_' + o.wallet.currency);
var pin_sum = document.getElementById('balance_pin');
if (pin_sum) {
pin_sum.innerHTML = Shared.str(sum, 8);

this.grid.api.forEachNode((node: RowNode) => {
var el = document.getElementById('balance_percent_' + node.data.currency);
if (el) {
var val = Shared.str(o.wallet.value / Shared.num(pin_sum.innerHTML) * 100, 2);
var val = Shared.str(Shared.num(node.data.balance) / sum * 100, 2);
if (val != el.innerHTML) el.innerHTML = val;
}
}
});

if (pin_sum) pin_sum.innerHTML = Shared.str(sum, 8);
});
}
};
};
10 changes: 7 additions & 3 deletions src/bin/scaling-bot/scaling-bot.data.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ namespace analpaper {
void debug(const string &step) {
if (K.arg<int>("debug-quotes"))
K.log("DEBUG QE", "[" + step + "] "
+ to_string((int)bid.state) + ":"
+ to_string((int)ask.state) + " "
+ ((json){{"bid", bid}, {"ask", ask}}).dump()
+ to_string((int)ask.state) + ":"
+ to_string((int)bid.state) + " "
+ to_string((int)ask.isPong) + ":"
+ to_string((int)bid.isPong) + " "
+ ((json){{"ask", ask}, {"bid", bid}}).dump()
);
};
};
Expand Down Expand Up @@ -367,6 +369,8 @@ namespace analpaper {
return true;
};
void calcRawQuotes() {
quotes.ask.isPong =
quotes.bid.isPong = false;
quotes.bid.size =
quotes.ask.size = K.arg<double>("order-size");
quotes.bid.price = fmin(
Expand Down
8 changes: 5 additions & 3 deletions src/bin/stable--bot/stable--bot.data.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ namespace analpaper {
void debug(const string &step) {
if (K.arg<int>("debug-quotes"))
K.log("DEBUG QE", "[" + step + "] "
+ to_string((int)bid.state) + ":"
+ to_string((int)ask.state) + " "
+ ((json){{"bid", bid}, {"ask", ask}}).dump()
+ to_string((int)ask.state) + ":"
+ to_string((int)bid.state) + " "
+ to_string((int)ask.isPong) + ":"
+ to_string((int)bid.isPong) + " "
+ ((json){{"ask", ask}, {"bid", bid}}).dump()
);
};
};
Expand Down
26 changes: 9 additions & 17 deletions src/bin/trading-bot/trading-bot.data.h
Original file line number Diff line number Diff line change
Expand Up @@ -1973,11 +1973,11 @@ namespace tribeca {
void debug(const string &step) {
if (K.arg<int>("debug-quotes"))
K.log("DEBUG QE", "[" + step + "] "
+ to_string((int)bid.state) + ":"
+ to_string((int)ask.state) + " "
+ to_string((int)bid.isPong) + ":"
+ to_string((int)ask.isPong) + " "
+ ((json){{"bid", bid}, {"ask", ask}}).dump()
+ to_string((int)ask.state) + ":"
+ to_string((int)bid.state) + " "
+ to_string((int)ask.isPong) + ":"
+ to_string((int)bid.isPong) + " "
+ ((json){{"ask", ask}, {"bid", bid}}).dump()
);
};
};
Expand Down Expand Up @@ -2528,30 +2528,22 @@ namespace tribeca {
}
};
void applyDepleted() {
if (!quotes.bid.empty()) {
const Amount minBid = K.gateway->minValue
? fmax(K.gateway->minSize, K.gateway->minValue / quotes.bid.price)
: K.gateway->minSize;
if (!quotes.bid.empty())
if ((K.gateway->margin == Future::Spot
? wallet.quote.total / quotes.bid.price
: (K.gateway->margin == Future::Inverse
? wallet.base.amount * quotes.bid.price
: wallet.base.amount / quotes.bid.price)
) < minBid
) < quotes.bid.size
) quotes.bid.clear(QuoteState::DepletedFunds);
}
if (!quotes.ask.empty()) {
const Amount minAsk = K.gateway->minValue
? fmax(K.gateway->minSize, K.gateway->minValue / quotes.ask.price)
: K.gateway->minSize;
if (!quotes.ask.empty())
if ((K.gateway->margin == Future::Spot
? wallet.base.total
: (K.gateway->margin == Future::Inverse
? wallet.base.amount * quotes.ask.price
: wallet.base.amount / quotes.ask.price)
) < minAsk
) < quotes.ask.size
) quotes.ask.clear(QuoteState::DepletedFunds);
}
};
void applyWaitingPing() {
if (qp.safety == QuotingSafety::Off) return;
Expand Down

0 comments on commit 52303f0

Please sign in to comment.