Skip to content

Commit

Permalink
Updated db with only relaxed profits.
Browse files Browse the repository at this point in the history
Free Software Free Society

To support commits by ctubio,
you can buy-me-a-drink with a small git tip at:
  1GitTipgxvKB3zjCLXRcSgDhC9pivkpc7u

I promise to drink chocolate milk in the development of the next commit.

To request new features or in case this commit breaks something for you,
please create a new github issue with all possible details,
but never share your API Keys!

Signed-off-by: Carles Tubio <ctubio@users.noreply.github.com>
  • Loading branch information
ctubio committed Nov 2, 2017
1 parent 5997381 commit 5bfa565
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ namespace K {
return sum;
};
static void calcWallet(mWallet k) {
static unsigned long profitT_21s = 0;
static mutex walletMutex,
profitMutex;
static map<string, mWallet> pgWallet;
Expand All @@ -246,7 +247,10 @@ namespace K {
double quoteValue = baseWallet.amount * mgFairValue + quoteWallet.amount + baseWallet.held * mgFairValue + quoteWallet.held;
unsigned long now = FN::T();
mProfit profit(baseValue, quoteValue, now);
DB::insert(uiTXT::Position, profit, false, "NULL", FN::T() - qp.profitHourInterval * 36e+5);
if (profitT_21s+21e+3 < FN::T()) {
profitT_21s = FN::T();
DB::insert(uiTXT::Position, profit, false, "NULL", now - qp.profitHourInterval * 36e+5);
}
profitMutex.lock();
pgProfit.push_back(profit);
for (vector<mProfit>::iterator it = pgProfit.begin(); it != pgProfit.end();)
Expand Down

0 comments on commit 5bfa565

Please sign in to comment.