Re: Newbie: How to manage option trades?

2021-02-28 Thread Martin Blais
On Sun, Feb 28, 2021 at 6:49 PM Rahul Kuchhal  wrote:

> Just a quick update on what I ended up doing.
>
> - I do not do any fancy options strategies, not even naked calls (only
> covered calls).
> - After options expire or the positions get closed, I only need to keep a
> record the cash outflow and inflow. The options details are only in
> narration.
> - So options accounts are needed only until options are held in account
>
> I created a separate file for each account where I trade options to keep
> track of live options. This file has entries like this:
>
> 2021-01-25 open Assets:Vanguard:Brokerage:Options:CUK210820P0001
> CUK210820P0001
> 2021-02-02 open Assets:Vanguard:Brokerage:Options:CNK220121C0002
> CNK220121C0002
>
> 2021-01-25 * "Sold -300.0 Options CUK210820P0001"
> Assets:Vanguard:Brokerage:Options:CUK210820P0001 -300.000
> CUK210820P0001 {0.8200 USD}
> Assets:Vanguard:Brokerage:VMSXX -3000.00 USD
> Assets:Vanguard:Brokerage:VMSXX:Reserved 3000.00 USD
> Assets:Vanguard:Brokerage:VMSXX 245.99 USD
> Expenses:US:BrokerageFees 0.01 USD
> Income:Vanguard:Brokerage:PnL
>
> 2021-02-02 * "Bought 200.0 Options CNK220121C0002"
> Assets:Vanguard:Brokerage:Options:CNK220121C0002 200.000
> CNK220121C0002 {5.5000 USD}
> Assets:Vanguard:Brokerage:VMSXX -1100.00 USD
> Income:Vanguard:Brokerage:PnL
>

Dedicated accounts per options is likely overkill. They won't get lost or
collide in the same account since they will typically all have unique names.
Moreover, if you're doing covered calls, you're selling one of the three
front months (I use the 40-60 DTE) and so you'll be rolling monthly, which
means a lot of account openings and closing.
I would suggest you instead segregate these options by creating a dedicated
account for your covered calls.



> When the positions get closed the entries change into this (the first
> option expired, the second one got sold) and move to the main file:
>
> 2021-01-25 * "Sold -300.0 Options CUK210820P0001"
> Assets:Vanguard:Brokerage:VMSXX 245.99 USD
> Expenses:US:BrokerageFees 0.01 USD
> Income:Vanguard:Brokerage:PnL
>
> 2021-02-02 * "Bought 200.0 Options CNK220121C0002"
> Assets:Vanguard:Brokerage:VMSXX -1100.00 USD
> Income:Vanguard:Brokerage:PnL
>
> 2021-02-10 * "Sold 200.0 Options CNK220121C0002"
> Assets:Vanguard:Brokerage:VMSXX 500.00 USD
> Income:Vanguard:Brokerage:PnL
>
> Automatic importers spit out the transactions broken down into two parts -
> open option trades that go into the secondary file, closed option trades
> that go into the main file.
>

Urg... you're losing your history.
Never overwrite the past, unless it was incorrect.
I would instead create a dedicated transaction to get rid of it, something
like this (like a sale at zero cost):

2021-01-25 * "(RAD) REMOVAL OF OPTION DUE TO EXPIRATION"
^trade-0f92d8a9490f
  Assets:US:Ameritrade:Main:Options 500 SPXW_012221P3655 {4.4200
USD, 2021-01-19} @ 0 USD
  Income:US:Ameritrade:Main:PnL  -2210. USD




>
> This way the number of Options account is limited to the options that I
> currently have open positions in.
>
>
> On Sunday, February 14, 2021 at 10:45:55 AM UTC-5 Rahul Kuchhal wrote:
>
>> Thank you!
>>
>> I see that adding new commodities is the recommended way then.
>>
>> Now on to finding Vanguard and Schwab importers or adopting your
>> Ameritrade importer for them.
>>
>> On Saturday, February 13, 2021 at 5:13:01 PM UTC-5 b...@bben.us wrote:
>>
>>> Good point about the price directive. I agree with your recommendation.
>>> Seems like the best way to handle it is to fix any reporting tooling that
>>> have problems with the flood of commodity symbols to aggregate or page
>>> their output.
>>>
>>> On Sat, Feb 13, 2021, 14:03 Martin Blais  wrote:
>>>
 On Sat, Feb 13, 2021 at 1:34 PM Rahul Kuchhal 
 wrote:

