本帖最后由 xinxing 于 2019-3-23 01:24 PM 编辑
xinxing 发表于 2019-3-22 08:22 AM
最简单的规则就是: buy at oversold and sell at overbought. 这个规则能盈利吗?我不知道答案。
有盈利的 ...
任何一笔交易(Transaction)都应该有一条对应的记录。所以,先定义一下这个结构:
// A Transaction is about when at what price buy/sell how many number of shares.
struct Transaction {
Transaction(ulong _time = 0, double _price = 0, int act = 0, int accumulation = 0)
: time(_time)
, price(_price)
, shares(act)
, holding(accumulation)
{}
ulong time; // date and time
double price; // market price
int shares; // number of share(s) of this transaction. +: buy, -: sell
int holding; // number of holding share(s) after this transaction
};
利用这个结构,定义一个数组,把所有交易都记录下来。
|