Darts shooting program in python.
There is a story talking about making choices in
stock market. There three groups to choose the targets in stock markets. Each
of them used their own method.
Team A: They used fundamental analysis.
Team B: They used technical
analysis.
Team C: They just let a monkey shoot darts,
and choose the targets which was shooted.
In the end, the team C’s benefit higher
than team A and B.
O.K., this is joke. I don’t believe this
will happened in real world. But this story gave me some inspiration. What if
we choose a method which can give me a random number, and I choose targets by
these numbers. Just like shooting darts.
In this case, I want to use a random
generator to print out targets. My requirements are: Quickly, precisely,
automatically calculate, automatically send a report to me. Then, I found the
computer can do it for me. The only question is what I want to use, there are a
dozen methods to finish the job. Like Excel, PHP, Python, Java. Finally, I
choose python, because it is easy to load a csv file and calculate quickly.
The code is here, it’s free to download.
The program is going the actions below:
1 > Choose 5 targets from the source
file.
2 > Save the result in a text file.
3 > Calculate yesterday’s results.
4 > Calculation way is simple, find
yesterday’s targets, pretend I put 1 million jpy to buy it. The end price of today
minus the start price of today is the revenue.
5 > Save revenue to another text file.
Below is the result picture.
2016-06-15 darts |
darts:
8789-T, 東証マザーズ, フィンテック グローバル, その他金融業, 140, 142, 139, 140, 923900, 129426400
1491-T, 東証2部, 中外鉱業, 非鉄金属, 29, 34, 28, 32, 6265900, 196434600
7150-T, 東証1部, 島根銀行, 銀行業, 1593, 1604, 1593, 1596, 1600, 2554400
9468-T, 東証1部, KADOKAWA・DWANGO, 情報・通信業, 1670, 1670, 1651, 1658, 352900, 585462700
6753-T, 東証1部, シャープ, 電気機器, 171, 172, 170, 170, 8335000, 1423073000
Accumulate revenue and duration time |
Detail every day. |
date:2015-06-15
today_revenue:4462
accumulate_revenue:4462
duration:1
['9882-T', 'イエローハット', 426]
['3810-T', 'サイバーステップ', 22875]
['6247-T', '日阪製作所', -25751]
['8345-T', '岩手銀行', -8665]
['8050-T', 'セイコーホールディングス', 15576]
date:2015-06-16
today_revenue:92297
accumulate_revenue:96759
duration:2
['8789-T', 'フィンテック グローバル', 0]
['1491-T', '中外鉱業', 103448]
['7150-T', '島根銀行', 1883]
['9468-T', 'KADOKAWA・DWANGO', -7185]
['6753-T', 'シャープ', -5847]
沒有留言:
張貼留言