- 사각형
- 포지션 균형 전략
포지션 균형 전략
저자:
춘조, 날짜: 2017-09-06 21:28:03
태그:
균형
function main() {
while (true) {
Sleep(300000);
var account = $.GetAccount();
var ticker = exchange.GetTicker();
var stockValue = account.Stocks * ticker.Last;
var totalValue = stockValue + account.Balance;
var position = stockValue / totalValue;
var trade_amount = 0;
if ( position > TARGET_POSITION + ACT_DIFF ) {
trade_amount = (position - TARGET_POSITION) * totalValue / ticker.Buy;
$.Sell(trade_amount);
} else if ( position < TARGET_POSITION - ACT_DIFF ) {
trade_amount = (TARGET_POSITION - position) * totalValue / ticker.Sell;
$.Buy(trade_amount);
} else {
Sleep(60000);
continue;
}
$.CancelPendingOrders();
account = $.GetAccount();
stockValue = account.Stocks * ticker.Last;
LogProfit(account.Balance + stockValue);
}
}
관련
더 많은