Simulate a trade of foreign currencies

Impelled by a sudden thought, I simulated a trade of foreign currencies.


First, I got data of the rate as CSV from ADVFN(http://jp.advfn.com/p.php?pid=forexhistdata&cb=1189437510%E3%80%80%E3%81%84%E3%82%8D%E3%81%84%E3%82%8D%E9%81%8A%E3%81%B9%E3%81%9D%E3%81%86%E3%80%82).
Then, I wrote a simple simulation program with Ruby.


Paramaters and rules I adopted are below.

  • Parameters

Data: Daily log of South African Land Doller / Yen from 2006 to 2007
Period: From January 2th of 2006 to today
InitialMoney: 100000 Yen
Spread: 0.05 Yen
Charge: Free
Leverage: not use
Swap: Out of consideration
Los cut rate: 2%
Fix gain rate: 5%
Period of moving average: 2days
Buying frequency: One time a day(not always buy or sell)



  • Trade rule

Fundamentally, the simulation program buys(or sells) Dollers up to the limit of having money.
Then it sells(or buys) all of these at "proper timing" and buys up to the limit of having money in the same way.
"proper timing" is that gain is more than fix gain rate or less than los cut rate.


Simulation desides whether buying or selling from a forecast based on a moving average I customized.

  • A part of the forecasts

exchange_forecast
exchange_forecast posted by (C)Ryo

little queer... :-(
But, it's ok because I need only whether up or down here.
#Do not need how much rate changes

  • Chart of exchange rate and money changes

south_african_doller_yen_log
south_african_doller_yen_log posted by (C)Ryo
""Some part is out of alignment""

  • Result

Win rate: 53.5% (this include times that gain is zero)
Money finally have: 116724.34 Yen (116.72%)
Trade times: 534 times

  • Conclusion

Above is a good result and other bad results exist.
I think that auto buying algorithm is not easy :-(
But, it is not impossible to some extent with improving a forecast algorithm :-)

Bonus

  • Bad Result(US Doller / Yen from 2006 to 2007)

Win rate: 47.3% (this include times that gain is zero)
Money finally have: 79011.855 Yen (79.01%)
Trade times: 557 times