from ParadoxTrading.Chart import Wizard
from ParadoxTrading.Fetch.ChineseFutures import FetchDominantIndex
from ParadoxTrading.Indicator import ReturnRate

fetcher = FetchDominantIndex()

market = fetcher.fetchDayData('20100701', '20170101', 'rb')
rate_1 = ReturnRate().addMany(market).getAllData()
rate_12 = ReturnRate(12).addMany(market).getAllData()

rate_abs_1 = ReturnRate(_use_abs=True).addMany(market).getAllData()
rate_abs_12 = ReturnRate(12, _use_abs=True).addMany(market).getAllData()

wizard = Wizard()

price_view = wizard.addView('price', _view_stretch=3)
price_view.addLine('market', market.index(), market['closeprice'])

sub_view = wizard.addView('sub')
sub_view.addLine('rate_1', rate_1.index(), rate_1['returnrate'])
sub_view.addLine('rate_12', rate_12.index(), rate_12['returnrate'])

abs_view = wizard.addView('abs')
abs_view.addLine('rate_abs_1', rate_abs_1.index(), rate_abs_1['returnrate'])
abs_view.addLine('rate_abs_12', rate_abs_12.index(), rate_abs_12['returnrate'])

wizard.show()
Example #2
0
from ParadoxTrading.Chart import Wizard
from ParadoxTrading.Fetch.ChineseFutures import FetchDominantIndex
from ParadoxTrading.Indicator import MA, FastMA
import time

fetcher = FetchDominantIndex()
data = fetcher.fetchDayData(
    '20100101', '20170101', 'rb'
)
print(time.clock())
ma = MA(30).addMany(data).getAllData()
print(time.clock())
fast_ma = FastMA(30).addMany(data).getAllData()
print(time.clock())

wizard = Wizard()

price_view = wizard.addView('price')
price_view.addLine('price', data.index(), data['closeprice'])
price_view.addLine('ma', ma.index(), ma['ma'])
price_view.addLine('fast ma', fast_ma.index(), fast_ma['ma'])

wizard.show()
Example #3
0
import time

import numpy as np
from TorchTSA.model import IGARCHModel, ARMAGARCHModel
from arch import arch_model

from ParadoxTrading.Chart import Wizard
from ParadoxTrading.Fetch.ChineseFutures import FetchDominantIndex
from ParadoxTrading.Indicator import LogReturn
from ParadoxTrading.Indicator.TSA import GARCH

fetcher = FetchDominantIndex()

market = fetcher.fetchDayData('20100701', '20180101', 'cu')

returns = LogReturn().addMany(market).getAllData()
return_arr = np.array(returns['logreturn'])

am = arch_model(return_arr, mean='Zero')
start_time = time.time()
res = am.fit(disp='off', show_warning=False)
print('fitting time:', time.time() - start_time)
print(res.params)

igarch_model = IGARCHModel(_use_mu=False)
start_time = time.time()
igarch_model.fit(return_arr)
print('fitting time:', time.time() - start_time)
print(
    igarch_model.getAlphas(),
    igarch_model.getBetas(),
print(fetcher.instrumentIsAvailable('rb1801', '20171014'))

print(fetcher.instrumentLastTradingDay('rb1801', '20171013'))
print(fetcher.instrumentNextTradingDay('rb1801', '20171013'))

print(fetcher.fetchData('20171013', 'rb1801'))
print(fetcher.fetchData('20171014', 'rb1801'))

print(fetcher.fetchDayData('20171010', '20171017', 'rb1801'))

register = fetcher.register_type('rb')
print(register)
print(fetcher.fetchSymbol('20171013', **register.toKwargs()))

print('-- dominant index --')
fetcher = FetchDominantIndex()

print(fetcher.fetchData('20171013', 'rb'))
print(fetcher.fetchData('20171014', 'rb'))

print(fetcher.fetchDayData('20171010', '20171017', 'rb'))

register = fetcher.register_type('rb')
print(register)
print(fetcher.fetchSymbol('20171013', **register.toKwargs()))

print('-- product index --')
fetcher = FetchProductIndex()

print(fetcher.fetchData('20171013', 'rb'))
print(fetcher.fetchData('20171014', 'rb'))
Example #5
0
from ParadoxTrading.Chart import Wizard
from ParadoxTrading.Fetch.ChineseFutures import FetchDominantIndex
from ParadoxTrading.Indicator import RSRS

fetcher = FetchDominantIndex()
data = fetcher.fetchDayData('20100101', '20170101', 'cu')

rsrs_data = RSRS().addMany(data).getAllData()

wizard = Wizard()

price_view = wizard.addView('price')
price_view.addCandle(
    'candle', data.index(), data.toRows(
        ['openprice', 'highprice', 'lowprice', 'closeprice']
    )[0]
)

rsrs_view = wizard.addView('rsrs')
rsrs_view.addLine('rsrs', rsrs_data.index(), rsrs_data['rsrs'])

wizard.show()
Example #6
0
from ParadoxTrading.Fetch.ChineseFutures import FetchDominantIndex
from ParadoxTrading.Indicator import Plunge, EMA
from ParadoxTrading.Chart import Wizard

fetcher = FetchDominantIndex()
rb = fetcher.fetchDayData('20100101', '20170101', 'rb')

fast_ema = EMA(50).addMany(rb).getAllData()
slow_ema = EMA(100).addMany(rb).getAllData()
plunge = Plunge().addMany(rb).getAllData()

wizard = Wizard()

main_view = wizard.addView('main', _adaptive=True, _view_stretch=3)
main_view.addLine('price', rb.index(), rb['closeprice'])
main_view.addLine('fast_ema', fast_ema.index(), fast_ema['ema'])
main_view.addLine('slow_ema', slow_ema.index(), slow_ema['ema'])

sub_view = wizard.addView('sub')
sub_view.addLine('plunge', plunge.index(), plunge['plunge'])

wizard.show()