Giter Site home page Giter Site logo

yabc's People

Contributors

robertkarl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gorilik324

yabc's Issues

Support multiple open 'pools'

Required for #62.

Currently the algorithm looks like this:

for each different coin:
  select all tx's that appear to contain that coin
  create an empty pool
  for each tx we selected:
    call process_one()

At the very least we need to make sure that we select the right tx's for each coin.

cost basis reports for coin/coin trades need to lookup prices

resolved when:
the cost basis reports generated from running yabc on adhoc.csv look up a dollar value for the amount of BTC and ETH on that date.

$ python -m yabc /home/rk/code/yabc/testdata/adhoc/adhoc.csv
...
<Sold 10000 ETH on 2018-05-22 00:00:00 for $0. Exchange: adhoc. Profit:$0.
	<TX 2018-05-22 00:00:00 SELL 0.33 BTC for 10000 ETH, from exchange adhoc. Fee 0.001 BTC>>

"Perpetual Futures" contracts

Perpetual futures are a strange beast.

https://help.bybit.com/hc/en-us/articles/360012865933-Bybit-Definition-Features-Uses

Two traders, one short and one long, enter into a contract with each other. Payments are made, typically in BTC, based on price movements in the underlying asset. TODO: Does the exchange take long and short positions with their customers?

bybit, bitmex and deribit offer these contracts.

Make yabc understand them better. AFAIK no IRS guidance has been given about this, so the best way to treat this seems to me to be:

  • First, track the initial deposit to the exchange. This is typically in BTC.
  • Once the user enters into one of these contracts, there is a daily stream of BTC inputs and BTC payments made.
    • For each input, when the price moves in your favor, assign a cost basis to that coin from the current price
    • For each output, when you lose bitcoin, treat this the same as making a payment for something that cost $0. The BTC vanished, you received nothing for it, create a sale at a loss equal to the cost basis.

Coin/coin trades

Support markets like ETH/BTC.

These are required for importing trade data from Binance for example.

  • Right now, we have asset_name as a field on Transaction.

Migration plan

  • add new fields to in-memory object (quantity_traded, quantity_received, symbol_traded, symbol_received)
  • Allow passing the new fields to constructor of Transaction
  • Deprecate usd_subtotal and quantity fields
  • Add migrate script to add the fields to existing DBs
  • write the values for 4 new fields to in-memory objects. (Still create Transactions using old syntax, but propagate it to new columns). This ability is critical for migration.
  • Move basis calculation logic to use NEW fields. Stop using usd_subtotal in basis.py. This is the most critical step for making sure basis calculations are still correct.

At this point we should be able to use both syntaxes. Either usd_subtotal and asset_name, or the fully specified one.

  • Migrate ALL usages of Transaction over to new syntax
  • Remove the deprecated parameters from Transaction constructor

If the inputs don't make sense, don't panic

If inputs are received with only SELLs, but no BUYS, we currently panic.

Instead detect this and use a cost basis of zero for those sells.

    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/rk/code/yabc/src/yabc/__main__.py", line 42, in <module>
    main()
  File "/home/rk/code/yabc/src/yabc/__main__.py", line 36, in main
    reports = processor.process()
  File "/home/rk/code/yabc/src/yabc/basis.py", line 293, in process
    reports, pool = _process_all(self.method, self.txs)
  File "/home/rk/code/yabc/src/yabc/basis.py", line 257, in _process_all
    ops = process_one(tx, pool)
  File "/home/rk/code/yabc/src/yabc/basis.py", line 128, in process_one
    amount += pool[pool_index].quantity
IndexError: list index out of range

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.