[BOT] Worker erweitert um permissions für buy und sell
This commit is contained in:
parent
89fcfec7d0
commit
a5f40ff006
@ -13,6 +13,15 @@ export default class TradingPairs {
|
||||
static XRPUSDT = new TradingPair(Assets.XRP, Assets.USDT);
|
||||
static DOGEUSDT = new TradingPair(Assets.DOGE, Assets.USDT);
|
||||
|
||||
static BTCUSDC = new TradingPair(Assets.BTC, Assets.USDC);
|
||||
static ETHUSDC = new TradingPair(Assets.ETH, Assets.USDC);
|
||||
static GALAUSDC = new TradingPair(Assets.GALA, Assets.USDC);
|
||||
static ALGOUSDC = new TradingPair(Assets.ALGO, Assets.USDC);
|
||||
static TRXUSDC = new TradingPair(Assets.TRX, Assets.USDC);
|
||||
static ADAUSDC = new TradingPair(Assets.ADA, Assets.USDC);
|
||||
static XRPUSDC = new TradingPair(Assets.XRP, Assets.USDC);
|
||||
static DOGEUSDC = new TradingPair(Assets.DOGE, Assets.USDC);
|
||||
|
||||
static TRADING_PAIRS = [
|
||||
this.BTCUSDT,
|
||||
this.ETHUSDT,
|
||||
@ -23,6 +32,14 @@ export default class TradingPairs {
|
||||
this.ADAUSDT,
|
||||
this.XRPUSDT,
|
||||
this.DOGEUSDT,
|
||||
this.BTCUSDC,
|
||||
this.ETHUSDC,
|
||||
this.GALAUSDC,
|
||||
this.ALGOUSDC,
|
||||
this.TRXUSDC,
|
||||
this.ADAUSDC,
|
||||
this.XRPUSDC,
|
||||
this.DOGEUSDC
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -24,6 +24,16 @@ export default class AbstractWorker extends Serializable {
|
||||
*/
|
||||
#pool = "default";
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
#allowBuy = true;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
#allowSell = true;
|
||||
|
||||
/**
|
||||
* @type {TradingPair} tradingpair
|
||||
*/
|
||||
@ -134,6 +144,34 @@ export default class AbstractWorker extends Serializable {
|
||||
this.#strategy = strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isAllowSell(){
|
||||
return this.#allowSell;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} allowSell
|
||||
*/
|
||||
setAllowBuy(allowSell){
|
||||
this.#allowSell = allowSell;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isAllowBuy(){
|
||||
return this.#allowBuy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} allowSell
|
||||
*/
|
||||
setAllowBuy(allowBuy){
|
||||
this.#allowBuy = allowBuy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Logger}
|
||||
*/
|
||||
@ -188,6 +226,8 @@ export default class AbstractWorker extends Serializable {
|
||||
obj.id = this.#id;
|
||||
obj.name = this.#name;
|
||||
obj.pool = this.#pool;
|
||||
obj.allowBuy = this.#allowBuy;
|
||||
obj.allowSell = this.#allowSell;
|
||||
obj.tradingPair = SerializableHelper.serialize(this.#tradingpair);
|
||||
obj.strategy = SerializableHelper.serialize(this.#strategy);
|
||||
|
||||
@ -210,6 +250,12 @@ export default class AbstractWorker extends Serializable {
|
||||
if (obj.pool != null) {
|
||||
worker.#pool = obj.pool;
|
||||
}
|
||||
if (obj.allowBuy != null) {
|
||||
worker.#allowBuy = obj.allowBuy;
|
||||
}
|
||||
if (obj.allowSell != null) {
|
||||
worker.#allowSell = obj.allowSell;
|
||||
}
|
||||
|
||||
return worker;
|
||||
}
|
||||
|
||||
@ -37,12 +37,12 @@ export default class DefaultWorker extends AbstractWorker{
|
||||
|
||||
const price = parseFloat(bestBid.price);
|
||||
|
||||
if(transactionlimit > transactions.length && this.getStrategy().shouldBuy()){
|
||||
if(this.isAllowBuy() && transactionlimit > transactions.length && this.getStrategy().shouldBuy()){
|
||||
this.getApiProvider().requestBuy(this, Math.round(50 / price), price);
|
||||
}
|
||||
|
||||
for(let transaction of transactions){
|
||||
if(transaction.phase == TransactionPhase.BUY_DONE && this.getStrategy().shouldSell(transaction)){
|
||||
if(this.isAllowSell() && transaction.phase == TransactionPhase.BUY_DONE && this.getStrategy().shouldSell(transaction)){
|
||||
this.getApiProvider().requestSell(this, transaction, price);
|
||||
} else if(this.getStrategy().shouldCancle(transaction)){
|
||||
this.getApiProvider().requestCancle(this, transaction);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user