> I am also trying to figure out the best way to represent Sold options
> that open new positions.
>
> The suggested approach below works (kind of).
>
> 2020-12-28 * "Sell March 1 PUT 200 on HOOL"
>Assets:Brokerage:Taxable:HOOL:Options   -1 HOOL_PUT_200_2021_03_01
> {1000 USD}
>Assets:Brokerage:Taxable:Cash 1000 USD
>
> Seems like I would need to add a new currency to HOOL:Options account
> each time I open a new position. Overtime I suspect this may result in
> hundreds (or even thousands) of currencies attached to a single account.
>

 That's what I do. My importer creates them automatically from the TOS
 log.
 Here:

 https://github.com/blais/ameritrade/blob/master/examples/ameritrade2beancount.py

 I'm doing vertical and calendar spreads, collars, covered calls, and
 more. It all works great with Beancount.
 I can give a little demo of how to use bean-doctor to interactively
 compute the P/L of an isolated sequence of trades if anyone cares.

 The importer above groups the trades by underly

Re: Newbie: How to manage option trades?

2021-02-28 Thread Rahul Kuchhal
Just a quick update on what I ended up doing.

- I do not do any fancy options strategies, not even naked calls (only 
covered calls).
- After options expire or the positions get closed, I only need to keep a 
record the cash outflow and inflow. The options details are only in 
narration.
- So options accounts are needed only until options are held in account

I created a separate file for each account where I trade options to keep 
track of live options. This file has entries like this:

2021-01-25 open Assets:Vanguard:Brokerage:Options:CUK210820P0001 
CUK210820P0001
2021-02-02 open Assets:Vanguard:Brokerage:Options:CNK220121C0002 
CNK220121C0002

2021-01-25 * "Sold -300.0 Options CUK210820P0001"
Assets:Vanguard:Brokerage:Options:CUK210820P0001 -300.000 
CUK210820P0001 {0.8200 USD}
Assets:Vanguard:Brokerage:VMSXX -3000.00 USD
Assets:Vanguard:Brokerage:VMSXX:Reserved 3000.00 USD
Assets:Vanguard:Brokerage:VMSXX 245.99 USD
Expenses:US:BrokerageFees 0.01 USD
Income:Vanguard:Brokerage:PnL

2021-02-02 * "Bought 200.0 Options CNK220121C0002"
Assets:Vanguard:Brokerage:Options:CNK220121C0002 200.000 
CNK220121C0002 {5.5000 USD}
Assets:Vanguard:Brokerage:VMSXX -1100.00 USD
Income:Vanguard:Brokerage:PnL

When the positions get closed the entries change into this (the first 
option expired, the second one got sold) and move to the main file:

2021-01-25 * "Sold -300.0 Options CUK210820P0001"
Assets:Vanguard:Brokerage:VMSXX 245.99 USD
Expenses:US:BrokerageFees 0.01 USD
Income:Vanguard:Brokerage:PnL

2021-02-02 * "Bought 200.0 Options CNK220121C0002"
Assets:Vanguard:Brokerage:VMSXX -1100.00 USD
Income:Vanguard:Brokerage:PnL

2021-02-10 * "Sold 200.0 Options CNK220121C0002"
Assets:Vanguard:Brokerage:VMSXX 500.00 USD
Income:Vanguard:Brokerage:PnL

Automatic importers spit out the transactions broken down into two parts - 
open option trades that go into the secondary file, closed option trades 
that go into the main file.

This way the number of Options account is limited to the options that I 
currently have open positions in. 


On Sunday, February 14, 2021 at 10:45:55 AM UTC-5 Rahul Kuchhal wrote:

> Thank you!
>
> I see that adding new commodities is the recommended way then.
>
> Now on to finding Vanguard and Schwab importers or adopting your 
> Ameritrade importer for them.
>
> On Saturday, February 13, 2021 at 5:13:01 PM UTC-5 b...@bben.us wrote:
>
>> Good point about the price directive. I agree with your recommendation. 
>> Seems like the best way to handle it is to fix any reporting tooling that 
>> have problems with the flood of commodity symbols to aggregate or page 
>> their output.
>>
>> On Sat, Feb 13, 2021, 14:03 Martin Blais  wrote:
>>
>>> On Sat, Feb 13, 2021 at 1:34 PM Rahul Kuchhal  wrote:
>>>
 I am also trying to figure out the best way to represent Sold options 
 that open new positions.

 The suggested approach below works (kind of). 

 2020-12-28 * "Sell March 1 PUT 200 on HOOL"
Assets:Brokerage:Taxable:HOOL:Options   -1 HOOL_PUT_200_2021_03_01 
 {1000 USD}
Assets:Brokerage:Taxable:Cash 1000 USD

 Seems like I would need to add a new currency to HOOL:Options account 
 each time I open a new position. Overtime I suspect this may result in 
 hundreds (or even thousands) of currencies attached to a single account.

>>>
>>> That's what I do. My importer creates them automatically from the TOS 
>>> log.
>>> Here:
>>>
>>> https://github.com/blais/ameritrade/blob/master/examples/ameritrade2beancount.py
>>>
>>> I'm doing vertical and calendar spreads, collars, covered calls, and 
>>> more. It all works great with Beancount.
>>> I can give a little demo of how to use bean-doctor to interactively 
>>> compute the P/L of an isolated sequence of trades if anyone cares.
>>>
>>> The importer above groups the trades by underlying, and typically these 
>>> are positions being rolled, but not always. I may initiate multiple 
>>> separate trades with distinct history in the same underlying (either 
>>> closing and reopening, or over different months).
>>>
>>> One of the issues is that "regular" activity - stock purchases and 
>>> sales, or short positions, as well as longer-term hedging on LEAPs, all 
>>> happen in the same account. I consider these logically distinct from the 
>>> premium / vol trading I do, so I want to separate them out. Here's how I do 
>>> this: when I import, I keep the active options traffic segregated to an 
>>> include file, one per week. I manually move the long term activity to my 
>>> main Beancount file, where it will remain forever. All the transactions are 
>>> tagged with TD's unique transaction ids, and when the importer runs it 
>>> automatically ignores anything that's been imported before, here:
>>>
>>> https://github.com/blais/ameritrade/blob/master/examples/ameritrade2beancount.py#L912
>>>
>>> I have been keeping each week in a separate file,

Re: Multipliers

2021-02-28 Thread Martin Blais
It's not mark-to-market that's the issue. There are three issues right now:
1. Multipliers are needed to make data entry represent what's really going
on.
2. A booking method that can cross from net short to net long and
vice-versa isn't present.
3. Average cost booking is required.

1. Multipliers
When you trade options, I currently handle the multiplier by scaling up the
size, e.g. for 3 contracts short (300 shares):

2021-02-23 * "(TRD) SELL TRADE" #opening ^order-T1234567890 ^td-1234567890
  Assets:US:Ameritrade:Main:CovCalls -300 SPX_041621C4045 {23.8000 USD,
2021-02-23}
  Expenses:Financial:Commissions1.50 USD
  Expenses:Financial:Fees   1.98 USD
  Expenses:Financial:Fees   0.04 USD
  Assets:US:Ameritrade:Main:Cash 7136.48 USD

Ideally Beancount should have a notion of multiplier that knows that for
[A-Z]+_\d+[CP][\d.]+ the multiplier is 100, so you could just enter what
you actually do:

2021-02-23 * "(TRD) SELL TRADE" #opening ^order-T1234567890 ^td-1234567890
  Assets:US:Ameritrade:Main:CovCalls -3   SPX_041621C4045 {23.8000 USD,
2021-02-23}
  Expenses:Financial:Commissions1.50 USD
  Expenses:Financial:Fees   1.98 USD
  Expenses:Financial:Fees   0.04 USD
  Assets:US:Ameritrade:Main:Cash 7136.48 USD

But that's not too bad, because options are pretty universally 100 in size,
so when you see it in your file, you just know what it stands for.

For futures, the problem is worse, because each contract has a potentially
different multiplier, e.g.
https://www.cmegroup.com/trading/equity-index/us-index/e-mini-nasdaq-100.html
has a $20 x NASDAQ index value.

So I enter them like this:

2021-02-19 * "BOT +5 /NQH21:XCME @13597.75"
  Assets:US:Ameritrade:Futures:Contracts5 NQH21 {271955.00 USD}
  Assets:US:Ameritrade:Futures:Margin -1359775.00 USD
  Expenses:Financial:Commissions11.25 USD
  Expenses:Financial:Fees6.25 USD
  Assets:US:Ameritrade:Futures:Cash-17.50 USD

