mirror of
https://github.com/dennisreimann/stacking-sats-kraken.git
synced 2026-08-13 12:33:45 +02:00
Price ratio (#15)
* add option for percentage of current price * remark on multiple configurations with raspiblitz * hint on new option in the example * add ratio for price manipulation, e.g. to ensure maker fees
This commit is contained in:
parent
d6b4f892ec
commit
07b2152c4d
2 changed files with 8 additions and 2 deletions
|
|
@ -44,6 +44,7 @@ KRAKEN_ORDER_TYPE="market" # "limit" (default) or "market"
|
|||
KRAKEN_API_FIAT="USD" # the governmental shitcoin you are selling
|
||||
KRAKEN_BUY_AMOUNT=21 # fiat amount you trade for the future of money
|
||||
KRAKEN_FEE_CURRENCY="XBT" # pay fee in this currency, e.g. buying XBT for USD and paying fee in XBT
|
||||
#KRAKEN_BUY_RATIO=0.99 # place order at 99% of current bid price, e.g. to ensure maker fees
|
||||
|
||||
# used for withdrawal
|
||||
KRAKEN_MAX_REL_FEE=0.5 # maximum fee in % that you are willing to pay
|
||||
|
|
@ -88,6 +89,7 @@ PATH=/bin:/usr/sbin:/usr/bin:/usr/local/bin
|
|||
|
||||
**Note:** Do not run `npm` directly on the RaspiBlitz, like show in the examples below.
|
||||
Please use the `/home/stackingsats/stacking-sats-kraken/stacksats.sh` shell script instead, as this loads your configuration.
|
||||
On RaspiBlitz (v1.8 and above) you may use different configuration files for e.g. family or business.
|
||||
|
||||
To run the script manually, switch to the `stackingsats` user and use this command:
|
||||
|
||||
|
|
@ -157,6 +159,7 @@ export KRAKEN_BUY_AMOUNT=21
|
|||
export KRAKEN_MAX_REL_FEE=0.5
|
||||
export KRAKEN_WITHDRAW_KEY="descriptionOfWithdrawalAddress"
|
||||
export KRAKEN_DRY_RUN_PLACE_NO_ORDER=1
|
||||
export KRAKEN_BUY_RATIO=0.99
|
||||
|
||||
# run script
|
||||
cd $(cd `dirname $0` && pwd)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => {
|
||||
const [fiat, amount, feeCurrency] = getEnv('KRAKEN_API_FIAT', 'KRAKEN_BUY_AMOUNT', 'KRAKEN_FEE_CURRENCY')
|
||||
const ratio = getEnvOpt('KRAKEN_BUY_RATIO', '1.0')
|
||||
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
|
||||
|
|
@ -29,14 +30,16 @@ module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => {
|
|||
const [{ a: [a], b: [b] }] = Object.values(ticker)
|
||||
const ask = parseFloat(a)
|
||||
const bid = parseFloat(b)
|
||||
const price = bid
|
||||
const price = Math.round( bid * ratio * 10 ) / 10
|
||||
|
||||
// Calculate volume and adjust precision
|
||||
const volume = (amount / price).toFixed(8)
|
||||
|
||||
console.log('💰 Balance:', fiatBalance, fiat, '/', cryptoBalance, crypto, '\n')
|
||||
console.log('📈 Ask:', ask, fiat)
|
||||
console.log('📉 Bid:', bid, fiat, '\n')
|
||||
console.log('📉 Bid:', bid, fiat, '(', ( ratio * 100 ), '%', ')')
|
||||
console.log('🏷️ Price:', price, fiat, "/", "XBT")
|
||||
console.log('\n')
|
||||
|
||||
if (parseFloat(fiatBalance) < parseFloat(amount)) {
|
||||
console.log('❌ Insufficient funds')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue