Socket
Socket
Sign inDemoInstall

@fl0wo/wallet-simulator

Package Overview
Dependencies
95
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fl0wo/wallet-simulator

Tool for tracking and simulating trades, work as well with cryptocurrency transactions.


Version published
Maintainers
1
Weekly downloads
1
decreased by-83.33%

Weekly downloads

Readme

Source

Wallet Simulator

A class to simulate a cryptocurrency wallet in Node.js

Can Integrate with CCTX to Import/Export information from real world crypto exchanges.

Installation

npm install wallet-simulator

Usage

import { WalletSimulator } from 'wallet-simulator';

const wallet = new WalletSimulator(1000)
    .addTrade({ ticker: 'BTC', price: 10, quantity: 1, type: TradeMove.BUY })
    .addTrade({ ticker: 'ETH', price: 100, quantity: 2, type: TradeMove.BUY })
    .updatePrice('BTC', 12)
    .updatePrice('ETH', 110);

console.log(wallet.getPositionValue('BTC')); // 12
console.log(wallet.getPositionValue('ETH')); // 220
console.log(wallet.getTotalValue()); // 1232

console.log(wallet.getPositionAverageCost('BTC')); // 10
console.log(wallet.getEstimatedLiquidationPrice('BTC')); // 10
console.log(wallet.getEstimatedUnrealizedProfitLoss('BTC')); // 2

Todo

  • Price update method on particular asset
  • Add new trades balancing current balance
  • P&L and cost basis for each asset
  • Donut information on % of owned assets
  • Trend snapshots graph of balance at "every day"
  • Trend snapshots graph of balance if just buy & hold at day 0
  • Fee % on addTrade operations
  • Export Wallet as JSON
  • Import Wallet from JSON
  • Reverse-Engineering data from Real Exchanges Trades
  • Filter on Max Buy Power allowed and list of allowed-desired assets to open orders

Methods

CommandDescription
addTradeUpdate balance and holdings based on trade
updatePriceSet price for a particular asset
getPositionValueReturn the value owned on this wallet of a particular asset
getTotalValueReturn the sum of all funds in this wallet
getPositionAverageCostReturn the average cost of a particular asset
getEstimatedLiquidationPriceReturn the estimated liquidation price of a particular asset
getPriceGet latest known price for an asset
getPositionAverageCostAverage spent position costs for a particular asset
getDonutAssetInformationReturn a donut type chart with all assets owned in %
getTrendBalanceSnapshotsTrend balance graph snapshots of daily gaps
exportToTextReturn the estimated unrealized profit or loss of a particular asset
exportToJsonReturns a stringified verson of the WalletSimulator object
importFromJsonStringReverse operation of exportToJson

Properties

FieldDescription
balanceCurrent available balance in the base currency (EUR,USD,Bananas,Apples,etc...)
holdingsMap with quantities owned of each asset
pricesMap with the last known price for each asset
costBasisCurrent sum of costs paid for an asset
tradesAll trades
daySnapshotsDate separated values of Wallet Snapshot in the history

Test

npm run test

Authors

  • @fl0wo

License

This project is licensed under the Apache License - see the LICENSE file for details.

Contributions

Want to contribute to this project? Great! We welcome contributions and are always looking for ways to improve this package. Please take a look at the CONTRIBUTING file for more information on how to get started.

Support

If you have any questions or issues with this package, please open an issue on the Github repository or contact us at sabaniflorian@gmail.com

You can also find me on Twitter

Keywords

FAQs

Last updated on 12 Apr 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc