As others have already said, this is way underspecified. But I think the following is at least a fairly decent answer for most plausible ways of filling in the details:
Let's suppose you are aiming for wealth in the longish term (clearly you aren't much interested in the short term or else you would be spending some of this money) and let's suppose your utility is proportional to log(wealth), which is (1) empirically at least semi-plausible, (2) quite nice mathematically, and (3) traditional (it goes all the way back to Bernoulli's treatment of the St Petersburg paradox).
Then every day you get to choose to multiply your wealth by either about 1 (if you put your assets in cash) or some random factor with known pdf (if you put your assets in the stock). In other words, you get to add to log(wealth) either about 0 or some random addend with known pdf.
If those random things are reasonably well behaved, then with very high probability after a while your log(wealth) is approximately log(original wealth) + the sum of E(delta log wealth). Which suggests that, ignoring horizon effects when you know the game will be ending soon, you always want to choose the outcome that maximizes the expectation of delta log wealth.
(Of course you should include the effects of the transaction fee in this. Since we have neglected the impact of future transaction fees, it might be a good idea to compensate by adding a little extra "friction" and, say, pretending that the transaction fee is $3 instead of $2 when doing the calculation.)
Worked example #1: Consider Lumifer's example where every day the stock either goes up by 2.01x or goes all the way down to zero. The expectation of delta log wealth, ignoring transaction costs, is 1/2(log 2.01 + log 0) = -infinity, so unless your current wealth is barely more than the transaction cost and you're already invested in the stock you want to be in cash. (So you will never invest in the stock, so you will never get into the crazy situations where the transaction cost might change your decision.)
Worked example #2: suppose on the first day when you have $1000 you know that the stock will either go to 0.9 or 1.2 of its previous value, each with probability 1/2. And suppose what you currently have is cash. Then your options are to stay in cash, with E(delta log wealth) = 0 because this is a no-op, or to buy shares, with E(delta log wealth) = 1/2[log(1198/1000)+log(898/1000)] ~= 1/2(0.181-0.108), which is positive. So in this case you should get into the market.
Worked example #3: same as #2 but now you only have $32. So now if you buy you have $30 in stock and it will move to $27 or $36 with equal probability. So the expectation is 1/2[log(27/32)+log(36/32)] which you can easily check is negative; so in this case you sit on the cash and hope for a better PDF next time.
Would this system ever invest in stock when the probability of losing all the money is non-zero?
Let's suppose you start with $1000 to invest, and the only thing you can invest it in is stock ABC. You are only permitted to occupy two states:
* All assets in cash
* All assets in stock ABC
You incur a $2 transaction fee every time you buy or sell.
Kind of annoying limitations to operate under. But you have a powerful advantage as well. You have a perfect crystal ball that each day gives you the [probability density function](http://en.wikipedia.org/wiki/Probability_density_function) of ABC's closing price for the following day (but no further ahead in time).
What would be an optimal decision rule for when to buy and sell?