with the multiplier in the cost. The actual price of the index at the time
was 13597.75.
I'd much rather do this:

2021-02-19 * "BOT +5 /NQH21:XCME @13597.75"
  Assets:US:Ameritrade:Futures:Contracts5 NQH21 {13597.75 USD
USD}
  Assets:US:Ameritrade:Futures:Margin -1359775.00 USD
  Expenses:Financial:Commissions11.25 USD
  Expenses:Financial:Fees6.25 USD
  Assets:US:Ameritrade:Futures:Cash-17.50 USD

and have Beancount do the multiplication itself.
I mean I could have done 100 NQH21 = 20 x 5 but that feels so wrong.


2. I think in general the way that the profits are booked from your margin
to your cash account is via average cost.
If you want to be able to use the numbers pulled in from e.g. Ameritrade's
futures reporting in your importer, they're average cost.
When you enter a position, there's zero cash account effect. When you close
one, the average basis is used to add/remove to/from your futures account
cash balance.
(I'm not sure if this is customizable by broker. I suspect that it might be
subject to reg)
At the day it doesn't matter too much if you don't hold contracts overnight.


3. Imagine this sequence of trades starting from a flat position, e.g. you
buy one, then sell 2:

2021-02-19 * "BOT +1 /NQH21:XCME @13593.00"
  Assets:US:Ameritrade:Futures:Contracts   1 NQH21 {271860.00 USD}
  Assets:US:Ameritrade:Futures:Margin -271860.00 USD
  Expenses:Financial:Commissions2.25 USD
  Expenses:Financial:Fees   1.25 USD
  Assets:US:Ameritrade:Futures:Cash-3.50 USD

2021-02-19 * "SOLD -2 /NQH21:XCME @13590.75"
  Assets:US:Ameritrade:Futures:Contracts -2 NQH21 {271815.00 USD}
  Assets:US:Ameritrade:Futures:Margin 543630.00 USD
  Income:US:Ameritrade:Futures:PnL45.00 USD
  Expenses:Financial:Commissions   4.50 USD
  Expenses:Financial:Fees  2.50 USD
  Assets:US:Ameritrade:Futures:Cash  -52.00 USD

This is a pretty common occurrence when scalping.
Futures are really one for their "one click action" like that.
The problem is that the second trade really should have been recorded as:

2021-02-19 * "SOLD -2 /NQH21:XCME @13590.75"
  Assets:US:Ameritrade:Futures:Contracts -1 NQH21 {} @ 271815.00 USD
  Assets:US:Ameritrade:Futures:Contracts -1 NQH21 {271815.00 USD}
  Assets:US:Ameritrade:Futures:Margin 543630.00 USD
  Income:US:Ameritrade:Futures:PnL45.00 USD
  Expenses:Financial:Commissions   4.50 USD
  Expenses:Financial:Fees  2.50 USD
  Assets:US:Ameritrade:Futures:Cash  -52.00 USD

This has to be resolved somehow. In v3 we should try to build something to
handle that gracefully and automatically.
I mean this does raise an important question: Should there really be a
different syntax for augmentations and reductions?
Right now, what you input h

Re: Loss reported as profit

2021-02-28 Thread Andreas Gerstmayr

Hi Tono,

the change was merged in master yesterday. You can install the latest 
development version of fava with:


pip3 install git+https://github.com/beancount/fava.git

or you wait until a new fava version is released.


Cheers,
Andreas


Am 26.02.21 um 14:56 schrieb Tono Riesco:

Hi Andreas,

Thank you very much for your patch. I’ve been looking for that for a 
long time.
Could please be so kind to explain how to apply to the present fava 
package (1.18)? If I try "pip3 install —upgrade fava" doesn’t work 
because hasn’t been commit to the main version ...



Best regards.

Tono.

On 26 Feb 2021, 13:47 +0100, Andreas Gerstmayr , 
wrote:

I also didn't like seeing my net profit as negative (even though it's
positive), so I added an option to fava to flip the sign of the Income,
Liabilities and Equity accounts: 
https://github.com/beancount/fava/pull/1214


Keep in mind though that it will only flip the signs in the user
interface though, and won't change anything with the internal beancount
accounting.


Cheers,
Andreas


Am 02.02.21 um 14:26 schrieb Martin Blais:

One important design decision in beancount (an idea borrowed from Ledger
originally) is to do away with credit accounts and debit accounts.
Income, liabilities and equity accounts all normally have negative
signs, so that is correct. (It's a bit like programmers counting from
zero and not one).

See the a section in the documentation about this.


On Tue, Feb 2, 2021, 08:10 Andrew Chiw mailto:randomshinichi4...@gmail.com>> wrote:

I followed the Beancount getting started guide, and made
transactions from my bank account to my different categories like this:

2019-01-24 * "Employer" "Invoice 23"
  Income:DE:Salary
  Assets:Bank  2000 EUR

2019-01-02 * "Stromio GmbH" "ABSCHLAG Strom"
  Assets:Bank  -87.0 EUR
  Expenses:Core:Electricity

However, if I saved money from my income, fava reports a negative
"net profit", and if I used more than I got, fava says I have a
positive "net profit". Am I doing things wrong somehow?
Thanks,
Andrew

--
You received this message because you are subscribed to the Google
Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to beancount+unsubscr...@googlegroups.com
.
To view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/b5c42a27-fe2a-49e5-82d0-f127303e47dbn%40googlegroups.com
.

--
You received this message because you are subscribed to the Google
Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to beancount+unsubscr...@googlegroups.com
.
To view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/CAK21%2BhP%2BVLF3%2Bmys39JHM3RdS9%2B%2BWnxW3QQ9-A7NusMKfkqKkw%40mail.gmail.com
.


--
You received this message because you are subscribed to the Google 
Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/08330cbb-26fc-bf7d-6796-5963b07d644e%40gerstmayr.me.


--
You received this message because you are subscribed to the Google 
Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to beancount+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/7fb0083e-53cc-4790-869c-003a4a714e6d%40Spark 
.


--
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/b7ab4a7c-16d6-ac2c-6665-3ad94b0f8176%40gerstmayr.me.


Re: Multipliers

2021-02-28 Thread Ben Blount
I'm curious to hear a bit more about what gets ugly with modeling futures
in the present system. Resolving mark to market seems like a challenge.

On Sun, Feb 28, 2021, 08:02 Martin Blais  wrote:

> FYI.
> I added a section on multipliers in the v3 goals:
>
> https://docs.google.com/document/d/1qPdNXaz5zuDQ8M9uoZFyyFis7hA0G55BEfhWhrVBsfc/edit#heading=h.b30u633jlv5x
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to beancount+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/CAK21%2BhPsRZ2mcxBdkd6Ew2OVzZir-hLH45mc7%2BvPUS1QWDMwMw%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CACGEkZvAZf78coQ77XDpegNLHxYbVGQAStC8-KLhRY8%3DN8pzdg%40mail.gmail.com.


Multipliers

2021-02-28 Thread Martin Blais
FYI.
I added a section on multipliers in the v3 goals:
https://docs.google.com/document/d/1qPdNXaz5zuDQ8M9uoZFyyFis7hA0G55BEfhWhrVBsfc/edit#heading=h.b30u633jlv5x

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhPsRZ2mcxBdkd6Ew2OVzZir-hLH45mc7%2BvPUS1QWDMwMw%40mail.gmail.com.


Re: Frustration

2021-02-28 Thread redst...@gmail.com


> My total time to update is now less than 5 minutes.
>
> Wow!  That is truly inspiring.  I am looking forward to your forthcoming 
> blog post(s) on all of this.  Do you have anything already published I 
> could flip through?
>

I'll try to share at least an outline in the next couple weeks.

14 of these don't have a scriptable ofx API (aka ofx/qfx via quicken 
> directconnect)
>
> Are you using quicken to access the APIs that area available?
>

Not Quicken, but the API that Quicken uses, via 
https://ofxtools.readthedocs.io/en/latest/
 

> I use something similar to supertab 
> , 
>
> I tried getting supertab to work and did not succeed.  I’m currently 
> trying to get something going with neovim embedded in VSCode; but the 
> folding in VSCode leaves a lot to be desired.
>

My bad: turns out I use this single, simple line in my .virmc (in addition 
to the vim-beancount plugin):
*autocmd FileType beancount inoremap   *

More later.

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/0c70d46e-94e1-4467-8bdc-6f32acf1d383n%40googlegroups.com.