
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Crude Oil Inventories (Forex Factory)
and the oil price
Crude Oil Inventories
Crude Oil Inventories
and
Crude Oil COT report
COT Crude Oil
A.) SVM input example
Train examples: i=1..100
Class: C[0+i]-O[6+i]
Attribute1: C[1+i]-O[6+i]
Attribute2: C[2+i]-O[6+i]
Attribute3: C[3+i]-O[6+i]
Attribute4: C[4+i]-O[6+i]
Attribute5: C[5+i]-O[6+i]
Test examples: i=0
Class: C[0+i]-O[6+i]
Attribute1: C[1+i]-O[6+i]
Attribute2: C[2+i]-O[6+i]
Attribute3: C[3+i]-O[6+i]
Attribute4: C[4+i]-O[6+i]
Attribute5: C[5+i]-O[6+i]
B.) SVM input example
Train examples: i=1..100
Class: C[0+i]-O[0+i]
Attribute1: C[1+i]-O[0+i]
Attribute2: C[2+i]-O[0+i]
Attribute3: C[3+i]-O[0+i]
Attribute4: C[4+i]-O[0+i]
Attribute5: C[5+i]-O[0+i]
Test examples: i=0
Class: C[0+i]-O[0+i]
Attribute1: C[1+i]-O[0+i]
Attribute2: C[2+i]-O[0+i]
Attribute3: C[3+i]-O[0+i]
Attribute4: C[4+i]-O[0+i]
Attribute5: C[5+i]-O[0+i]
Offset=6
B.) SVM input example
Train examples: i=1..100
Class: C[0+i]-O[0+i]
Attribute1: C[1+i]-O[0+i]
Attribute2: C[2+i]-O[0+i]
Attribute3: C[3+i]-O[0+i]
Attribute4: C[4+i]-O[0+i]
Attribute5: C[5+i]-O[0+i]
Test examples: i=0
Class: C[0+i]-O[0+i]
Attribute1: C[1+i]-O[0+i]
Attribute2: C[2+i]-O[0+i]
Attribute3: C[3+i]-O[0+i]
Attribute4: C[4+i]-O[0+i]
Attribute5: C[5+i]-O[0+i]
Simple Trading System
Source Checkout - wtx - Google Code
class Strategy:
def __init__(self, deposit=400000, price_per_point=200, commission=500):
self.bars = None
self.current_index = -1
self.points_balance = 0
self.entry_price = 0
self.current_contracts = 0
self.price_per_point = price_per_point
self.commission = commission
self.initial_deposit = deposit
self.balance = deposit
self.win = 0
self.lose = 0
def Buy(self, price):
self.ExitShort(price)
self.entry_price = price
self.current_contracts = 1
#print "Buy @%d"%(price)
def Sell(self, price):
self.ExitLong(price)
self.entry_price = price
self.current_contracts = -1
#print "Sell @%d"%(price)
def ExitLong(self, price):
if self.current_contracts > 0:
points_balance = (price - self.entry_price)*self.current_contracts
if points_balance>=0:
self.win += 1
else:
self.lose += 1
print "ExitLong: %d points (%d -> %d)"%(points_balance, self.entry_price, price)
self.points_balance += points_balance
self.balance += points_balance * self.price_per_point - self.commission
self.current_contracts = 0
def ExitShort(self, price):
if self.current_contracts < 0:
points_balance = (price - self.entry_price)*self.current_contracts
if points_balance<=0:
self.win += 1
else:
self.lose += 1
print "ExitShort: %d points (%d -> %d)"%(points_balance, self.entry_price, price)
self.points_balance += points_balance
self.balance += points_balance * self.price_per_point - self.commission
self.current_contracts = 0
def ShowResults(self):
self.ExitLong(self.Close(0))
self.ExitShort(self.Close(0))
transaction = self.lose+self.win
print "--------------- Performance Report ------------------"
print "%d Transaction, Win=%d (%.1f%%), Lose=%d(%.1f%%)"%(\
transaction, self.win, self.win*100/transaction, self.lose, self.lose*100/transaction)
print "Initial deposit=%d"%(self.initial_deposit)
print "points_balance is %d points, equals to %d (NTD)"%\
(self.points_balance, self.points_balance*self.price_per_point)
print "commission is %d"%(self.balance-self.initial_deposit-self.points_balance*self.price_per_point)
print "Final balance is %d"%(self.balance)
print "Actual earning is %d"%(self.balance-self.initial_deposit)
print "--------------- Performance Report ------------------"
def CrossOver(self, a, b):
#prev a current b
print "[%s] Close=%d, Fast[-1](%d)=Slow(%d) ? %d"%(self.bars[self.current_index].time, \
self.bars[self.current_index].close, a(1),b(1),a(0),b(0), a(1)=b(0))
return a(1)=b(0)
def Close(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].close
def Open(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].open
def High(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].high
def Low(self, offset=0):
if self.current_index < offset:
return 0
else:
return self.bars[self.current_index - offset].low
def Sum(self, f, count, offset=0):
sum = 0
if self.current_index < offset:
return sum
elif self.current_index < offset + count:
count = self.current_index-offset
for e in map(f, range(offset, count+offset)):
#print "sum(%d) += %d"%(sum, e)
sum += e
#print "[%d] Sum(count=%d, offset=%d)=%d"%(self.current_index, count, offset, sum)
return sum
def Average(self, f, count, offset=0):
avg = 0
if self.current_index < offset:
return 0
elif self.current_index < offset + count:
count = self.current_index-offset
if count == 0:
return 0
avg = self.Sum(f, count, offset)/count
#print "[%d] Average(count=%d, offset=%d)=%d"%(self.current_index, count, offset, avg)
return avg
def Run(self, Open, High, Low, Close):
pass
def RunWithBars(self, bars):
self.bars = bars
self.count = len(bars)
for i in range(0, self.count):
self.current_index = i
#print "[%d][%s] %d %d %d %d"%(i, self.bars.time, self.bars.open, \
#self.bars.high, self.bars.low, self.bars.close)
self.Run(lambda x: self.Open(x), \
lambda x: self.High(x), \
lambda x: self.Low(x), \
lambda x: self.Close(x))
self.ShowResults()
An attempt to beat the market by generating trading strategies using genetic programming
pipster - Google Code
Capital Management
On the management of capital
"about the final result" - TWR(Terminal Wealth Relative).
For example, if the income was 12%, theTWR = 1.12.
Or, if the loss was 18%, theTWR = 0.82.
The probability of winning will be indicated byp.
The probability of a loss q = 1 - p
The total number of transactions -N, the number of winning deals -V, and Losing -L.
The size of the winning deals in absolute terms will be indicated by the symbola, Losing transactions - b, while the amount of gain to loss - a k = a / b.
If it will be the size of the winning \ Losing transactions in shares on the equity, the symbol will be, respectively, a%, b%. The ratio of a% b% will bek. I note that the margin rate on capital will be denoted asf.
The probability of events that we will receive on time payments, will be referred to as Prob.
p = 0.45,q= 0.55,a% = 0.08, b%= 0.05, N = 20, the results will be - MO = 0.0085, TWR = 1.170.
TWR =N * MO + 1
we introduce two additional formulas:
for the calculation of income at a known number of winning bids (3)
and calculate the probability of occurrence in the series a certain number of winning bids (4):
The results of our calculations according to formulas (3) and (4) are represented by green dots.
For example, the probability of occurrence of a series of transactions whose TWR = 1.04, is 0.162.
Maximum winnings TWR = 2.60, - Prob = 1.2E-07.
Blue dots indicate the same data, but in the form of cumulative probability.
Capital, which is involved in trade, is called aDeposit. We have the right, using the leverage Leverage, buy and sell contract size LotSize. The contract may be fractional, so we need the notion of Lots, a characteristic that points to the ways in which the size of contracts we operate. Accordingly, the actual size of the lot operated in the base currency will call LotPrice. For the right to buy or sell, we must make a Margin. If you express the Margin as a percentage of the Deposit, we'll get the option Margin%. Together with these we will use the notion of StopOut, which indicates a minimum of Margin, the achievement of which leads to the closing of this transaction, and forced the completion of trade. Thus, there are two different situations where continued trading impossible (with the desired amount of LotPrice), ie a situation of collapse. Additionally, was introduced another parameter, which is conventionally called Sigma. In essence, this is - the ratio used in commercial transactions with a view to a loan size of their own funds. The ratio of the operated facilities for the actual capital, ie analogue of leverage, just assigned to the entire Deposit, and not toLotPrice.
One of the basic concepts relating to the trade, it is Quote - current exchange rate. Minimal change of course is called Tick. The size of the minimum exchange tool - TickPrice, seen as part of Deposit - Tick%.
In addition, we have a few more parameters associated with the change of course: the so-called TP (TakeProfit) and SL (StopLoss) - change of course in which fixation occurs profit or loss. If you express these parameters in the currency, then we will call them TPprice and SLprice. And, accordingly, expressed as part of Deposit, and is called a TP% SL%. Also there are different kinds of dealer commissions, such as Spread, Swap, etc. We will not address all the diversity of these options, stop only at the Spread, which is traditionally expressed in paragraphs change course. Data Swap, if it is expressed in points, it is very easy to accommodate, if necessary. If the Swap is presented as a real bank interest in the use of leverage through borrowings, the situation is more complicated.
Let's try to compare the parameters obtained by us with those we used in the problem of "absorbing wall". It is clear thatSL% corresponds tob%. Like, TP% =a%. The initial capital we have been presented as TWR = 1. In this case, the same as our calculations are based on parameters, expressed in fractions of units. Used boundary value z% + b% can be considered Margin%. Between the two there is some difference, but it is not a principle, if you do not take into account the existence of StopOut. In general, it turned out that the challenges are similar to the first approximation. Later we check this assertion.
A careful look at the formula (9, 11, 13, 15), then all of a parameter Sigma. As already mentioned, this is the analogue of leverage, and it is used in all the important formulas. Directly from Leverage depends only Margin%.
The correctness of the calculations can be verified in the following example. We know that when Leverage = 100, LotSize = 100000, Lots = 0.1, Deposit = 10000 size of the collateral is 100. If we look at a timetable (brown), we find that the Margin% = 0.01, in the Deposit = 10000 it is 100.