Merge tag 'v0.4.3'

0.4.3

revert order price from custom "bid" to default "ask"
as now order type "market" is available.

# gpg: directory '/c/Users/william/.gnupg' created
# gpg: keybox '/c/Users/william/.gnupg/pubring.kbx' created
# gpg: Signature made Wed Apr 21 11:43:06 2021
# gpg:                using RSA key F20858435799A6F10089A82B5009E1797F03F8D0
# gpg: Can't check signature: No public key

# Conflicts:
#	commands/stack.js
This commit is contained in:
william
2021-08-08 18:52:15 +02:00
6 changed files with 593 additions and 172 deletions

View File

@@ -1,9 +1,24 @@
module.exports = async (kraken, validate, getEnv) => {
const [crypto, fiat, amount] = getEnv('KRAKEN_API_CRYPTO', 'KRAKEN_API_FIAT', 'KRAKEN_BUY_AMOUNT')
module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => {
const [crypto, fiat, amount, feeCurrency] = getEnv('KRAKEN_API_CRYPTO', 'KRAKEN_API_FIAT', 'KRAKEN_BUY_AMOUNT', 'KRAKEN_FEE_CURRENCY')
const ordertype = getEnvOpt('KRAKEN_ORDER_TYPE', 'limit', ['limit', 'market'])
// if living in Germany, one needs to add an additional parameter to explicitly agree to the trade
// if the parameter is not set one will get the following error: EOrder:Trading agreement required
// see https://support.kraken.com/hc/en-us/articles/360000920026--Trading-agreement-required-error-for-German-residents
const trading_agreement = getEnvOpt('KRAKEN_GERMANY_TRADING_AGREEMENT', '', ['agree', ''])
// https://www.kraken.com/features/api
const pair = `${crypto}${fiat}`
// for explanation of oflags see https://www.kraken.com/features/api#add-standard-order
var fee = ""
if (feeCurrency == crypto) {
fee = "fcib"
} else if (feeCurrency == fiat) {
fee = "fciq"
} else {
fee = ""
}
// Fetch and display information
const { result: balance } = await kraken.api('Balance')
const { result: ticker } = await kraken.api('Ticker', { pair })
@@ -13,7 +28,7 @@ module.exports = async (kraken, validate, getEnv) => {
const [{ a: [a], b: [b] }] = Object.values(ticker)
const ask = parseFloat(a)
const bid = parseFloat(b)
const price = ask
const price = bid
// Calculate volume and adjust precision
const volume = (amount / price).toFixed(8)
@@ -23,8 +38,10 @@ module.exports = async (kraken, validate, getEnv) => {
console.log('📉 Bid:', bid, fiat, '\n')
// Place order
const details = { pair, type: 'buy', ordertype: 'limit', price, volume }
const details = { pair, type: 'buy', ordertype, price, volume }
if (validate) details.validate = true
if (trading_agreement) details.trading_agreement = trading_agreement
if (fee) details.oflags = fee
const { result: { descr: { order }, txid } } = await kraken.api('AddOrder', details)

View File

@@ -1,4 +1,4 @@
module.exports = async (kraken, validate, getEnv) => {
module.exports = async (kraken, validate, { getEnv }) => {
const [maxFee, key] = getEnv('KRAKEN_MAX_REL_FEE', 'KRAKEN_WITHDRAW_KEY')
// https://api.kraken.com/0/private/WithdrawInfo