Skip to content

use tulipy and accept an array of technical indicators as an argument (feature request) #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ckhung opened this issue Dec 20, 2019 · 2 comments

Comments

@ckhung
Copy link

ckhung commented Dec 20, 2019

Hi Daniel, thank you for taking over the maintainance of mpl-finance. I agree with you about the new mission statement. Here is a feature request for you to consider. (Hope it's ok to post it as an issue.) The tulipy project already implemented lots of technical indicators. It would be nice to be able to use them in mpl_finance. Here is a short piece showing how I would like to be able to pass my chosen technical indicators as arguments to candlestick_ohlc():

#!/usr/bin/python3

import numpy as np
import tulipy as ti
from datetime import datetime

def candlestick_ohlc(quotes, ti_array):
    close_prices = quotes['Close'].copy(order='C')
    for ti in ti_array:
        f = ti['f']
        del ti['f']
        print(f.full_name, f(close_prices, **ti))
        # of course in real code it should be plotting here.

dt = [float] * 6
dt[0] = 'datetime64[D]'
convertfunc = lambda x: datetime.strptime(x.decode('utf8'), '%m/%d/%Y')
daily = np.genfromtxt('SP500_NOV2019_Hist.csv',
    delimiter=',', autostrip=True, names=True, dtype=dt,
    converters = {'Date': convertfunc}
)
candlestick_ohlc(daily, [
    {'f':ti.sma, 'period':5},
    {'f':ti.sma, 'period':10},
    {'f':ti.macd, 'short_period':2, 'long_period':5, 'signal_period':9}
] )

@ckhung ckhung changed the title use tulipy and accept an array of technical indicators (feature request) use tulipy and accept an array of technical indicators as an argument (feature request) Dec 20, 2019
@DanielGoldfarb
Copy link
Contributor

Chao-Kuei, Thank you so much for the idea. I had never heard of tulipy, and I like this idea very much. I will try in the next week or two to make some time to experiment with the code you have provided, and with tulipy in general, and see if I can prototype something for you to play with. Please feel free to re-post this idea here: https://github.com/matplotlib/mplfinance/issues as I plan to be doing all new development in that new repository. Thanks again.

@ckhung
Copy link
Author

ckhung commented Mar 17, 2021

matplotlib/mplfinance#3

@ckhung ckhung closed this as completed Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants