Technology is not only used for work, but also for life. ——- Wojcke Thod

preface

Last year, I began to fund investment.

Yeah, I got a couple of brass crackheads in my pocket saying, “Go for it, bike for bike.”

As a result, when the epidemic hit at the beginning of this year, the global stock market plunged. In the panic, I sold Mackey crazily at a low price, and the copper collapse in my trouser pocket became even more lonely.

A few months later…

Oh, my gosh! The outbreak in the United States is so explosive that the fucking stock market can go back up? It’s not scientific!

Those days, I feel like this:

Later, when I thought about it carefully, I realized that there must be ups and downs in investment, which are all floating losses. As long as I don’t give up, I will never lose. The most important thing is rationality, having my own investment decision tree and not being moved by external things.

Rising market me: ok, I get it, be rational. Drop market of I: you know fart!!

That’s easier said than done, since investment deals are anti-human. It is not easy to stick to your investment strategy. However, investing is a game of numbers. Buy low and sell high.

As it happens, as a programmer, you’re never unfamiliar with data.

So the whole fund back test site, simulated investment strategy income should not be difficult?

If I accidentally discover the “wealth code”, it will not be long before MY wealth increases exponentially, I will become rich overnight, complete a small goal, marry a rich woman, and walk on the peak of life. It is a little exciting to think.

Technical solution

So, to develop a fund back test site, need a few steps?

  1. Technology selection
  2. Get data source
  3. Code development
  4. The deployment of online

Technology selection

Want to make a website, even a lot of data chart, because often use pay treasure investment fund, that use ant home thing ANTD + G2 data visualization directly, fix!

The data source

This is a difficulty that stumbles everyone. Generally, the following schemes come to mind:

  1. Open source API? These data source apis are mostly charged, but occasionally free and limited for a limited time.
  2. Data from the fund’s website? That’s one way to do it, but you have to have a server to crawl the data in real time, and you have to write a crawler, and you probably have to compete with anti-crawler strategies.

So what’s my solution? White fuck!

I happened to find that a fund website uses JSONP to deal with cross-domain problems, and uses JS script + cache to store a large amount of fund history data, without limiting the referrer intentionally or unintentionally. This easily solves the data source problem (note that websites cannot use HTTPS, otherwise the data request will be blocked by the same origin policy).

It smells so sweet

Code development

The core of the business code is to record daily snapshots of funds and assets, including but not limited to: fund net value, relative increase, fund assets, available funds, positions, yield and other information.

Then the front end chart library G2 renders all the data in the time interval.

The deployment of online

Data all white whoring, we this is a static front-end site. GitHub Pages is not a server.

Add a few more details,

Our fund will be back on the beta site,Here is the access address [currently only PC access is supported]

Here is the github open source repository


Instructions and mumbling

Recently the topic of fund investment is more and more, especially the fund investment, but also found that there are suddenly many want to cut leek marketing number, the ability to distinguish almost is easy to be taken to the pit, I want to say:

Stop with the bells and whistles. You want to know if you’re sure? Can you make money? What’s the yield? Empty goods, direct simulation of the historical data of the cast strategy, back to test it is not ok?

China Merchants liquor investment three years income

Above is the simulation merchants China liquor classification index fund investment three years of earnings, how long, how much, the loss of the time to withdraw how much, how much yield, at a glance.

If someone questions you, just throw it in their face.

PS: Explain the possible objections in advance

  1. The rate of return algorithm refers to alipay fund andEvery day fund net calculatorAnd the data are basically consistent within the error range.
  2. The rate of return below refers to the cumulative rate of return, not the internal rate of return, and does not take into account the time occupancy cost of capital. 3. Past rate of return is not equal to the future rate of return, past known, future unpredictable, only for reference. 4. The fund examples are not intended as investment advice. Investment needs to be cautious.

Fake fund investment?

Nearly a year old heard recommended financial management, especially recommended investment index funds. What stock god Buffett strongly recommended, smile cast, easily annual rate of return of 15%, blowing fancy.

But most people just talk about the principle of fixed investment, and few can actually provide data to prove how much a fixed investment index fund can give you.

So as a programmer, and data to deal with more, so used to talk with data, so wrote a program to simulate the historical time of the return rate can reach how much?

First of all, the basic operation is:

  1. Patience, long enough to pitch

  2. Smiley face exponential curve

So, we chose the past three years as our historical test data, and the past three years have just passed a mini-bear market and a mini-bull market, which fits the smile and is long enough.

Real fund investment returns

We opened the index fund rankings for the past 3 years [2017/01/29 ~ 2020/01/29].

First, China Merchants Liquor index classification [161725], the cumulative yield of the past three years up to 135%, enough cattle force, this index fund.

So we go back to the past, to this fund for 3 years to see the effect:

[2017/01/29 ~ 2020/01/29] Decided to invest in China Securities Liquor

The three-year cumulative return rate of fixed investment is 44.19%, and the annualized return rate is 12.97%

Looks pretty good close to 15% is it, but know that this is the index fund yield ranking of the first, fixed investment can not reach 15%.

So let’s look at the broad base index recommended by many people, such as SSE 50, CSI 300 and so on.

According to the ranking, the broad-based index performs best in Yifonda Sse 50 Index [110003].

Oh huo, the average annual return is 8%, let alone 15%, 10% is less than oh.

Does that mean that the return rate of the broad index is not as good as P2P?

Not so. If accumulative total decides to cast index fund 10W and investment P2P accumulative total 10W, although final income is 1W same, but the capital of both takes up time cost is different. P2P is 10W occupied for one year, fixed investment is 1W occupied for one year, 1W occupied for 11 months,…… One million yuan, which was ordered last month, has only been occupied for a month. Income is almost fixed investment fund is obviously better than P2P.

The characteristics of the fund with high returns

So, is there no fixed investment can achieve 15% of the rate of return?

You can’t say the same. This time, we’re opening up the leaderboard. Select First Place, Galaxy Innovation Growth Mix [519674]

[2017/01/29 ~ 2020/01/29] Investment Galaxy Innovation and growth mix

It’s awesome, with an annualized return of 24%.

Yes, it is high, but if you look at the fund curve, this fund was flat a year ago, but in the last year, it has skyrocketed.

That is to say, this fund is not optimistic when, began to cast, in the low price accumulated a lot of chips, and then in the last year thick and thin hair, just had so high cast yield.

There is undoubtedly a paradox.

If I have this actual strength, have this vision, can see at present low valuation the fund that cow forces in the future, that does not need to decide to cast completely, choose directly when building storehouse in batches to go.

Fixed investment index fund, itself is the lack of a profound understanding of the market, can only be allocated through the Buddha fixed investment risk, to let people judge the future trend of a fund, it is too difficult.

In other words, given the mediocre performance of Galaxy innovation and Growth Mix three years ago, do you dare to stick with it for another three years?

Bottom line: Anyone who brags about easy 15% annualized returns from fixed-investment index funds is either a douchebag or a bad one. It’s not easy to invest in index funds, even on 10% annualized returns.

New understanding of fund financing

So is it wrong to cast?

No, it just means that casting isn’t as good as you think it is.

It’s a call or a call.

The fundamental reason is that I don’t have so much money at present, so I have to invest part of my salary every month.

If we had millions of dollars to invest in a fund, we would have invested in something, bought the dips and built up our positions.

The soul of fund finance

Then we should also have the knowledge of casting, not blind a few casting, everyone actually began to prepare for casting, there will be a lot of questions:

  1. Monthly or weekly? 2. How much do YOU invest each time? How much will the salary be invested? 3. How long is the subscription? 4. What fund will you invest in? 5. Stop earnings? When will the surplus stop? 6. Do you want to manually cover positions? When do you cover your positions? 7. What is the expected return rate?

At first, I didn’t have a clear answer to these questions

So I wrote a web program to analyze the effect of certain investments under different strategies on the final yield.

To be cast surely strategy

It is basic operation above all, choose fund, and choose to cast time:

  • Fund name/No
  • Time range

Then, make the choice of investment strategy:

  • Initial principal: How much liquidity to start with
  • Monthly salary: Incremental working capital per month *
  • Initial hold fund: whether to have held certain fund (some people are to build storehouse first, decide to cast again)
  • The amount of each investment
  • Subscription cycle: the day of the month, or the day of the week

Cast strategy option

Through these parameters, we can get the various curves of fund investment within the interval of time:

Check surplus strategy

Those who know how to buy are apprentices; those who know how to sell are masters.

A lot of people fund cast the biggest problem is: when check surplus? How much stop?

A lot of bigwigs are giving mature opinions,

  • If the holding income reaches a certain percentage,
  • Shanghai index reached how many points on the surplus
  • Positions to reach how many layers stop surplus

That all makes sense. The question is which strategy is the best?

We can parameterize these strategies, choose different stop-profit strategies, and the returns under different strategies:

Check surplus strategy

Margin strategy

In addition to monotony, want to increase yield, then should buy dips, cover positions as needed.

The question is when? Big drop to cover positions? Cheap cover? Here is a simple list of macD position covering strategies, other strategies I haven’t written yet, lazy. Let’s see if someone else sees it.

Strategy is

Comprehensive stop-profit and cover strategy, many people summed up the MACD gold fork dead fork trading method, grid trading method and so on investment strategy, but few can accurately say how much higher than the normal earnings data.

Therefore, I also implemented the function of income data comparison of multiple strategies.

What can we compare? Comparison chart of investment effect curves of different funds under different strategies.

What kind of curves can we look at? Currently, the following data are tentatively available:

Fund strategy comparison options

By comparing the investment strategy, you can quickly draw the profit and loss, position, yield and other data graphs of this investment strategy. So as to find a more suitable investment strategy.

For example, investment investment certificate liquor for 3 years, what is the difference between stop profit and more than profit? Look at the data:

Cumulative return = Total return/Total investment (stop-profit vs. stop-profit)

Obviously, the stop-profit strategy is 3.4% higher than the stop-profit strategy

Not high, do you think there is no difference between stop surplus and stop surplus?

Wrong!

Let’s take a look at the position comparison during the booking period:

Holdings = fund assets/current total assets

A stop-profit strategy is about 15% lower than a stop-profit position. Investing to control your position is basic investment literacy.

Accumulative total profit and loss

Is a high position bad? No, it depends on your risk tolerance. Although the cumulative return rate is higher than the stop-earnings ratio, the cumulative return is actually higher than the “stop-earnings strategy”.

This is because of high positions, high risks and high returns, the overall liquor is rising in the past three years. If change a whole down fund, that high position yield collapse. Interested can measure relevant fund next by oneself on the website, here is no longer redundant.


The simulation of the above investment strategy from my personal depend on the interest in writing web pages: sunshowerc. Making. IO /, /, support only PC, not compatible with the mobile terminal access, lazy.

More complete stop-profit strategy and cover strategy may be updated later

Github open Source: github.com/SunshowerC/…

Buddha is a star

.

.

  • “Wait, you stop!”

  • “What about the wealth code? What about the headline wealth code? Give me the password!”

  • “Oh? Oh, yeah, want to get rich with money? A little rich? A quick rich? Go to sleep. You have everything in your dreams. The primitive accumulation of capital, you know? The principal is too little, the rate of return is no use, or honestly go back to move bricks!”



If articles are helpful to you, your star is my biggest support for other articles:

  • Json you don’t know the browser, Module, and main fields priority
  • You can play it this way? Super useful Typescript built-in and custom types
  • Not shocked, you can also look at the front of the Flutter advice guide