babao.inputs.ledger package

Submodules

babao.inputs.ledger.fakeLedgerInput module

Handle logging in database all our fake transactions (dry-run)

class babao.inputs.ledger.fakeLedgerInput.ABCFakeLedgerInput(log_to_file=True, temp=False)[source]

Bases: babao.inputs.ledger.ledgerInputBase.ABCLedgerInput

Base class for any fake ledger

asset

Overide this method with the desired CryptoEnum / QuoteEnum ex: self.asset = CryptoEnum.XBT

buy(ledger, volume_spent, price, timestamp=None)[source]

Buy with the current ledger asset the asset of the given ´ledger´

(If the current ledger is a quote, this is a buy)
´volume_spent´ quantity spent (including fees)
deposit(ledger, volume, timestamp=None)[source]

Deposit from the current ledger to the given ´ledger´

fetch()[source]

Return a time-serie DataFrame fetched from the internets

This data will be stored on database for later use (and eventual resampling). Data can be continuous. Index must be nanosecond timestamps.

logTransaction(typ, volume, refid, fee=0, product=0, timestamp=None)[source]

Log transaction in database if ´timestamp´ is not given, the current time will be used

This should’nt be used outside of this class

sell(ledger, volume_spent, price, timestamp=None)[source]

Buy with the asset of the given ´ledger´ the current ledger asset

(If the current ledger is a quote, this is a sell)
´volume_spent´ quantity spent (including fees)
withdraw(ledger, volume, timestamp=None)[source]

Withdraw from the current ledger to the given ´ledger´

babao.inputs.ledger.krakenLedgerInput module

Handle logging in database all our real transactions on kraken api (wet-run) Also fetch from kraken api the history of your past transactions

class babao.inputs.ledger.krakenLedgerInput.ABCKrakenLedgerInput(log_to_file=True, unused_temp=False)[source]

Bases: babao.inputs.ledger.ledgerInputBase.ABCLedgerInput, babao.inputs.krakenInputBase.ABCKrakenInput

Base class for any kraken ledger

buy(ledger, volume_spent, price, timestamp=None)[source]

Buy with the current ledger asset the asset of the given ´ledger´

(If the current ledger is a quote, this is a buy)
´volume_spent´ quantity spent (including fees)
deposit(ledger, volume, timestamp=None)[source]

Deposit from the current ledger to the given ´ledger´

fetch()[source]

Return a time-serie DataFrame fetched from the internets

This data will be stored on database for later use (and eventual resampling). Data can be continuous. Index must be nanosecond timestamps.

sell(ledger, volume_spent, price, timestamp=None)[source]

Buy with the asset of the given ´ledger´ the current ledger asset

(If the current ledger is a quote, this is a sell)
´volume_spent´ quantity spent (including fees)
withdraw(ledger, volume, timestamp=None)[source]

Withdraw from the current ledger to the given ´ledger´

babao.inputs.ledger.ledgerInputBase module

Handle logging in database all our transactions

TODO: It is really not obvious how you’re gonna link the transaction across various ledgers… kraken doesn’t give you anything else than an “order id”, so you still have to iterate over all entries in all ledgers to find the matching one :/ The good new is, I don’t know when we’ll need that! Anyway, I’ll leave an empty column “product”, which reference another ledger; this could be used for later indexing?

class babao.inputs.ledger.ledgerInputBase.ABCLedgerInput[source]

Bases: babao.inputs.inputBase.ABCInput

Base class for any ledger

asset

Overide this method with the desired CryptoEnum / QuoteEnum ex: self.asset = CryptoEnum.XBT

buy(ledger, volume_spent, price, timestamp=None)[source]

Buy with the current ledger asset the asset of the given ´ledger´

(If the current ledger is a quote, this is a buy)
´volume_spent´ quantity spent (including fees)
deposit(ledger, volume, timestamp=None)[source]

Deposit from the current ledger to the given ´ledger´

fillMissing(resampled_data)[source]

Fill missing values (np.nan/np.inf) in ´resampled_data´

raw_columns = ['volume', 'balance', 'fee', 'refid', 'type', 'product']
resampled_columns = ['balance']
sell(ledger, volume_spent, price, timestamp=None)[source]

Buy with the asset of the given ´ledger´ the current ledger asset

(If the current ledger is a quote, this is a sell)
´volume_spent´ quantity spent (including fees)
withdraw(ledger, volume, timestamp=None)[source]

Withdraw from the current ledger to the given ´ledger´

babao.inputs.ledger.ledgerManager module

Manage all the ledgers and give some utils functions to check balance or buy/sell

babao.inputs.ledger.ledgerManager.buy(crypto_enum, volume)[source]

Buy the given ´volume´ of ´crypto_enum´

babao.inputs.ledger.ledgerManager.buyOrSell(action_enum, crypto_enum, volume=None)[source]

Decide wether to buy or sell (or not) ´volume´ the ´crypto_enum´ based on the given ´action_enum´

It will consider the current ´ledger.BALANCE´, and evenutally update it.

babao.inputs.ledger.ledgerManager.gameOver()[source]

Check if you’re broke

babao.inputs.ledger.ledgerManager.getBalanceInQuote(crypto_enum)[source]

Convert to quote the balance of the LEDGERS[crypto_enum]

babao.inputs.ledger.ledgerManager.getGlobalBalanceInQuote()[source]

Sum and convert to quote the balance of all your LEDGERS

babao.inputs.ledger.ledgerManager.getLastTx()[source]

Return the timestamp of the last transaction in all LEDGERS

babao.inputs.ledger.ledgerManager.initLedgers()[source]

Instantiate all the ledgers and corresponding trade-inputs needed by conf.CRYPTOS / conf.QUOTE

babao.inputs.ledger.ledgerManager.sell(crypto_enum, volume)[source]

Sell the given ´volume´ of ´crypto_enum´

Module contents