import sys
sys.path.append('../tools')

import getanalysis
import tradesim
import csv
import time
import numpy
import pylab

jdata_filepath = '../../data/jcandles.csv'
hadata_filepath = '../../data/hacandles.csv'
jdata = getanalysis.import_j_candles(jdata_filepath)
hadata = getanalysis.import_j_candles(hadata_filepath)

[jincrease_data, jbody_sizes, jshadow_sizes,
 data_length] = getanalysis.body_and_shadow(jdata)
[jrun_length_data,
 jreversals] = getanalysis.runs_and_reversal(jdata, data_length,
                                             jincrease_data)

[haincrease_data, habody_sizes, hashadow_sizes,
 data_length] = getanalysis.body_and_shadow(hadata)
[harun_length_data,
 hareversals] = getanalysis.runs_and_reversal(hadata, data_length,
                                              haincrease_data)

jrun_function_data = getanalysis.run_analysis(jbody_sizes, data_length,
                                              jrun_length_data, jincrease_data)
harun_function_data = getanalysis.run_analysis(habody_sizes, data_length,
                                               harun_length_data,
예제 #2
0
import getanalysis
import tradesim
import csv

trade_filepath = '../../data/tradedata/Heikenashispintopsbuyorsell.csv'

with open(trade_filepath, 'rb') as trade_file:
    trade_array = []
    trade_file_data = csv.reader(trade_file, delimiter=',')
    for row in trade_file_data:
        trade_array.append(int(row[0]))

data_filepath = '../../data/hacandles.csv'
        
data = getanalysis.import_j_candles(data_filepath)

[profit, profit_array] = tradesim.sim_trade(data, trade_array)
percent_profit = (profit - 1) * 100
print('Heikin Ashi spinning tops')
print('Profit: ' + str(percent_profit) + '%')
print('Max profit: ' + str((max(profit_array)-1)*100) + '%\n')

trade_filepath = '../../data/tradedata/ha-candles-bear-and-bull-dojis.csv'
with open(trade_filepath, 'rb') as trade_file:
    trade_array = []
    trade_file_data = csv.reader(trade_file, delimiter=',')
    for row in trade_file_data:
        trade_array.append(int(row[0]))
[profit, profit_array] = tradesim.sim_trade(data, trade_array)
percent_profit = (profit - 1) * 100
예제 #3
0
import sys
sys.path.append('../tools')

import getanalysis
import tradesim

# Import japanese candle data
data = getanalysis.import_j_candles('../../data/jcandles.csv')

# Get all sorts of data
[
    increase_data, body_sizes, shadow_sizes, data_length, run_length_data,
    reversals
] = getanalysis.analyse(data)

# Get body size data
[av_body_size,
 body_size_quartiles] = getanalysis.body_size_analysis(body_sizes)

# Get Dojis
doji_array = [0] * data_length
for i in range(data_length):
    if body_sizes[i] < body_size_quartiles[1]:
        doji_array[i] += 1

###########
# Testing #
###########

# Buy or sell on every reversal
trade_array = [0] * data_length