Git Product home page Git Product logo

stellar-downloader's Introduction

Stellar Downloader

Download trades and payment data from the Stellar blockchain network as a CSV file for accounting purposes.

Table of Contents

How it Works

Stellar Downloader uses Node and the Stellar Javascript SDK to pull payments and effects from Horizon.

It uses the /effects endpoint to get all payments and trades, ordering them by the paging_token in ascending order.

It uses the /payments endpoint to fill in data that is unavailable from the /effects endpoint such as the initial funder of an account or the counterparty of a payment.

Everytime it encounters a new trustline, it adds it to the list of headers and prints out the headers to stdout. From that point on, it always prints the cumulative balance of that asset in a new column on the right. In this manner, you will always have the latest balance for all assets on each row in CSV format.

Note: This script will not include any fees paid by the account, and as such, balances for XLM may be slightly off.

Output

This is what the script outputs:

  • trades and payments to stdout in CSV format.
  • column headers to stdout in CSV format. It prefixes headers with - so it can be removed using grep in the bash script. See the How to Run (Advanced) section for more details.
  • new accounts to stderr.

Note: This script will not include any path_payments made by the account at this point in time, although you can easily update the script to include this.

Note: This script will not include any fees paid by the account, and as such, balances for XLM may be slightly off.

Getting Started

Set Up

  1. You can clone the repo by running the following command:
    git clone [email protected]:nikhilsaraf/stellar-downloader.git
  2. Make sure you install Node.js
  3. Set up the Stellar Javascript SDK by installing it from npm:
    npm install --save stellar-sdk

How to Run (Basic)

Run the trades.js script for your account (replace GA... with your account):

node trades.js GA...

You can redirect stdout and stderr to files as desired. See the How to Run (Advanced) section below for more details.

How to Run (Advanced I)

This process will allow you to spider an account, i.e. you can pull data from the initial account as well as all accounts created by the initial account. This will create N files, 1 per account. Note the script will modify your input file, so be careful if you run it more than once.

  1. create a new file called newAccounts.txt with the initial account you want to start with on the first line as follows (replace GA... with your account):
    new account: GA....
    
  2. run the bash script spiderAccounts.sh as follows:
    ./spiderAccounts.sh newAccounts.txt

How to Run (Advanced II)

This process will allow you to run the downloader script for all your market making accounts in a single command and the output files will include the portfolio balances in XLM and USD using a reference price provided by you in the input file. This will not spider any of the accounts and will not modify your original file.

  1. create a new file called markets.csv detailing all your accounts using the following columns (no header line):

    • code: the asset_code on the stellar network
    • issuer: the issuer's address
    • name: any friendly name you want to assign to the token or issuer
    • trader_secret: this will be converted to your trader account, this depends on the test_secret script, see runForMarketsCsv.sh for more information.
    • blank: make sure to leave an empty value here
    • blank: make sure to leave an empty value here
    • blank: make sure to leave an empty value here
    • feed_type: crypto or fiat; takes the reference price from coinmarketcap and currencylayer accordingly
    • feed_token: USD / bitcoin / ethereum / etc.; see coinmarketcap and currencylayer for the values to use here
    • blank: make sure to leave an empty value here
  2. set the CURRENCY_LAYER_API_TOKEN, you can use a .env file to do this, like so (replace ... with your token):

    export CURRENCY_LAYER_API_TOKEN=...
  3. run the bash script runForMarketsCsv.sh as follows:

    ./runForMarketsCsv.sh markets.csv

Questions

Please feel free to ask questions by opening an issue or to contribute to the code using a Pull Request.

stellar-downloader's People

Contributors

nikhilsaraf avatar sirpillage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

stellar-downloader's Issues

support path payments

{ message: 'invalid payment type: path_payment',
is_create_account: false,
is_payment: false,
is_account_merge: false,
is_inflation: false,
....
}

Git cloning permissions may be wrong

Currently attempting to clone the repository as documented returns a Permission denied (publickey) error. I double checked the address in the README; it matches the repository url. Not a huge deal since the repo can be copied manually, but may be worth looking into.

Command used = git clone [email protected]:nikhilsaraf/stellar-downloader.git
Screenshot:
giterror

Request: Example price_map

It is unclear what specific JSON map format price_map should be in. I tried several based on what appears in the trades.sh usage info and the actual code, none of which worked. Examples:

Both of these return SyntaxError: Unexpected token X in JSON at position 1, followed by the traceback, indicating that the error occured on lines 24-26.

  • {"XLM":0.2}
  • {'XLM':0.2}

These just return the usage information:

  • {"code":"XLM", "price":0.2}
  • {{"code":"[otherissuer], "price":0.018} , {"code":"XLM", "price":"0.2"}}

Running it with nil works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.