[#34] Verarbeitung von balance change events
This commit is contained in:
parent
c98ac43d52
commit
2b3a0e3102
@ -238,8 +238,7 @@ export default class TradingBot {
|
||||
handleAccountUpdate(accountUpdateEvent) {
|
||||
switch (accountUpdateEvent.eventType) {
|
||||
case APIEventType.BALANCE_CHANGE:
|
||||
this.#logger.info("Balance update: ", accountUpdateEvent);
|
||||
// TODO update changed balances
|
||||
this.#accountInfo.updateBalances(accountUpdateEvent);
|
||||
break;
|
||||
case APIEventType.TRANSACTION_UPDATE:
|
||||
this.#updateTransaction(accountUpdateEvent);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import BalanceChangeEvent from "../../../apiwrapper/event/BalanceChangeEvent.js";
|
||||
import AccountRights from "./AccountRights.js";
|
||||
import AccountStatus from "./AccountStatus.js";
|
||||
|
||||
@ -23,9 +24,14 @@ export default class AccountInfo {
|
||||
*/
|
||||
#balances = new Map();
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
#lastBalanceUpdate = 0;
|
||||
|
||||
constructor() {
|
||||
//super();
|
||||
this.#updateTime = Date.now();
|
||||
this.#lastBalanceUpdate = Date.now();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,23 +90,19 @@ export default class AccountInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {AccountInformation} accountInfo
|
||||
* @param {BalanceChangeEvent} balanceEvent
|
||||
*/
|
||||
update(accountInfo) {
|
||||
// TODO
|
||||
/*if (accountInfo == null) {
|
||||
updateBalances(balanceEvent){
|
||||
if(balanceEvent.timestamp < this.#lastBalanceUpdate){
|
||||
return;
|
||||
}
|
||||
|
||||
this.#updateTime = accountInfo.updateTime;
|
||||
this.#canDeposit = accountInfo.canDeposit;
|
||||
this.#canTrade = accountInfo.canTrade;
|
||||
this.#canWithdraw = accountInfo.canWithdraw;
|
||||
|
||||
for (let balance of accountInfo.balances) {
|
||||
if (balance.free > 0) {
|
||||
this.#balances.set(balance.asset, balance.free);
|
||||
balanceEvent.changedBalances.forEach((balance, symbol) => {
|
||||
if(balance > 0 || this.#balances.has(symbol)){
|
||||
this.#balances.set(symbol, balance);
|
||||
}
|
||||
}*/
|
||||
});
|
||||
|
||||
this.#lastBalanceUpdate = balanceEvent.timestamp;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user