├── Cocoa-KLine.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── Yochi.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── Cocoa-KLine ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Cocoa_KLine │ ├── Cocoa_CalculateCoordinate.h │ ├── Cocoa_CalculateCoordinate.m │ ├── Cocoa_CandleLineView.h │ ├── Cocoa_CandleLineView.m │ ├── Cocoa_ChartManager.h │ ├── Cocoa_ChartManager.m │ ├── Cocoa_ChartModel.h │ ├── Cocoa_ChartModel.m │ ├── Cocoa_ChartProtocol.h │ ├── Cocoa_ChartStylesheet.h │ ├── Cocoa_CrossCurveView.h │ ├── Cocoa_CrossCurveView.m │ ├── Cocoa_FullScreenController.h │ ├── Cocoa_FullScreenController.m │ ├── Cocoa_KDJView.h │ ├── Cocoa_KDJView.m │ ├── Cocoa_KLine.h │ ├── Cocoa_MACDView.h │ ├── Cocoa_MACDView.m │ ├── Cocoa_OBVView.h │ ├── Cocoa_OBVView.m │ ├── Cocoa_TecnnicalOptionsView.h │ ├── Cocoa_TecnnicalOptionsView.m │ ├── Cocoa_TecnnicalView.h │ ├── Cocoa_TecnnicalView.m │ ├── Cocoa_TradingVolumeView.h │ ├── Cocoa_TradingVolumeView.m │ ├── Cocoa_WRView.h │ ├── Cocoa_WRView.m │ └── TALib │ │ ├── include │ │ ├── ta_abstract.h │ │ ├── ta_common.h │ │ ├── ta_defs.h │ │ ├── ta_func.h │ │ └── ta_libc.h │ │ └── src │ │ ├── ta_common │ │ ├── ta_global.c │ │ ├── ta_global.h │ │ ├── ta_magic_nb.h │ │ ├── ta_memory.h │ │ ├── ta_pragma.h │ │ ├── ta_retcode.c │ │ ├── ta_retcode.csv │ │ └── ta_version.c │ │ └── ta_func │ │ ├── ta_ACOS.c │ │ ├── ta_AD.c │ │ ├── ta_ADD.c │ │ ├── ta_ADOSC.c │ │ ├── ta_ADX.c │ │ ├── ta_ADXR.c │ │ ├── ta_APO.c │ │ ├── ta_AROON.c │ │ ├── ta_AROONOSC.c │ │ ├── ta_ASIN.c │ │ ├── ta_ATAN.c │ │ ├── ta_ATR.c │ │ ├── ta_AVGPRICE.c │ │ ├── ta_BBANDS.c │ │ ├── ta_BETA.c │ │ ├── ta_BOP.c │ │ ├── ta_CCI.c │ │ ├── ta_CDL2CROWS.c │ │ ├── ta_CDL3BLACKCROWS.c │ │ ├── ta_CDL3INSIDE.c │ │ ├── ta_CDL3LINESTRIKE.c │ │ ├── ta_CDL3OUTSIDE.c │ │ ├── ta_CDL3STARSINSOUTH.c │ │ ├── ta_CDL3WHITESOLDIERS.c │ │ ├── ta_CDLABANDONEDBABY.c │ │ ├── ta_CDLADVANCEBLOCK.c │ │ ├── ta_CDLBELTHOLD.c │ │ ├── ta_CDLBREAKAWAY.c │ │ ├── ta_CDLCLOSINGMARUBOZU.c │ │ ├── ta_CDLCONCEALBABYSWALL.c │ │ ├── ta_CDLCOUNTERATTACK.c │ │ ├── ta_CDLDARKCLOUDCOVER.c │ │ ├── ta_CDLDOJI.c │ │ ├── ta_CDLDOJISTAR.c │ │ ├── ta_CDLDRAGONFLYDOJI.c │ │ ├── ta_CDLENGULFING.c │ │ ├── ta_CDLEVENINGDOJISTAR.c │ │ ├── ta_CDLEVENINGSTAR.c │ │ ├── ta_CDLGAPSIDESIDEWHITE.c │ │ ├── ta_CDLGRAVESTONEDOJI.c │ │ ├── ta_CDLHAMMER.c │ │ ├── ta_CDLHANGINGMAN.c │ │ ├── ta_CDLHARAMI.c │ │ ├── ta_CDLHARAMICROSS.c │ │ ├── ta_CDLHIGHWAVE.c │ │ ├── ta_CDLHIKKAKE.c │ │ ├── ta_CDLHIKKAKEMOD.c │ │ ├── ta_CDLHOMINGPIGEON.c │ │ ├── ta_CDLIDENTICAL3CROWS.c │ │ ├── ta_CDLINNECK.c │ │ ├── ta_CDLINVERTEDHAMMER.c │ │ ├── ta_CDLKICKING.c │ │ ├── ta_CDLKICKINGBYLENGTH.c │ │ ├── ta_CDLLADDERBOTTOM.c │ │ ├── ta_CDLLONGLEGGEDDOJI.c │ │ ├── ta_CDLLONGLINE.c │ │ ├── ta_CDLMARUBOZU.c │ │ ├── ta_CDLMATCHINGLOW.c │ │ ├── ta_CDLMATHOLD.c │ │ ├── ta_CDLMORNINGDOJISTAR.c │ │ ├── ta_CDLMORNINGSTAR.c │ │ ├── ta_CDLONNECK.c │ │ ├── ta_CDLPIERCING.c │ │ ├── ta_CDLRICKSHAWMAN.c │ │ ├── ta_CDLRISEFALL3METHODS.c │ │ ├── ta_CDLSEPARATINGLINES.c │ │ ├── ta_CDLSHOOTINGSTAR.c │ │ ├── ta_CDLSHORTLINE.c │ │ ├── ta_CDLSPINNINGTOP.c │ │ ├── ta_CDLSTALLEDPATTERN.c │ │ ├── ta_CDLSTICKSANDWICH.c │ │ ├── ta_CDLTAKURI.c │ │ ├── ta_CDLTASUKIGAP.c │ │ ├── ta_CDLTHRUSTING.c │ │ ├── ta_CDLTRISTAR.c │ │ ├── ta_CDLUNIQUE3RIVER.c │ │ ├── ta_CDLUPSIDEGAP2CROWS.c │ │ ├── ta_CDLXSIDEGAP3METHODS.c │ │ ├── ta_CEIL.c │ │ ├── ta_CMO.c │ │ ├── ta_CORREL.c │ │ ├── ta_COS.c │ │ ├── ta_COSH.c │ │ ├── ta_DEMA.c │ │ ├── ta_DIV.c │ │ ├── ta_DX.c │ │ ├── ta_EMA.c │ │ ├── ta_EXP.c │ │ ├── ta_FLOOR.c │ │ ├── ta_HT_DCPERIOD.c │ │ ├── ta_HT_DCPHASE.c │ │ ├── ta_HT_PHASOR.c │ │ ├── ta_HT_SINE.c │ │ ├── ta_HT_TRENDLINE.c │ │ ├── ta_HT_TRENDMODE.c │ │ ├── ta_KAMA.c │ │ ├── ta_LINEARREG.c │ │ ├── ta_LINEARREG_ANGLE.c │ │ ├── ta_LINEARREG_INTERCEPT.c │ │ ├── ta_LINEARREG_SLOPE.c │ │ ├── ta_LN.c │ │ ├── ta_LOG10.c │ │ ├── ta_MA.c │ │ ├── ta_MACD.c │ │ ├── ta_MACDEXT.c │ │ ├── ta_MACDFIX.c │ │ ├── ta_MAMA.c │ │ ├── ta_MAVP.c │ │ ├── ta_MAX.c │ │ ├── ta_MAXINDEX.c │ │ ├── ta_MEDPRICE.c │ │ ├── ta_MFI.c │ │ ├── ta_MIDPOINT.c │ │ ├── ta_MIDPRICE.c │ │ ├── ta_MIN.c │ │ ├── ta_MININDEX.c │ │ ├── ta_MINMAX.c │ │ ├── ta_MINMAXINDEX.c │ │ ├── ta_MINUS_DI.c │ │ ├── ta_MINUS_DM.c │ │ ├── ta_MOM.c │ │ ├── ta_MULT.c │ │ ├── ta_NATR.c │ │ ├── ta_NVI.c │ │ ├── ta_OBV.c │ │ ├── ta_PLUS_DI.c │ │ ├── ta_PLUS_DM.c │ │ ├── ta_PPO.c │ │ ├── ta_PVI.c │ │ ├── ta_ROC.c │ │ ├── ta_ROCP.c │ │ ├── ta_ROCR.c │ │ ├── ta_ROCR100.c │ │ ├── ta_RSI.c │ │ ├── ta_SAR.c │ │ ├── ta_SAREXT.c │ │ ├── ta_SIN.c │ │ ├── ta_SINH.c │ │ ├── ta_SMA.c │ │ ├── ta_SQRT.c │ │ ├── ta_STDDEV.c │ │ ├── ta_STOCH.c │ │ ├── ta_STOCHF.c │ │ ├── ta_STOCHRSI.c │ │ ├── ta_SUB.c │ │ ├── ta_SUM.c │ │ ├── ta_T3.c │ │ ├── ta_TAN.c │ │ ├── ta_TANH.c │ │ ├── ta_TEMA.c │ │ ├── ta_TRANGE.c │ │ ├── ta_TRIMA.c │ │ ├── ta_TRIX.c │ │ ├── ta_TSF.c │ │ ├── ta_TYPPRICE.c │ │ ├── ta_ULTOSC.c │ │ ├── ta_VAR.c │ │ ├── ta_WCLPRICE.c │ │ ├── ta_WILLR.c │ │ ├── ta_WMA.c │ │ ├── ta_utility.c │ │ └── ta_utility.h ├── Info.plist ├── ViewController.h ├── ViewController.m ├── klineJson.geojson └── main.m ├── Cocoa-KLineTests ├── Cocoa_KLineTests.m └── Info.plist ├── Cocoa-KLineUITests ├── Cocoa_KLineUITests.m └── Info.plist └── README.md /Cocoa-KLine.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Cocoa-KLine.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Cocoa-KLine.xcodeproj/xcuserdata/Yochi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 18 | 19 | 20 | 22 | 34 | 35 | 36 | 38 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Cocoa-KLine.xcodeproj/xcuserdata/Yochi.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Cocoa-KLine.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Cocoa-KLine/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Cocoa-KLine/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Cocoa-KLine/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Cocoa-KLine/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Cocoa-KLine/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Cocoa-KLine/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_CalculateCoordinate.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_CalculateCoordinate.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/4. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ta_libc.h" 11 | #import "Cocoa_ChartModel.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MACDParameter) { 14 | MACDParameterDIFF, 15 | MACDParameterMACD, 16 | MACDParameterDEA, 17 | }; 18 | 19 | @interface Cocoa_CalculateCoordinate : NSObject 20 | 21 | /** 均值计算 */ 22 | void computeMAData(NSArray *items,int period); 23 | 24 | /** macd 计算 */ 25 | void computeMACDData(NSArray *items); 26 | 27 | /** kdj计算 */ 28 | void computeKDJData(NSArray *items); 29 | 30 | /** WR计算 */ 31 | NSMutableArray *computeWRData(NSArray *items,int period); 32 | 33 | /** OBV计算 */ 34 | void computeOBVData(NSArray *items); 35 | 36 | /** ... */ 37 | 38 | /** iOS 转 c数组 */ 39 | void NSArrayToCArray(NSArray *array, double outCArray[]); 40 | 41 | /** c数组转iOS数组 */ 42 | NSArray *CArrayToNSArray(const double inCArray[], int length, int outBegIdx, int outNBElement); 43 | 44 | // MACD类型 45 | NSArray *MACDCArrayToNSArray(const double inCArray[], int length, int outBegIdx, int outNBElement, NSArray *items, MACDParameter parameter); 46 | 47 | NSArray *MDCArrayToNSArray(const double inCArray[], int length, int outBegIdx, int outNBElement, NSArray *items); 48 | 49 | void freeAndSetNULL(void *ptr); 50 | 51 | CGFloat customComputeMA(NSArray *items, NSInteger days); 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_CandleLineView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_CandleLineView.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartModel.h" 11 | #import "Cocoa_ChartProtocol.h" 12 | 13 | @interface Cocoa_CandleLineView : UIView 14 | 15 | /** 当前屏幕范围内显示的k线模型数组 */ 16 | @property (nonatomic,strong) NSMutableArray *currentDisplayArray; 17 | @property (nonatomic,assign) NSInteger displayCount; 18 | @property (nonatomic, assign) BOOL socketFlag; 19 | /** 均线宽度(默认:1.0) **/ 20 | @property (nonatomic, assign) CGFloat avgLineWidth; 21 | 22 | /** K线宽度(蜡烛实体宽度)(默认:8.0) **/ 23 | @property (nonatomic, assign) CGFloat candleWidth; 24 | @property (nonatomic, assign) NSInteger startIndex; 25 | 26 | @property (nonatomic, strong) UIColor *candleRiseColor; 27 | @property (nonatomic, strong) UIColor *candleFallColor; 28 | 29 | /** 最大宽度(默认:10.0) **/ 30 | @property (nonatomic, assign) CGFloat maxCandleWidth; 31 | 32 | @property (nonatomic, assign) CGFloat maxHighValue; 33 | @property (nonatomic, assign) CGFloat minlowValue; 34 | 35 | /** 最小K线宽度(默认:1.0) **/ 36 | @property (nonatomic, assign) CGFloat minCandleWidth; 37 | 38 | /** 5日均线颜色(默认:白色) 由小到大排列 **/ 39 | @property (nonatomic, strong) UIColor *ma1AvgLineColor; 40 | 41 | /** 10日均线颜色(默认:黄色) **/ 42 | @property (nonatomic, strong) UIColor *ma2AvgLineColor; 43 | 44 | /** 20日均线颜色(默认:紫色) **/ 45 | @property (nonatomic, strong) UIColor *ma3AvgLineColor; 46 | 47 | /** 数据模型 */ 48 | @property (nonatomic,strong) NSMutableArray<__kindof Cocoa_ChartModel*> *dataArray; 49 | 50 | @property (nonatomic, assign) id delegate; 51 | 52 | - (void)pinGesture:(UIPinchGestureRecognizer *)pin; 53 | 54 | - (void)refreshChartView; 55 | 56 | - (void)clearChartView; 57 | 58 | - (void)removeAllObserver; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_ChartManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_ChartManager.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "Cocoa_ChartModel.h" 12 | #import "Cocoa_CandleLineView.h" 13 | 14 | typedef void(^ChangeCompleteBlock)(id DataInfo); 15 | 16 | typedef void(^LoadmoredataBlock)(id DataInfo); 17 | 18 | typedef void(^LandscapeSwitchBlock)(void); 19 | 20 | @interface Cocoa_ChartManager : UIView 21 | 22 | @property (nonatomic, strong) UIScrollView *mainScrollerView; 23 | 24 | /** 是否支持长按手势(默认:支持) **/ 25 | @property (nonatomic, assign) BOOL longPressEnabled; 26 | /** 是否支持滑动手势(默认:支持) **/ 27 | @property (nonatomic, assign) BOOL panEnabled; 28 | /** 是否支持啮合放大缩小手势(默认:支持) **/ 29 | @property (nonatomic, assign) BOOL pinEnabled; 30 | /** 是否支持轻拍切换类型手势(默认:支持) **/ 31 | @property (nonatomic, assign) BOOL tapEnabled; 32 | 33 | /** 数据回调 */ 34 | @property (nonatomic, strong) ChangeCompleteBlock changeCompleteBlock; 35 | 36 | /** 刷新数据 */ 37 | @property (nonatomic, strong) LoadmoredataBlock loadmoredataBlock; 38 | 39 | /** 全屏切换 */ 40 | @property (nonatomic, strong) LandscapeSwitchBlock landscapeSwitchBlock; 41 | 42 | /** 初始化数据 */ 43 | @property (nonatomic,strong) NSMutableArray<__kindof Cocoa_ChartModel*> *dataArray; 44 | 45 | /** 双击 横竖屏切换 */ 46 | - (void)landscapeSwitch; 47 | 48 | /** 刷新数据 */ 49 | - (void)refreshChartView; 50 | 51 | /** socket追加数据 */ 52 | - (void)appendingChartView; 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_ChartModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_ChartModel.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/1. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface Cocoa_ChartModel : NSObject 13 | 14 | //------------------------------- 15 | /** 外部必传参数 */ 16 | //------------------------------- 17 | 18 | // 成交量 19 | @property (nonatomic, assign) double volume; 20 | // 开盘价 21 | @property (nonatomic, assign) double open; 22 | // 收盘价 23 | @property (nonatomic, assign) double close; 24 | // 最高价 25 | @property (nonatomic, assign) double high; 26 | // 最低价 27 | @property (nonatomic, assign) double low; 28 | 29 | /** 字符串显示 */ 30 | // 成交量 31 | @property (nonatomic, strong) NSString *volumeStr; 32 | // 开盘价 33 | @property (nonatomic, strong) NSString *openStr; 34 | // 收盘价 35 | @property (nonatomic, strong) NSString *closeStr; 36 | // 最高价 37 | @property (nonatomic, strong) NSString *highStr; 38 | // 最低价 39 | @property (nonatomic, strong) NSString *lowStr; 40 | 41 | // 小数位精度 主要用于数据展示 最长八位 42 | @property (nonatomic, assign) NSInteger priceaccuracy; 43 | @property (nonatomic, assign) NSInteger volumaccuracy; 44 | 45 | // 日期时间 46 | @property (nonatomic, copy) NSString *date; 47 | 48 | @property (nonatomic, copy) NSString *timestampStr; 49 | 50 | //------------------------------- 51 | /** 内部计算参数 */ 52 | //------------------------------- 53 | 54 | /********************坐标位置******************************/ 55 | 56 | /** 开盘点 */ 57 | @property (nonatomic, assign) CGPoint openPoint; 58 | 59 | /** 收盘点 */ 60 | @property (nonatomic, assign) CGPoint closePoint; 61 | 62 | /** 最高点 */ 63 | @property (nonatomic, assign) CGPoint highPoint; 64 | 65 | /** 最低点 */ 66 | @property (nonatomic, assign) CGPoint lowPoint; 67 | 68 | /** 当前k线位置 */ 69 | @property (assign, nonatomic) NSInteger localIndex; 70 | 71 | /********************k线图均线******************************/ 72 | /** 5日均线 */ 73 | @property (nonatomic, assign) CGFloat ma5; 74 | /** 10日均线 */ 75 | @property (nonatomic, assign) CGFloat ma10; 76 | /** 20日均线 */ 77 | @property (nonatomic, assign) CGFloat ma20; 78 | 79 | /********************成交量均线******************************/ 80 | /** 5日成交量均线 */ 81 | @property (nonatomic, assign) CGFloat ma5Volume; 82 | 83 | /** 10日成交量均线 */ 84 | @property (nonatomic, assign) CGFloat ma10Volume; 85 | 86 | @property (nonatomic, assign) CGFloat priceChangeRatio; 87 | 88 | /********************MACD值******************************/ 89 | @property(assign, nonatomic) CGFloat dea; 90 | @property(assign, nonatomic) CGFloat diff; 91 | @property(assign, nonatomic) CGFloat macd; 92 | 93 | /********************KDJ值******************************/ 94 | @property(assign, nonatomic) CGFloat KValue; 95 | @property(assign, nonatomic) CGFloat DValue; 96 | @property(assign, nonatomic) CGFloat JValue; 97 | 98 | /********************WR值******************************/ 99 | @property(assign, nonatomic) CGFloat WRValue; 100 | 101 | /********************OBV值******************************/ 102 | @property(assign, nonatomic) CGFloat OBVValue; 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_ChartModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_ChartModel.m 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/1. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_ChartModel.h" 10 | 11 | @implementation Cocoa_ChartModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_ChartProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_ChartProtocol.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartModel.h" 11 | typedef enum 12 | { 13 | TecnnicalType_VOL = 100, 14 | TecnnicalType_MACD, 15 | TecnnicalType_KDJ, 16 | TecnnicalType_OBV, 17 | TecnnicalType_WR, 18 | 19 | }TecnnicalType; 20 | 21 | typedef NS_ENUM(NSInteger, StockStyleState){ 22 | StockStateRise = 1, 23 | StockStateFall 24 | }; 25 | 26 | static inline bool isEqualZero(float value) { 27 | 28 | return fabsf(value) <= 0.00001f; 29 | } 30 | 31 | // 数据精度控制 值 参考值 32 | static inline NSString* klineValue(double value, NSInteger accuracy) { 33 | 34 | NSString *string = [NSString stringWithFormat:@"%%.%ldf",accuracy]; 35 | NSString *accuracystr = [NSString stringWithFormat:string, value]; 36 | return accuracystr; 37 | } 38 | 39 | /** 所有指标,遵循次协议 */ 40 | @protocol Cocoa_ChartProtocol 41 | 42 | /** 数据模型 */ 43 | @property (nonatomic,strong) NSMutableArray<__kindof Cocoa_ChartModel*> *dataArray; 44 | /** 数据模型最大值 */ 45 | @property (nonatomic, assign) CGFloat maxValue; 46 | /** 数据模型最小值 */ 47 | @property (nonatomic, assign) CGFloat minValue; 48 | /** 坐标最大值 */ 49 | @property (nonatomic, assign) CGFloat coordinateMaxValue; 50 | /** 坐标最小值 */ 51 | @property (nonatomic, assign) CGFloat coordinateminValue; 52 | /** 坐标比例 */ 53 | @property (nonatomic, assign) CGFloat scaleValue; 54 | /** 边距 */ 55 | @property (nonatomic, assign) UIEdgeInsets padding; 56 | 57 | // @synthesize xxx 将@property中定义的属性自动生成get/set的实现方法而且默认访问成员变量xxx 58 | 59 | @optional 60 | 61 | @property (nonatomic,assign) CGFloat leftPostion; 62 | @property (nonatomic,assign) NSInteger startIndex; 63 | @property (nonatomic,assign) NSInteger displayCount; 64 | @property (nonatomic,assign) CGFloat candleWidth; 65 | @property (nonatomic,assign) CGFloat candleSpace; 66 | 67 | // 清空k线界面数据 68 | - (void)clearChartView; 69 | 70 | // 刷新k线界面 71 | - (void)refreshChartView; 72 | 73 | // 计算最大最小值 74 | - (void)calcuteMaxAndMinValue; 75 | 76 | // 绘制k线 77 | - (void)drawChartView; 78 | 79 | // 加载更多数据 80 | - (void)displayMoreData; 81 | 82 | // 蜡烛柱,位置,index,带动底部指标 83 | - (void)displayScreenleftPostion:(CGFloat)leftPostion startIndex:(NSInteger)index count:(NSInteger)count; 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_ChartStylesheet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_ChartStylesheet.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/1. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #ifndef Cocoa_ChartStylesheet_h 10 | #define Cocoa_ChartStylesheet_h 11 | 12 | /** 屏幕横竖屏尺寸 */ 13 | #define kSCREENWIDTH [UIScreen mainScreen].bounds.size.width 14 | 15 | #define kSCREENHEIGHT [UIScreen mainScreen].bounds.size.height 16 | 17 | #define kSTATUSHEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height 18 | 19 | #define kNAVIGATIONHEIGHT (kSTATUSHEIGHT + 44) 20 | 21 | #define kTABBARHEIGHT (PCiPhoneX ? 83.0 : 49.0) 22 | 23 | //涨 24 | #define COLOR_RISECOLOR [UIColor colorWithRed:249.0/255.0 green:87.0/255.0 blue:92.0/255.0 alpha:1.0] 25 | 26 | //跌 27 | #define COLOR_FALLCOLOR [UIColor colorWithRed:36.0/255.0 green:165.0/255.0 blue:120.0/255.0 alpha:1.0] 28 | 29 | //背景色 30 | //#define COLOR_BACKGROUND [UIColor colorWithRed:30.0/255.0 green:33.0/255.0 blue:48.0/255.0 alpha:1.0] 31 | 32 | #define COLOR_BACKGROUND [UIColor colorWithRed:30.0/255.0 green:33.0/255.0 blue:50.0/255.0 alpha:1.0] 33 | #define COLOR_CROSSBACKGROUND [UIColor colorWithRed:38.0/255.0 green:42.0/255.0 blue:64.0/255.0 alpha:1.0] 34 | #define COLOR_CROSSTEXT [UIColor colorWithRed:142.0/255.0 green:154.0/255.0 blue:183.0/255.0 alpha:1.0] 35 | 36 | // 高亮色 37 | #define COLOR_HIGHLIGHT [UIColor colorWithRed:36.0/255.0 green:133.0/255.0 blue:169.0/255.0 alpha:1.0] 38 | 39 | // 文字警告色 40 | #define COLOR_WARNINTEXT [UIColor colorWithRed:176.0/255.0 green:100.0/255.0 blue:75.0/255.0 alpha:1.0] 41 | 42 | // 坐标线颜色 43 | #define COLOR_COORDINATELINE [UIColor colorWithRed:15.0/255.0 green:17.0/255.0 blue:26.0/255.0 alpha:1.0] 44 | 45 | // 坐标文字颜色 46 | #define COLOR_COORDINATETEXT [UIColor colorWithRed:104.0/255.0 green:105.0/255.0 blue:112.0/255.0 alpha:1.0] 47 | 48 | // 文字标题色 49 | #define COLOR_TITLECOLOR [UIColor colorWithRed:179.0/255.0 green:179.0/255.0 blue:179.0/255.0 alpha:1.0] 50 | 51 | // 5 10 30 日均线 52 | #define COLOR_MA5 [UIColor colorWithRed:204.0/255.0 green:114.0/255.0 blue:24.0/255.0 alpha:1.0] 53 | #define COLOR_MA10 [UIColor colorWithRed:38.0/255.0 green:144.0/255.0 blue:182.0/255.0 alpha:1.0] 54 | #define COLOR_MA30 [UIColor colorWithRed:153.0/255.0 green:82.0/255.0 blue:149.0/255.0 alpha:1.0] 55 | 56 | #endif /* Cocoa_ChartStylesheet_h */ 57 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_CrossCurveView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_CrossCurveView.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/4. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartModel.h" 11 | #import "Cocoa_ChartStylesheet.h" 12 | @interface Cocoa_CrossCurveView : UIView 13 | 14 | @property (nonatomic, assign) CGPoint touchPoint; 15 | @property (nonatomic, strong) UIColor *crossLineColor; 16 | @property (nonatomic, assign) UIEdgeInsets padding; 17 | @property (nonatomic, strong) CAShapeLayer *crossLayer; 18 | @property (nonatomic, strong) Cocoa_ChartModel *chartModel; 19 | @property (nonatomic, strong) UILabel *suspendDateL; 20 | 21 | - (void)drawCrossLineWithPoint:(CGPoint)point inofStr:(NSString *)infoStr chartModel:(Cocoa_ChartModel*)chartModel; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_FullScreenController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_FullScreenController.h 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/23. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_KLine.h" 11 | 12 | 13 | @interface Cocoa_FullScreenController : UIViewController 14 | 15 | @property (nonatomic, strong) UIView *chartsuperView; 16 | 17 | @property (nonatomic, weak) Cocoa_ChartManager *chartManager; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_FullScreenController.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_FullScreenController.m 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/23. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_FullScreenController.h" 10 | 11 | @interface Cocoa_FullScreenController () 12 | 13 | @end 14 | 15 | @implementation Cocoa_FullScreenController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | 21 | self.view.backgroundColor = COLOR_BACKGROUND; 22 | 23 | _chartManager.frame = CGRectMake(0, 40, kSCREENHEIGHT, kSCREENWIDTH-40); 24 | [self.view addSubview:_chartManager]; 25 | 26 | [_chartManager landscapeSwitch]; 27 | 28 | __weak typeof(self) weakSelf = self; 29 | _chartManager.landscapeSwitchBlock = ^{ 30 | __strong typeof(self) self = weakSelf; 31 | 32 | [self clickAction]; 33 | }; 34 | } 35 | 36 | - (void)clickAction 37 | { 38 | __weak typeof(self) weakSelf = self; 39 | [self dismissViewControllerAnimated:NO completion:^{ 40 | 41 | __strong typeof(self) self = weakSelf; 42 | self.chartManager.frame = CGRectMake(0, 60, kSCREENWIDTH, kSCREENWIDTH-60); 43 | 44 | [self.chartManager landscapeSwitch]; 45 | [self.chartsuperView addSubview:self.chartManager]; 46 | 47 | }]; 48 | } 49 | 50 | - (BOOL)shouldAutorotate{ 51 | return NO; 52 | } 53 | - (UIInterfaceOrientationMask)supportedInterfaceOrientations{ 54 | return UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft; 55 | } 56 | 57 | - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ 58 | return UIDeviceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft; 59 | } 60 | 61 | - (UIStatusBarStyle)preferredStatusBarStyle { 62 | return UIStatusBarStyleLightContent; 63 | } 64 | 65 | - (BOOL)prefersStatusBarHidden { 66 | return NO; 67 | } 68 | 69 | - (UIStatusBarAnimation)preferredStatusBarUpdateAnimation { 70 | return UIStatusBarAnimationNone; 71 | } 72 | 73 | - (void)didReceiveMemoryWarning { 74 | [super didReceiveMemoryWarning]; 75 | // Dispose of any resources that can be recreated. 76 | } 77 | 78 | /* 79 | #pragma mark - Navigation 80 | 81 | // In a storyboard-based application, you will often want to do a little preparation before navigation 82 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 83 | // Get the new view controller using [segue destinationViewController]. 84 | // Pass the selected object to the new view controller. 85 | } 86 | */ 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_KDJView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_KDJView.h 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/21. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartProtocol.h" 11 | @interface Cocoa_KDJView : UIView 12 | 13 | /** 数据模型 */ 14 | @property (nonatomic,strong) NSMutableArray<__kindof Cocoa_ChartModel*> *dataArray; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_KDJView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_KDJView.m 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/21. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_KDJView.h" 10 | 11 | @interface Cocoa_KDJView() 12 | 13 | @property (nonatomic,strong) CAShapeLayer *kLineLayer; 14 | @property (nonatomic,strong) CAShapeLayer *dLineLayer; 15 | @property (nonatomic,strong) CAShapeLayer *jLineLayer; 16 | @property (nonatomic,strong) NSMutableArray *displayArray; 17 | 18 | @end 19 | 20 | @implementation Cocoa_KDJView 21 | 22 | - (void)initLayer 23 | { 24 | if (self.kLineLayer) { 25 | 26 | [self.kLineLayer removeFromSuperlayer]; 27 | self.kLineLayer = nil; 28 | } 29 | 30 | if (!self.kLineLayer) { 31 | self.kLineLayer = [CAShapeLayer layer]; 32 | self.kLineLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 33 | self.kLineLayer.lineWidth = 1; 34 | self.kLineLayer.lineCap = kCALineCapRound; 35 | self.kLineLayer.lineJoin = kCALineJoinRound; 36 | } 37 | [self.layer addSublayer:self.kLineLayer]; 38 | 39 | if (self.dLineLayer) { 40 | 41 | [self.dLineLayer removeFromSuperlayer]; 42 | self.dLineLayer = nil; 43 | } 44 | 45 | if (!self.dLineLayer) { 46 | self.dLineLayer = [CAShapeLayer layer]; 47 | self.dLineLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 48 | self.dLineLayer.lineCap = kCALineCapRound; 49 | self.dLineLayer.lineJoin = kCALineJoinRound; 50 | } 51 | 52 | [self.layer addSublayer:self.dLineLayer]; 53 | 54 | if (self.jLineLayer) { 55 | 56 | [self.jLineLayer removeFromSuperlayer]; 57 | self.jLineLayer = nil; 58 | } 59 | 60 | if (!self.jLineLayer) { 61 | 62 | self.jLineLayer = [CAShapeLayer layer]; 63 | self.jLineLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 64 | self.jLineLayer.lineWidth = 1; 65 | self.jLineLayer.lineCap = kCALineCapRound; 66 | self.jLineLayer.lineJoin = kCALineJoinRound; 67 | } 68 | [self.layer addSublayer:self.jLineLayer]; 69 | } 70 | 71 | // 刷新k线界面 72 | - (void)refreshChartView 73 | { 74 | [self.displayArray removeAllObjects]; 75 | 76 | NSInteger count = self.startIndex + self.displayCount <= self.dataArray.count?self.displayCount:self.displayCount -1; 77 | 78 | [self.displayArray addObjectsFromArray:[self.dataArray subarrayWithRange:NSMakeRange(self.startIndex,count)]]; 79 | 80 | [self calcuteMaxAndMinValue]; 81 | 82 | [CATransaction begin]; 83 | [CATransaction setDisableActions:YES]; 84 | [self initLayer]; 85 | [self drawChartView]; 86 | [CATransaction commit]; 87 | 88 | } 89 | 90 | // 计算最大最小值 91 | - (void)calcuteMaxAndMinValue 92 | { 93 | [self layoutIfNeeded]; 94 | self.maxValue = CGFLOAT_MIN; 95 | self.minValue = CGFLOAT_MAX; 96 | 97 | for (Cocoa_ChartModel *model in self.displayArray) { 98 | 99 | self.minValue = MIN(self.minValue, MIN(model.KValue, MIN(model.DValue, model.JValue))); 100 | self.maxValue = MAX(self.maxValue, MAX(model.KValue, MAX(model.DValue, model.JValue))); 101 | } 102 | 103 | if (self.maxValue - self.minValue < 0.000000005) { 104 | 105 | self.maxValue += 0.000000005; 106 | self.minValue += 0.000000005; 107 | } 108 | 109 | self.scaleValue = (CGRectGetHeight(self.frame) - self.padding.top - self.padding.bottom)/(self.maxValue - self.minValue); 110 | 111 | self.coordinateMaxValue = self.minValue - self.padding.bottom/self.scaleValue; 112 | 113 | self.coordinateminValue = CGRectGetHeight(self.frame)/self.scaleValue + self.coordinateminValue; 114 | } 115 | 116 | // 绘制k线 117 | - (void)drawChartView 118 | { 119 | UIBezierPath *kPath = [UIBezierPath bezierPath]; 120 | UIBezierPath *dPath = [UIBezierPath bezierPath]; 121 | UIBezierPath *jPath = [UIBezierPath bezierPath]; 122 | 123 | __weak typeof(self) weakSelf = self; 124 | [self.displayArray enumerateObjectsUsingBlock:^(Cocoa_ChartModel * model, NSUInteger idx, BOOL * _Nonnull stop) { 125 | __strong typeof(self) self = weakSelf; 126 | 127 | // 绘制 k d j 线 128 | CGFloat xPosition = self.leftPostion + ((self.candleWidth + self.candleSpace) * idx) + self.candleWidth/2 + self.padding.left; 129 | CGFloat yKPosition = ((self.maxValue - model.KValue) *self.scaleValue) + self.padding.top; 130 | 131 | CGFloat yDPosition = ((self.maxValue - model.DValue) *self.scaleValue) + self.padding.top; 132 | 133 | CGFloat yJPosition = ((self.maxValue - model.JValue) *self.scaleValue) + self.padding.top; 134 | 135 | if (idx == 0) 136 | { 137 | [kPath moveToPoint:CGPointMake(xPosition,yKPosition)]; 138 | [dPath moveToPoint:CGPointMake(xPosition,yDPosition)]; 139 | [jPath moveToPoint:CGPointMake(xPosition,yJPosition)]; 140 | } 141 | 142 | else 143 | { 144 | [kPath addLineToPoint:CGPointMake(xPosition,yKPosition)]; 145 | [dPath addLineToPoint:CGPointMake(xPosition,yDPosition)]; 146 | [jPath addLineToPoint:CGPointMake(xPosition,yJPosition)]; 147 | } 148 | 149 | 150 | }]; 151 | 152 | self.kLineLayer.path = kPath.CGPath; 153 | self.kLineLayer.strokeColor = [UIColor redColor].CGColor; 154 | self.kLineLayer.fillColor = [[UIColor clearColor] CGColor]; 155 | self.kLineLayer.contentsScale = [UIScreen mainScreen].scale; 156 | 157 | self.dLineLayer.path = dPath.CGPath; 158 | self.dLineLayer.strokeColor = [UIColor orangeColor].CGColor; 159 | self.dLineLayer.fillColor = [[UIColor clearColor] CGColor]; 160 | self.dLineLayer.contentsScale = [UIScreen mainScreen].scale; 161 | 162 | self.jLineLayer.path = jPath.CGPath; 163 | self.jLineLayer.strokeColor = [UIColor purpleColor].CGColor; 164 | self.jLineLayer.fillColor = [[UIColor clearColor] CGColor]; 165 | self.jLineLayer.contentsScale = [UIScreen mainScreen].scale; 166 | } 167 | 168 | #pragma mark - lazy 169 | - (NSMutableArray *)displayArray 170 | { 171 | if (!_displayArray) { 172 | 173 | _displayArray = [NSMutableArray array]; 174 | } 175 | 176 | return _displayArray; 177 | } 178 | 179 | - (NSMutableArray *)dataArray 180 | { 181 | if (!_dataArray) { 182 | 183 | _dataArray = [NSMutableArray array]; 184 | } 185 | 186 | return _dataArray; 187 | } 188 | 189 | @synthesize coordinateMaxValue; 190 | @synthesize coordinateminValue; 191 | @synthesize maxValue; 192 | @synthesize minValue; 193 | @synthesize padding; 194 | @synthesize scaleValue; 195 | @synthesize leftPostion; 196 | @synthesize startIndex; 197 | @synthesize displayCount; 198 | @synthesize candleWidth; 199 | @synthesize candleSpace; 200 | 201 | @end 202 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_KLine.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_KLine.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #ifndef Cocoa_KLine_h 10 | #define Cocoa_KLine_h 11 | 12 | /** 数据模型 */ 13 | #import "Cocoa_ChartModel.h" 14 | #import "Cocoa_ChartManager.h" 15 | 16 | /** 工具样式 */ 17 | #import "Cocoa_ChartProtocol.h" 18 | #import "Cocoa_CalculateCoordinate.h" 19 | #import "Cocoa_ChartStylesheet.h" 20 | 21 | /** 指标 */ 22 | #import "Cocoa_CandleLineView.h" 23 | #import "Cocoa_TecnnicalOptionsView.h" 24 | #import "Cocoa_TradingVolumeView.h" 25 | #import "Cocoa_MACDView.h" 26 | #import "Cocoa_OBVView.h" 27 | #import "Cocoa_KDJView.h" 28 | 29 | #endif /* Cocoa_KLine_h */ 30 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_MACDView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_MACDView.h 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/21. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartProtocol.h" 11 | #import "Cocoa_ChartModel.h" 12 | 13 | @interface Cocoa_MACDView : UIView 14 | 15 | @property (nonatomic,strong) NSMutableArray <__kindof Cocoa_ChartModel*>*dataArray; 16 | 17 | - (void)refreshChartView; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_MACDView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_MACDView.m 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/21. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_MACDView.h" 10 | #import "Cocoa_ChartStylesheet.h" 11 | @interface Cocoa_MACDView () 12 | 13 | @property (nonatomic,strong) NSMutableArray *displayArray; 14 | @property (nonatomic,strong) CAShapeLayer *macdLayer; 15 | 16 | @end 17 | 18 | @implementation Cocoa_MACDView 19 | 20 | - (void)refreshChartView 21 | { 22 | [self.displayArray removeAllObjects]; 23 | 24 | NSInteger count = self.startIndex + self.displayCount <= self.dataArray.count?self.displayCount:self.displayCount -1; 25 | 26 | [self.displayArray addObjectsFromArray:[self.dataArray subarrayWithRange:NSMakeRange(self.startIndex,count)]]; 27 | 28 | [self calcuteMaxAndMinValue]; 29 | 30 | [CATransaction begin]; 31 | [CATransaction setDisableActions:YES]; 32 | [self removeFromSubLayer]; 33 | [self drawChartView]; 34 | [CATransaction commit]; 35 | 36 | } 37 | 38 | - (void)calcuteMaxAndMinValue 39 | { 40 | CGFloat maxValue = 0; 41 | CGFloat minValue = 0; 42 | 43 | Cocoa_ChartModel *first = [self.displayArray objectAtIndex:0]; 44 | maxValue = MAX(first.dea, MAX(first.diff, first.macd)); 45 | minValue = MIN(first.dea, MIN(first.diff, first.macd)); 46 | 47 | for (NSInteger i = 1; i CGRectGetHeight(self.frame)) { 109 | diffPoint.y = CGRectGetHeight(self.frame); 110 | } 111 | if (deaPoint.y > CGRectGetHeight(self.frame)) { 112 | deaPoint.y = CGRectGetHeight(self.frame); 113 | } 114 | [deaPath moveToPoint:CGPointMake(diffPoint.x,diffPoint.y)]; 115 | [diffPath moveToPoint:CGPointMake(deaPoint.x,deaPoint.y)]; 116 | }else { 117 | 118 | if (diffPoint.y > CGRectGetHeight(self.frame)) { 119 | diffPoint.y = CGRectGetHeight(self.frame); 120 | } 121 | if (deaPoint.y > CGRectGetHeight(self.frame)) { 122 | deaPoint.y = CGRectGetHeight(self.frame); 123 | } 124 | [deaPath addLineToPoint:CGPointMake(diffPoint.x,diffPoint.y)]; 125 | [diffPath addLineToPoint:CGPointMake(deaPoint.x,deaPoint.y)]; 126 | } 127 | } 128 | 129 | CAShapeLayer *deaLayer = [CAShapeLayer layer]; 130 | deaLayer.path = deaPath.CGPath; 131 | deaLayer.strokeColor = [UIColor redColor].CGColor; 132 | deaLayer.fillColor = [[UIColor clearColor] CGColor]; 133 | deaLayer.contentsScale = [UIScreen mainScreen].scale; 134 | [self.macdLayer addSublayer:deaLayer]; 135 | 136 | CAShapeLayer *diffLayer = [CAShapeLayer layer]; 137 | diffLayer.path = diffPath.CGPath; 138 | diffLayer.strokeColor = [UIColor orangeColor].CGColor; 139 | diffLayer.fillColor = [[UIColor clearColor] CGColor]; 140 | diffLayer.contentsScale = [UIScreen mainScreen].scale; 141 | [self.macdLayer addSublayer:diffLayer]; 142 | } 143 | 144 | #pragma mark - drawLayer 145 | - (void)removeFromSubLayer 146 | { 147 | for (NSInteger i = 0 ; i < self.macdLayer.sublayers.count; i++) { 148 | 149 | CAShapeLayer *layer = (CAShapeLayer*)self.macdLayer.sublayers[i]; 150 | [layer removeFromSuperlayer]; 151 | layer = nil; 152 | } 153 | 154 | [self.macdLayer removeFromSuperlayer]; 155 | 156 | self.macdLayer = nil; 157 | 158 | [self.layer addSublayer:self.macdLayer]; 159 | } 160 | 161 | - (void)drawMacdLayermacdstartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint macdModel:(Cocoa_ChartModel *)macdModel 162 | { 163 | CGRect rect = CGRectZero; 164 | CGFloat y = self.maxValue*self.scaleValue + self.padding.top; 165 | 166 | if (macdModel.macd > 0) { 167 | 168 | rect = CGRectMake(startPoint.x, endPoint.y, self.candleWidth, ABS(y - endPoint.y)); 169 | 170 | }else { 171 | 172 | rect = CGRectMake(startPoint.x,y, self.candleWidth, ABS(endPoint.y - startPoint.y)); 173 | } 174 | 175 | UIBezierPath *path = [UIBezierPath bezierPathWithRect:rect]; 176 | CAShapeLayer *subLayer = [CAShapeLayer layer]; 177 | subLayer.path = path.CGPath; 178 | 179 | if (macdModel.macd > 0) { 180 | subLayer.strokeColor = COLOR_RISECOLOR.CGColor; 181 | subLayer.fillColor = COLOR_RISECOLOR.CGColor; 182 | } else { 183 | subLayer.strokeColor = COLOR_FALLCOLOR.CGColor; 184 | subLayer.fillColor = COLOR_FALLCOLOR.CGColor; 185 | } 186 | 187 | [self.macdLayer addSublayer:subLayer]; 188 | } 189 | 190 | #pragma mark lazyLoad 191 | 192 | - (NSMutableArray *)dataArray 193 | { 194 | if (!_dataArray) { 195 | 196 | _dataArray = [NSMutableArray array]; 197 | } 198 | 199 | return _dataArray; 200 | } 201 | 202 | - (NSMutableArray*)displayArray 203 | { 204 | if (!_displayArray) { 205 | 206 | _displayArray = [NSMutableArray array]; 207 | } 208 | return _displayArray; 209 | } 210 | 211 | - (CAShapeLayer*)macdLayer 212 | { 213 | if (!_macdLayer) { 214 | 215 | _macdLayer = [CAShapeLayer layer]; 216 | _macdLayer.lineWidth = 1; 217 | _macdLayer.strokeColor = [UIColor clearColor].CGColor; 218 | _macdLayer.fillColor = [UIColor clearColor].CGColor; 219 | } 220 | return _macdLayer; 221 | } 222 | 223 | @synthesize coordinateMaxValue; 224 | @synthesize coordinateminValue; 225 | @synthesize maxValue; 226 | @synthesize minValue; 227 | @synthesize padding; 228 | @synthesize scaleValue; 229 | @synthesize leftPostion; 230 | @synthesize startIndex; 231 | @synthesize displayCount; 232 | @synthesize candleWidth; 233 | @synthesize candleSpace; 234 | 235 | @end 236 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_OBVView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_OBVView.h 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/21. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartProtocol.h" 11 | @interface Cocoa_OBVView : UIView 12 | 13 | @property (nonatomic,strong) NSMutableArray <__kindof Cocoa_ChartModel*>*dataArray; 14 | 15 | - (void)refreshChartView; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_OBVView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_OBVView.m 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/21. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_OBVView.h" 10 | 11 | @interface Cocoa_OBVView() 12 | 13 | @property (nonatomic,strong) NSMutableArray *displayArray; 14 | @property (nonatomic,strong) CAShapeLayer *obvLineLayer; 15 | 16 | @end 17 | 18 | @implementation Cocoa_OBVView 19 | 20 | - (void)initLayer 21 | { 22 | if (self.obvLineLayer) 23 | { 24 | [self.obvLineLayer removeFromSuperlayer]; 25 | self.obvLineLayer = nil; 26 | } 27 | 28 | if (!self.obvLineLayer) { 29 | 30 | self.obvLineLayer = [CAShapeLayer layer]; 31 | self.obvLineLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 32 | self.obvLineLayer.lineWidth = 1; 33 | self.obvLineLayer.lineCap = kCALineCapRound; 34 | self.obvLineLayer.lineJoin = kCALineJoinRound; 35 | } 36 | [self.layer addSublayer:self.obvLineLayer]; 37 | } 38 | 39 | - (void)refreshChartView 40 | { 41 | [self.displayArray removeAllObjects]; 42 | 43 | NSInteger count = self.startIndex + self.displayCount <= self.dataArray.count?self.displayCount:self.displayCount -1; 44 | 45 | [self.displayArray addObjectsFromArray:[self.dataArray subarrayWithRange:NSMakeRange(self.startIndex,count)]]; 46 | 47 | [self calcuteMaxAndMinValue]; 48 | 49 | [CATransaction begin]; 50 | [CATransaction setDisableActions:YES]; 51 | [self initLayer]; 52 | [self drawChartView]; 53 | [CATransaction commit]; 54 | } 55 | 56 | // 计算最大最小值 57 | - (void)calcuteMaxAndMinValue 58 | { 59 | [self layoutIfNeeded]; 60 | self.maxValue = CGFLOAT_MIN; 61 | self.minValue = CGFLOAT_MAX; 62 | 63 | for (Cocoa_ChartModel *model in self.displayArray) { 64 | 65 | self.maxValue = MAX(self.maxValue, model.OBVValue); 66 | self.minValue = MIN(self.minValue, model.OBVValue); 67 | } 68 | 69 | self.scaleValue = (CGRectGetHeight(self.frame) - self.padding.top - self.padding.bottom)/(self.maxValue - self.minValue); 70 | 71 | self.coordinateMaxValue = self.minValue - self.padding.bottom/self.scaleValue; 72 | 73 | self.coordinateminValue = CGRectGetHeight(self.frame)/self.scaleValue + self.coordinateminValue; 74 | } 75 | 76 | // 绘制k线 77 | - (void)drawChartView 78 | { 79 | UIBezierPath *obvPath = [UIBezierPath bezierPath]; 80 | 81 | __weak typeof(self) weakSelf = self; 82 | [self.displayArray enumerateObjectsUsingBlock:^(Cocoa_ChartModel *model, NSUInteger idx, BOOL * _Nonnull stop) { 83 | __strong typeof(self) self = weakSelf; 84 | 85 | CGFloat xPosition = self.leftPostion + ((self.candleWidth + self.candleSpace) * idx) + self.candleWidth/2; 86 | CGFloat yPosition = ((self.maxValue - model.OBVValue)*self.scaleValue) + self.padding.top; 87 | 88 | if (idx == 0) { 89 | 90 | [obvPath moveToPoint:CGPointMake(xPosition, yPosition)]; 91 | }else { 92 | 93 | [obvPath addLineToPoint:CGPointMake(xPosition, yPosition)]; 94 | } 95 | }]; 96 | 97 | self.obvLineLayer.path = obvPath.CGPath; 98 | self.obvLineLayer.strokeColor = [UIColor redColor].CGColor; 99 | self.obvLineLayer.fillColor = [[UIColor clearColor] CGColor]; 100 | self.obvLineLayer.contentsScale = [UIScreen mainScreen].scale; 101 | } 102 | 103 | #pragma mark - layz 104 | - (NSMutableArray *)dataArray 105 | { 106 | if (!_dataArray) { 107 | 108 | _dataArray = [NSMutableArray array]; 109 | } 110 | 111 | return _dataArray; 112 | } 113 | 114 | - (NSMutableArray *)displayArray 115 | { 116 | if (!_displayArray) { 117 | 118 | _displayArray = [NSMutableArray array]; 119 | } 120 | 121 | return _displayArray; 122 | } 123 | 124 | @synthesize coordinateMaxValue; 125 | @synthesize coordinateminValue; 126 | @synthesize maxValue; 127 | @synthesize minValue; 128 | @synthesize padding; 129 | @synthesize scaleValue; 130 | @synthesize leftPostion; 131 | @synthesize startIndex; 132 | @synthesize displayCount; 133 | @synthesize candleWidth; 134 | @synthesize candleSpace; 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_TecnnicalOptionsView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_TecnnicalOptionsView.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/1. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartProtocol.h" 11 | 12 | typedef void(^TecnnicalTypeBlock)(TecnnicalType tecnnicalType); 13 | 14 | @interface Cocoa_TecnnicalOptionsView : UIView 15 | @property (nonatomic, strong) NSArray *optionArray; 16 | @property (nonatomic, assign) TecnnicalType tecnnicalType; 17 | @property (nonatomic, copy) TecnnicalTypeBlock tecnnicalTypeBlock; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_TecnnicalOptionsView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_TecnnicalOptionsView.m 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/1. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_TecnnicalOptionsView.h" 10 | #import "Cocoa_ChartStylesheet.h" 11 | @interface Cocoa_TecnnicalOptionsView () 12 | 13 | @property (nonatomic, strong) UIButton *lastBtn; 14 | 15 | @end 16 | 17 | @implementation Cocoa_TecnnicalOptionsView 18 | 19 | - (instancetype)init 20 | { 21 | self = [super init]; 22 | 23 | if (self) { 24 | 25 | self.backgroundColor = COLOR_BACKGROUND; 26 | _optionArray = @[@"VOL", @"MACD", @"KDJ", @"OBV", @"WR"]; 27 | [self setup]; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | - (void)setup 34 | { 35 | CGFloat gap = 5; 36 | CGFloat btnWidth = (kSCREENWIDTH - (_optionArray.count + 1) * gap)/_optionArray.count; 37 | 38 | [_optionArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 39 | 40 | dispatch_async(dispatch_get_main_queue(), ^{ 41 | 42 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 43 | button.tag = 100 + idx; 44 | button.frame = CGRectMake(gap + idx*(gap + btnWidth), 0, btnWidth, CGRectGetHeight(self.frame)); 45 | [button setTitle:self->_optionArray[idx] forState:UIControlStateNormal]; 46 | button.titleLabel.font = [UIFont systemFontOfSize:14]; 47 | [button setTitleColor:COLOR_COORDINATETEXT forState:UIControlStateNormal]; 48 | [button setTitleColor:COLOR_WARNINTEXT forState:UIControlStateSelected]; 49 | [button addTarget:self action:@selector(changeTecnnicalView:) forControlEvents:UIControlEventTouchUpInside]; 50 | [self addSubview:button]; 51 | 52 | if (idx == 0) { 53 | self.lastBtn = button; 54 | self.lastBtn.selected = YES; 55 | } 56 | }); 57 | }]; 58 | } 59 | //@[@"VOL", @"MACD", @"KDJ", @"OBV", @"RSI", @"WR"]; 60 | - (void)changeTecnnicalView:(UIButton *)btn 61 | { 62 | if ([self.lastBtn isEqual:btn]) { 63 | return; 64 | } 65 | self.lastBtn.selected = NO; 66 | btn.selected = YES; 67 | self.lastBtn = btn; 68 | 69 | NSString *tecnnicalStr = _optionArray[btn.tag - 100]; 70 | 71 | if ([tecnnicalStr isEqualToString:@"VOL"]) { 72 | 73 | self.tecnnicalType = TecnnicalType_VOL; 74 | }else if ([tecnnicalStr isEqualToString:@"MACD"]) { 75 | 76 | self.tecnnicalType = TecnnicalType_MACD; 77 | }else if ([tecnnicalStr isEqualToString:@"KDJ"]) { 78 | 79 | self.tecnnicalType = TecnnicalType_KDJ; 80 | }else if ([tecnnicalStr isEqualToString:@"OBV"]) { 81 | 82 | self.tecnnicalType = TecnnicalType_OBV; 83 | }else if ([tecnnicalStr isEqualToString:@"WR"]) { 84 | 85 | self.tecnnicalType = TecnnicalType_WR; 86 | } 87 | 88 | if (self.tecnnicalTypeBlock) { 89 | 90 | self.tecnnicalTypeBlock(self.tecnnicalType); 91 | } 92 | } 93 | 94 | /* 95 | // Only override drawRect: if you perform custom drawing. 96 | // An empty implementation adversely affects performance during animation. 97 | - (void)drawRect:(CGRect)rect { 98 | // Drawing code 99 | } 100 | */ 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_TecnnicalView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_TecnnicalView.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/1. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Cocoa_TecnnicalView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_TecnnicalView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_TecnnicalView.m 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/8/1. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_TecnnicalView.h" 10 | 11 | @implementation Cocoa_TecnnicalView 12 | 13 | - (instancetype)init 14 | { 15 | self = [super init]; 16 | 17 | if (self) { 18 | 19 | } 20 | 21 | return self; 22 | } 23 | 24 | /* 25 | // Only override drawRect: if you perform custom drawing. 26 | // An empty implementation adversely affects performance during animation. 27 | - (void)drawRect:(CGRect)rect { 28 | // Drawing code 29 | } 30 | */ 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_TradingVolumeView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_TradingVolumeView.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Cocoa_ChartProtocol.h" 11 | 12 | @interface Cocoa_TradingVolumeView : UIView 13 | 14 | /** 数据模型 */ 15 | @property (nonatomic,strong) NSMutableArray<__kindof Cocoa_ChartModel*> *dataArray; 16 | 17 | - (void)refreshChartView; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_TradingVolumeView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_TradingVolumeView.m 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_TradingVolumeView.h" 10 | #import "Cocoa_ChartStylesheet.h" 11 | 12 | @interface Cocoa_TradingVolumeView () 13 | 14 | /** 涨跌幅k线 */ 15 | @property (nonatomic,strong) CAShapeLayer *advancesLayer; 16 | 17 | @property (nonatomic,strong) CAShapeLayer *declinesLayer; 18 | 19 | @property (nonatomic,strong) NSMutableArray *displayArray; 20 | 21 | @property (nonatomic, assign) StockStyleState stockState; 22 | 23 | @end 24 | 25 | @implementation Cocoa_TradingVolumeView 26 | 27 | - (instancetype)init 28 | { 29 | self = [super init]; 30 | 31 | if (self) { 32 | 33 | [self.layer addSublayer:self.advancesLayer]; 34 | [self.layer addSublayer:self.declinesLayer]; 35 | } 36 | 37 | return self; 38 | } 39 | 40 | - (void)refreshChartView 41 | { 42 | [self.displayArray removeAllObjects]; 43 | 44 | NSInteger count = self.startIndex + self.displayCount <=self.dataArray.count?self.displayCount:self.displayCount -1; 45 | 46 | [self.displayArray addObjectsFromArray:[self.dataArray subarrayWithRange:NSMakeRange(self.startIndex,count)]]; 47 | 48 | [self drawRectVolumeView]; 49 | } 50 | 51 | - (void)clearChartView 52 | { 53 | [self.advancesLayer removeFromSuperlayer]; 54 | self.advancesLayer = nil; 55 | [self.declinesLayer removeFromSuperlayer]; 56 | self.declinesLayer = nil; 57 | [self.layer addSublayer:self.advancesLayer]; 58 | [self.layer addSublayer:self.declinesLayer]; 59 | } 60 | 61 | - (void)drawRectVolumeView 62 | { 63 | [self layoutIfNeeded]; 64 | 65 | [self calcuteMaxAndMinValue]; 66 | 67 | [self drawTradingVolumeLayer]; 68 | } 69 | 70 | - (void)calcuteMaxAndMinValue 71 | { 72 | CGFloat maxVolum = CGFLOAT_MIN; 73 | CGFloat minVolum = CGFLOAT_MAX; 74 | 75 | for (NSInteger i = 0;i 10 | #import "Cocoa_ChartProtocol.h" 11 | 12 | @interface Cocoa_WRView : UIView 13 | 14 | @property (nonatomic,strong) NSMutableArray <__kindof Cocoa_ChartModel*>*dataArray; 15 | 16 | - (void)refreshChartView; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/Cocoa_WRView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_WRView.m 3 | // PurCowExchange 4 | // 5 | // Created by Yochi on 2018/8/22. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "Cocoa_WRView.h" 10 | 11 | @interface Cocoa_WRView () 12 | 13 | @property (nonatomic,strong) NSMutableArray *displayArray; 14 | @property (nonatomic,strong) CAShapeLayer *wrLineLayer; 15 | 16 | @end 17 | 18 | @implementation Cocoa_WRView 19 | 20 | - (void)initLayer 21 | { 22 | if (self.wrLineLayer) { 23 | 24 | [self.wrLineLayer removeFromSuperlayer]; 25 | self.wrLineLayer = nil; 26 | } 27 | 28 | if (!self.wrLineLayer) { 29 | 30 | self.wrLineLayer = [CAShapeLayer layer]; 31 | self.wrLineLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 32 | self.wrLineLayer.lineWidth = 1; 33 | self.wrLineLayer.lineCap = kCALineCapRound; 34 | self.wrLineLayer.lineJoin = kCALineJoinRound; 35 | } 36 | [self.layer addSublayer:self.wrLineLayer]; 37 | } 38 | 39 | // 刷新k线界面 40 | - (void)refreshChartView 41 | { 42 | [self.displayArray removeAllObjects]; 43 | 44 | NSInteger count = self.startIndex + self.displayCount <= self.dataArray.count?self.displayCount:self.displayCount -1; 45 | 46 | [self.displayArray addObjectsFromArray:[self.dataArray subarrayWithRange:NSMakeRange(self.startIndex,count)]]; 47 | 48 | [self calcuteMaxAndMinValue]; 49 | 50 | [CATransaction begin]; 51 | [CATransaction setDisableActions:YES]; 52 | [self initLayer]; 53 | [self drawChartView]; 54 | [CATransaction commit]; 55 | } 56 | 57 | // 计算最大最小值 58 | - (void)calcuteMaxAndMinValue 59 | { 60 | [self layoutIfNeeded]; 61 | self.maxValue = CGFLOAT_MIN; 62 | self.minValue = CGFLOAT_MAX; 63 | 64 | for (Cocoa_ChartModel *model in self.displayArray) { 65 | 66 | self.maxValue = MAX(self.maxValue, model.WRValue); 67 | self.minValue = MIN(self.minValue, model.WRValue); 68 | } 69 | 70 | self.scaleValue = (CGRectGetHeight(self.frame) - self.padding.top - self.padding.bottom)/(self.maxValue - self.minValue); 71 | 72 | self.coordinateminValue = self.minValue - self.padding.bottom/self.scaleValue; 73 | 74 | self.coordinateMaxValue = CGRectGetHeight(self.frame)/self.scaleValue + self.coordinateminValue; 75 | } 76 | 77 | // 绘制k线 78 | - (void)drawChartView 79 | { 80 | UIBezierPath *wrPath = [UIBezierPath bezierPath]; 81 | 82 | __weak typeof(self) weakSelf = self; 83 | [self.displayArray enumerateObjectsUsingBlock:^(Cocoa_ChartModel *model, NSUInteger idx, BOOL * _Nonnull stop) { 84 | __strong typeof(self) self = weakSelf; 85 | 86 | CGFloat xPosition = self.leftPostion + ((self.candleWidth + self.candleSpace) * idx) + self.candleWidth/2; 87 | CGFloat yPosition = ((self.maxValue - model.WRValue)*self.scaleValue) + self.padding.top; 88 | 89 | if (idx == 0) { 90 | 91 | [wrPath moveToPoint:CGPointMake(xPosition, yPosition)]; 92 | }else { 93 | 94 | [wrPath addLineToPoint:CGPointMake(xPosition, yPosition)]; 95 | } 96 | }]; 97 | 98 | self.wrLineLayer.path = wrPath.CGPath; 99 | self.wrLineLayer.strokeColor = [UIColor redColor].CGColor; 100 | self.wrLineLayer.fillColor = [[UIColor clearColor] CGColor]; 101 | self.wrLineLayer.contentsScale = [UIScreen mainScreen].scale; 102 | } 103 | 104 | #pragma mark - layz 105 | 106 | - (NSMutableArray *)dataArray 107 | { 108 | if (!_dataArray) { 109 | 110 | _dataArray = [NSMutableArray array]; 111 | } 112 | 113 | return _dataArray; 114 | } 115 | 116 | - (NSMutableArray *)displayArray 117 | { 118 | if (!_displayArray) { 119 | _displayArray = [NSMutableArray array]; 120 | } 121 | 122 | return _displayArray; 123 | } 124 | 125 | @synthesize coordinateMaxValue; 126 | @synthesize coordinateminValue; 127 | @synthesize maxValue; 128 | @synthesize minValue; 129 | @synthesize padding; 130 | @synthesize scaleValue; 131 | @synthesize leftPostion; 132 | @synthesize startIndex; 133 | @synthesize displayCount; 134 | @synthesize candleWidth; 135 | @synthesize candleSpace; 136 | 137 | @end 138 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/include/ta_common.h: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | #ifndef TA_COMMON_H 34 | #define TA_COMMON_H 35 | 36 | /* The following macros are used to return internal errors. 37 | * The Id can be from 1 to 999 and translate to the user 38 | * as the return code 5000 to 5999. 39 | * 40 | * Everytime you wish to add a new fatal error code, 41 | * use the "NEXT AVAILABLE NUMBER" and increment the 42 | * number in this file. 43 | * 44 | * NEXT AVAILABLE NUMBER: 181 45 | */ 46 | #define TA_INTERNAL_ERROR(Id) ((TA_RetCode)(TA_INTERNAL_ERROR+Id)) 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | #include 53 | #include 54 | #include 55 | 56 | #ifndef TA_DEFS_H 57 | #include "ta_defs.h" 58 | #endif 59 | 60 | /* Some functions to get the version of TA-Lib. 61 | * 62 | * Format is "Major.Minor.Patch (Month Day Year Hour:Min:Sec)" 63 | * 64 | * Example: "1.2.0 (Jan 17 2004 23:59:59)" 65 | * 66 | * Major increments indicates an "Highly Recommended" update. 67 | * 68 | * Minor increments indicates arbitrary milestones in the 69 | * development of the next major version. 70 | * 71 | * Patch are fixes to a "Major.Minor" release. 72 | */ 73 | const char *TA_GetVersionString( void ); 74 | 75 | /* Get individual component of the Version string */ 76 | const char *TA_GetVersionMajor ( void ); 77 | const char *TA_GetVersionMinor ( void ); 78 | const char *TA_GetVersionBuild ( void ); 79 | const char *TA_GetVersionDate ( void ); 80 | const char *TA_GetVersionTime ( void ); 81 | 82 | /* Misc. declaration used throughout the library code. */ 83 | typedef double TA_Real; 84 | typedef int TA_Integer; 85 | 86 | /* General purpose structure containing an array of string. 87 | * 88 | * Example of usage: 89 | * void printStringTable( TA_StringTable *table ) 90 | * { 91 | * int i; 92 | * for( i=0; i < table->size; i++ ) 93 | * cout << table->string[i] << endl; 94 | * } 95 | * 96 | */ 97 | typedef struct TA_StringTable 98 | { 99 | unsigned int size; /* Number of string. */ 100 | const char **string; /* Pointer to the strings. */ 101 | 102 | /* Hidden data for internal use by TA-Lib. Do not modify. */ 103 | void *hiddenData; 104 | } TA_StringTable; 105 | /* End-user can get additional information related to a TA_RetCode. 106 | * 107 | * Example: 108 | * TA_RetCodeInfo info; 109 | * 110 | * retCode = TA_Initialize( ... ); 111 | * 112 | * if( retCode != TA_SUCCESS ) 113 | * { 114 | * TA_SetRetCodeInfo( retCode, &info ); 115 | * printf( "Error %d(%s): %s\n", 116 | * retCode, 117 | * info.enumStr, 118 | * info.infoStr ); 119 | * } 120 | * 121 | * Would display: 122 | * "Error 1(TA_LIB_NOT_INITIALIZE): TA_Initialize was not sucessfully called" 123 | */ 124 | typedef struct TA_RetCodeInfo 125 | { 126 | const char *enumStr; /* Like "TA_IP_SOCKETERROR" */ 127 | const char *infoStr; /* Like "Error creating socket" */ 128 | } TA_RetCodeInfo; 129 | 130 | /* Info is always returned, even when 'theRetCode' is invalid. */ 131 | void TA_SetRetCodeInfo( TA_RetCode theRetCode, TA_RetCodeInfo *retCodeInfo ); 132 | 133 | /* TA_Initialize() initialize the ressources used by TA-Lib. This 134 | * function must be called once prior to any other functions declared in 135 | * this file. 136 | * 137 | * TA_Shutdown() allows to free all ressources used by TA-Lib. Following 138 | * a shutdown, TA_Initialize() must be called again for re-using TA-Lib. 139 | * 140 | * TA_Shutdown() should be called prior to exiting the application code. 141 | */ 142 | TA_RetCode TA_Initialize( void ); 143 | TA_RetCode TA_Shutdown( void ); 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/include/ta_libc.h: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | #ifndef TA_LIBC_H 34 | #define TA_LIBC_H 35 | 36 | /* Includes all headers needed for using the ta-lib 'C' library. */ 37 | 38 | #ifndef TA_COMMON_H 39 | #include "ta_common.h" 40 | #endif 41 | 42 | #ifndef TA_FUNC_H 43 | #include "ta_func.h" 44 | #endif 45 | 46 | #ifndef TA_ABSTRACT_H 47 | #include "ta_abstract.h" 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_common/ta_global.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * AC Angelo Ciceri 40 | * 41 | * 42 | * Change history: 43 | * 44 | * MMDDYY BY Description 45 | * ------------------------------------------------------------------- 46 | * 112400 MF First version. 47 | * 082004 AC Add TA_SetCandleSettings, TA_RestoreCandleDefaultSettings 48 | * and call to TA_RestoreCandleDefaultSettings in TA_Initialize 49 | * 041106 MF Add prefix to theGlobals to avoid clash with other libs. 50 | * 040707 MF Change global initialization to eliminate Mac OS X link error. 51 | */ 52 | 53 | /* Description: 54 | * Provides initialization / shutdown functionality for all modules. 55 | */ 56 | 57 | /**** Headers ****/ 58 | #include 59 | #include 60 | #include 61 | 62 | #include "ta_common.h" 63 | #include "ta_magic_nb.h" 64 | #include "ta_global.h" 65 | #include "ta_func.h" 66 | 67 | /**** External functions declarations. ****/ 68 | /* None */ 69 | 70 | /**** External variables declarations. ****/ 71 | /* None */ 72 | 73 | /**** Global variables definitions. ****/ 74 | 75 | /* The entry point for all globals */ 76 | TA_LibcPriv ta_theGlobals = {0,{{0,0,0}},0,0,0,0,(TA_Compatibility)0,{0},{{(TA_CandleSettingType)0,(TA_RangeType)0,0,0}}}; 77 | 78 | TA_LibcPriv *TA_Globals = &ta_theGlobals; 79 | 80 | /**** Local declarations. ****/ 81 | /* None */ 82 | 83 | /**** Local functions declarations. ****/ 84 | /* None */ 85 | 86 | /**** Local variables definitions. ****/ 87 | /* None */ 88 | 89 | /**** Global functions definitions. ****/ 90 | TA_RetCode TA_Initialize( void ) 91 | { 92 | /* Initialize the "global variable" used to manage the global 93 | * variables of all other modules... 94 | */ 95 | memset( TA_Globals, 0, sizeof( TA_LibcPriv ) ); 96 | TA_Globals->magicNb = TA_LIBC_PRIV_MAGIC_NB; 97 | 98 | /*** At this point, TA_Shutdown can be called to clean-up. ***/ 99 | 100 | /* Set the default value to global variables */ 101 | TA_RestoreCandleDefaultSettings( TA_AllCandleSettings ); 102 | 103 | return TA_SUCCESS; 104 | } 105 | 106 | TA_RetCode TA_Shutdown( void ) 107 | { 108 | if( TA_Globals->magicNb != TA_LIBC_PRIV_MAGIC_NB ) 109 | return TA_LIB_NOT_INITIALIZE; 110 | 111 | /* Initialize to all zero to make sure we invalidate that object. */ 112 | memset( TA_Globals, 0, sizeof( TA_LibcPriv ) ); 113 | 114 | return TA_SUCCESS; 115 | } 116 | 117 | TA_RetCode TA_SetCandleSettings( TA_CandleSettingType settingType, 118 | TA_RangeType rangeType, 119 | int avgPeriod, 120 | double factor ) 121 | { 122 | /*printf("setcdlset:%d ",settingType);*/ 123 | if( settingType >= TA_AllCandleSettings ) 124 | return TA_BAD_PARAM; 125 | TA_Globals->candleSettings[settingType].settingType = settingType; 126 | TA_Globals->candleSettings[settingType].rangeType = rangeType; 127 | TA_Globals->candleSettings[settingType].avgPeriod = avgPeriod; 128 | TA_Globals->candleSettings[settingType].factor = factor; 129 | /*printf("cdlset: %d %d %d %f\n",TA_Globals->candleSettings[settingType].settingType,TA_Globals->candleSettings[settingType].rangeType, 130 | TA_Globals->candleSettings[settingType].avgPeriod,TA_Globals->candleSettings[settingType].factor);*/ 131 | return TA_SUCCESS; 132 | } 133 | 134 | TA_RetCode TA_RestoreCandleDefaultSettings( TA_CandleSettingType settingType ) 135 | { 136 | const TA_CandleSetting TA_CandleDefaultSettings[] = { 137 | /* real body is long when it's longer than the average of the 10 previous candles' real body */ 138 | { TA_BodyLong, TA_RangeType_RealBody, 10, 1.0 }, 139 | /* real body is very long when it's longer than 3 times the average of the 10 previous candles' real body */ 140 | { TA_BodyVeryLong, TA_RangeType_RealBody, 10, 3.0 }, 141 | /* real body is short when it's shorter than the average of the 10 previous candles' real bodies */ 142 | { TA_BodyShort, TA_RangeType_RealBody, 10, 1.0 }, 143 | /* real body is like doji's body when it's shorter than 10% the average of the 10 previous candles' high-low range */ 144 | { TA_BodyDoji, TA_RangeType_HighLow, 10, 0.1 }, 145 | /* shadow is long when it's longer than the real body */ 146 | { TA_ShadowLong, TA_RangeType_RealBody, 0, 1.0 }, 147 | /* shadow is very long when it's longer than 2 times the real body */ 148 | { TA_ShadowVeryLong, TA_RangeType_RealBody, 0, 2.0 }, 149 | /* shadow is short when it's shorter than half the average of the 10 previous candles' sum of shadows */ 150 | { TA_ShadowShort, TA_RangeType_Shadows, 10, 1.0 }, 151 | /* shadow is very short when it's shorter than 10% the average of the 10 previous candles' high-low range */ 152 | { TA_ShadowVeryShort, TA_RangeType_HighLow, 10, 0.1 }, 153 | /* when measuring distance between parts of candles or width of gaps */ 154 | /* "near" means "<= 20% of the average of the 5 previous candles' high-low range" */ 155 | { TA_Near, TA_RangeType_HighLow, 5, 0.2 }, 156 | /* when measuring distance between parts of candles or width of gaps */ 157 | /* "far" means ">= 60% of the average of the 5 previous candles' high-low range" */ 158 | { TA_Far, TA_RangeType_HighLow, 5, 0.6 }, 159 | /* when measuring distance between parts of candles or width of gaps */ 160 | /* "equal" means "<= 5% of the average of the 5 previous candles' high-low range" */ 161 | { TA_Equal, TA_RangeType_HighLow, 5, 0.05 } 162 | }; 163 | 164 | int i; 165 | if( settingType > TA_AllCandleSettings ) 166 | return TA_BAD_PARAM; 167 | if( settingType == TA_AllCandleSettings ) 168 | for( i = 0; i < TA_AllCandleSettings; ++i ) 169 | TA_Globals->candleSettings[i] = TA_CandleDefaultSettings[i]; 170 | else 171 | TA_Globals->candleSettings[settingType] = TA_CandleDefaultSettings[settingType]; 172 | return TA_SUCCESS; 173 | } 174 | 175 | /**** Local functions definitions. ****/ 176 | /* None */ 177 | 178 | 179 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_common/ta_global.h: -------------------------------------------------------------------------------- 1 | #ifndef TA_GLOBAL_H 2 | #define TA_GLOBAL_H 3 | 4 | #ifndef TA_COMMON_H 5 | #include "ta_common.h" 6 | #endif 7 | 8 | #ifndef TA_FUNC_H 9 | #include "ta_func.h" 10 | #endif 11 | 12 | /* TA_CandleSetting is the one setting struct */ 13 | typedef struct { 14 | TA_CandleSettingType settingType; 15 | TA_RangeType rangeType; 16 | int avgPeriod; 17 | double factor; 18 | } TA_CandleSetting; 19 | 20 | /* This interface is used exclusively INTERNALY to the TA-LIB. 21 | * There is nothing for the end-user here ;-> 22 | */ 23 | 24 | /* Provides functionality for managing global ressource 25 | * throughout the TA-LIB. 26 | * 27 | * Since not all module are used/link in the application, 28 | * the ta_common simply provides the mechanism for the module 29 | * to optionnaly "register" its initialization/shutdown 30 | * function. 31 | * 32 | * A function shall access its global variable by calling 33 | * TA_GetGlobal. This function will appropriatly call the 34 | * initialization function if its global are not yet initialized. 35 | * 36 | * The call of the init and shutdown function are guaranteed 37 | * to be multithread protected. It is also guarantee that 38 | * these function will always get called in alternance (in 39 | * other word, following an initialization only a shutdown 40 | * can get called). 41 | */ 42 | 43 | typedef enum 44 | { 45 | /* Module will be shutdown in the order specified here. */ 46 | 47 | TA_ABSTRACTION_GLOBAL_ID, 48 | TA_FUNC_GLOBAL_ID, 49 | TA_MEMORY_GLOBAL_ID, /* Must be last. */ 50 | TA_NB_GLOBAL_ID 51 | } TA_GlobalModuleId; 52 | 53 | typedef TA_RetCode (*TA_GlobalInitFunc) ( void **globalToAlloc ); 54 | typedef TA_RetCode (*TA_GlobalShutdownFunc)( void *globalAllocated ); 55 | 56 | typedef struct 57 | { 58 | const TA_GlobalModuleId id; 59 | const TA_GlobalInitFunc init; 60 | const TA_GlobalShutdownFunc shutdown; 61 | } TA_GlobalControl; 62 | 63 | TA_RetCode TA_GetGlobal( const TA_GlobalControl * const control, 64 | void **global ); 65 | 66 | /* Occasionaly, code tracing must be disable. 67 | * Example: 68 | * - The memory module needs to know if the tracing is 69 | * still enabled or not when freeing memory on shutdown. 70 | * - We do not want to recursively trace while the tracing 71 | * function themselves gets called ;-> 72 | */ 73 | int TA_IsTraceEnabled( void ); 74 | void TA_TraceEnable ( void ); 75 | void TA_TraceDisable ( void ); 76 | 77 | /* If enabled by the user, use a local drive 78 | * for configuration and/or temporary file. 79 | * TA-LIB must NEVER assume such local drive 80 | * is available. 81 | */ 82 | const char *TA_GetLocalCachePath( void ); 83 | 84 | typedef struct 85 | { 86 | unsigned int initialize; 87 | const TA_GlobalControl * control; 88 | void *global; 89 | } TA_ModuleControl; 90 | 91 | /* This is the hidden implementation of TA_Libc. */ 92 | typedef struct 93 | { 94 | unsigned int magicNb; /* Unique identifier of this object. */ 95 | TA_ModuleControl moduleControl[TA_NB_GLOBAL_ID]; 96 | 97 | unsigned int traceEnabled; 98 | unsigned int stdioEnabled; 99 | FILE *stdioFile; 100 | 101 | const char *localCachePath; 102 | 103 | /* For handling the compatibility with other software */ 104 | TA_Compatibility compatibility; 105 | 106 | /* For handling the unstable period of some TA function. */ 107 | unsigned int unstablePeriod[TA_FUNC_UNST_ALL]; 108 | 109 | /* For handling the candlestick global settings */ 110 | TA_CandleSetting candleSettings[TA_AllCandleSettings]; 111 | 112 | } TA_LibcPriv; 113 | 114 | /* The following global is used all over the place 115 | * and is the entry point for all other globals. 116 | */ 117 | extern TA_LibcPriv *TA_Globals; 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_common/ta_magic_nb.h: -------------------------------------------------------------------------------- 1 | #ifndef TA_MAGIC_NB_H 2 | #define TA_MAGIC_NB_H 3 | 4 | /* Many allocated structures contains a magic number. 5 | * 6 | * These numbers are used solely to make sure that when a pointer is 7 | * provided, it is really pointing on the expected type of data. 8 | * It helps also for the detection of memory corruption. 9 | * This mechanism is simple, but add a non-negligeable level of 10 | * reliability at a very low cost (speed/memory wise). 11 | */ 12 | #define TA_FUNC_DEF_MAGIC_NB 0xA201B201 13 | #define TA_PARAM_HOLDER_PRIV_MAGIC_NB 0xA202B202 14 | #define TA_LIBC_PRIV_MAGIC_NB 0xA203B203 15 | #define TA_UDBASE_MAGIC_NB 0xA204B204 16 | #define TA_CATEGORY_TABLE_MAGIC_NB 0xA205B205 17 | #define TA_SYMBOL_TABLE_MAGIC_NB 0xA206B206 18 | #define TA_WEBPAGE_MAGIC_NB 0xA207B207 19 | #define TA_STREAM_MAGIC_NB 0xA208B208 20 | #define TA_STREAM_ACCESS_MAGIC_NB 0xA209B209 21 | #define TA_YAHOO_IDX_MAGIC_NB 0xA20AB20A 22 | #define TA_STRING_TABLE_GROUP_MAGIC_NB 0xA20BB20B 23 | #define TA_STRING_TABLE_FUNC_MAGIC_NB 0xA20CB20C 24 | #define TA_MARKET_PAGE_MAGIC_NB 0xA20DB20D 25 | #define TA_TRADELOGPRIV_MAGIC_NB 0xA20EB20E 26 | #define TA_PMPRIV_MAGIC_NB 0xA20FB20F 27 | #define TA_PMREPORT_MAGIC_NB 0xA210B210 28 | #define TA_TRADEREPORT_MAGIC_NB 0xA211B211 29 | #define TA_HISTORY_MAGIC_NB 0xA212B212 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_common/ta_pragma.h: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * CM Craig Miller (c-miller@users.sourceforge.net) 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 011707 CM First version. 45 | */ 46 | 47 | /* Description: 48 | * 49 | * Visual Studio 2005 has extended the C Run-Time Library by including "secure" 50 | * runtime functions and deprecating the previous function prototypes. Since 51 | * we need to use the previous prototypes to maintain compatibility with other 52 | * platform compilers we are going to disable the deprecation warnings when 53 | * compiling with Visual Studio 2005. 54 | * 55 | * Note: this header must be the first inclusion referenced by the code file 56 | * needing these settings!!!!! 57 | * 58 | */ 59 | 60 | #ifndef TA_PRAGMA_H 61 | #define TA_PRAGMA_H 62 | 63 | #if (_MSC_VER >= 1400) // VC8+ nmake and VS2005 64 | 65 | #ifndef _CRT_SECURE_NO_DEPRECATE //turn off MS 'safe' CRT library routines 66 | #define _CRT_SECURE_NO_DEPRECATE 1 67 | #endif 68 | 69 | // There are additional macros that may be needed in the future, so we'll list them here 70 | //#ifndef _CRT_SECURE_NO_WARNINGS //turn off MS 'safe' CRT library routines 71 | // #define _CRT_SECURE_NO_WARNINGS 1 72 | //#endif 73 | // 74 | //#ifndef _SCL_SECURE_NO_DEPRECATE //turn off MS 'safe' C++RT library routines 75 | // #define _SCL_SECURE_NO_DEPRECATE 1 76 | //#endif 77 | //#ifndef _SCL_SECURE_NO_WARNINGS 78 | // #define _SCL_SECURE_NO_WARNINGS 1 79 | //#endif 80 | // 81 | //#ifndef _CRT_NONSTDC_NO_DEPRECATE //turn off MS POSIX replacements library routines 82 | // #define _CRT_NONSTDC_NO_DEPRECATE 1 83 | //#endif 84 | 85 | #endif // VC8+ 86 | 87 | #endif //TA_PRAGMA_H 88 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_common/ta_retcode.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* Important: This file is automatically generated by the utility gen_code. 35 | * Any modification will be lost on next execution of gen_code. 36 | * 37 | * The goal of this file is to provide the functionality TA_SetRetCodeInfo. 38 | * 39 | * This function is a convenient way for the user to translate a TA_RetCode into 40 | * a human readable string. 41 | */ 42 | #include "ta_common.h" 43 | 44 | typedef struct 45 | { 46 | TA_RetCode retCode; 47 | const char * const enumStr; 48 | const char * const infoStr; 49 | } TA_InternalRetCodeInfo; 50 | 51 | static TA_InternalRetCodeInfo retCodeInfoTable[] = { 52 | {(TA_RetCode)0,"TA_SUCCESS","No error"}, 53 | {(TA_RetCode)1,"TA_LIB_NOT_INITIALIZE","TA_Initialize was not sucessfully called"}, 54 | {(TA_RetCode)2,"TA_BAD_PARAM","A parameter is out of range"}, 55 | {(TA_RetCode)3,"TA_ALLOC_ERR","Possibly out-of-memory"}, 56 | {(TA_RetCode)4,"TA_GROUP_NOT_FOUND","No Info"}, 57 | {(TA_RetCode)5,"TA_FUNC_NOT_FOUND","No Info"}, 58 | {(TA_RetCode)6,"TA_INVALID_HANDLE","No Info"}, 59 | {(TA_RetCode)7,"TA_INVALID_PARAM_HOLDER","No Info"}, 60 | {(TA_RetCode)8,"TA_INVALID_PARAM_HOLDER_TYPE","No Info"}, 61 | {(TA_RetCode)9,"TA_INVALID_PARAM_FUNCTION","No Info"}, 62 | {(TA_RetCode)10,"TA_INPUT_NOT_ALL_INITIALIZE","No Info"}, 63 | {(TA_RetCode)11,"TA_OUTPUT_NOT_ALL_INITIALIZE","No Info"}, 64 | {(TA_RetCode)12,"TA_OUT_OF_RANGE_START_INDEX","No Info"}, 65 | {(TA_RetCode)13,"TA_OUT_OF_RANGE_END_INDEX","No Info"}, 66 | {(TA_RetCode)14,"TA_INVALID_LIST_TYPE","No Info"}, 67 | {(TA_RetCode)15,"TA_BAD_OBJECT","No Info"}, 68 | {(TA_RetCode)16,"TA_NOT_SUPPORTED","No Info"}, 69 | {(TA_RetCode)5000,"TA_INTERNAL_ERROR","No Info"}, 70 | {(TA_RetCode)0xFFFF,"TA_UNKNOWN_ERR","Unknown Error"} 71 | }; 72 | 73 | #define NB_RET_CODE_INFO (sizeof(retCodeInfoTable)/sizeof(TA_InternalRetCodeInfo)) 74 | 75 | void TA_SetRetCodeInfo( TA_RetCode theRetCode, TA_RetCodeInfo *retCodeInfo ) 76 | { 77 | unsigned int i; 78 | 79 | /* Trap internal error code */ 80 | if( (theRetCode >= 5000) && (theRetCode <= 5999) ) 81 | { 82 | retCodeInfo->enumStr = "TA_INTERNAL_ERROR"; 83 | retCodeInfo->infoStr = "Unexpected Internal Error - Contact TA-Lib.org"; 84 | return; 85 | } 86 | 87 | /* Check among all the error code defined in ta_common.h */ 88 | for( i=0; i < (NB_RET_CODE_INFO-1); i++ ) 89 | { 90 | if( theRetCode == retCodeInfoTable[i].retCode ) 91 | { 92 | /* Error code found. */ 93 | retCodeInfo->enumStr = retCodeInfoTable[i].enumStr; 94 | retCodeInfo->infoStr = retCodeInfoTable[i].infoStr; 95 | return; 96 | } 97 | } 98 | 99 | /* Error code not found. */ 100 | 101 | /* "TA_UNKNOWN_ERR" is ALWAYS the last entry in the table. */ 102 | retCodeInfo->enumStr = retCodeInfoTable[i].enumStr; 103 | retCodeInfo->infoStr = retCodeInfoTable[i].infoStr; 104 | } 105 | 106 | /***************/ 107 | /* End of File */ 108 | /***************/ 109 | 110 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_common/ta_retcode.csv: -------------------------------------------------------------------------------- 1 | 0,TA_SUCCESS,No error 2 | 1,TA_LIB_NOT_INITIALIZE,TA_Initialize was not sucessfully called 3 | 2,TA_BAD_PARAM,A parameter is out of range 4 | 3,TA_ALLOC_ERR,Possibly out-of-memory 5 | 4,TA_GROUP_NOT_FOUND,No Info 6 | 5,TA_FUNC_NOT_FOUND,No Info 7 | 6,TA_INVALID_HANDLE,No Info 8 | 7,TA_INVALID_PARAM_HOLDER,No Info 9 | 8,TA_INVALID_PARAM_HOLDER_TYPE,No Info 10 | 9,TA_INVALID_PARAM_FUNCTION,No Info 11 | 10,TA_INPUT_NOT_ALL_INITIALIZE,No Info 12 | 11,TA_OUTPUT_NOT_ALL_INITIALIZE,No Info 13 | 12,TA_OUT_OF_RANGE_START_INDEX,No Info 14 | 13,TA_OUT_OF_RANGE_END_INDEX,No Info 15 | 14,TA_INVALID_LIST_TYPE,No Info 16 | 15,TA_BAD_OBJECT,No Info 17 | 16,TA_NOT_SUPPORTED,No Info 18 | 5000,TA_INTERNAL_ERROR,No Info 19 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_common/ta_version.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | /* Version number controlled manually. 38 | * 39 | * Should be modified only by TA-Lib.org 40 | */ 41 | #define MAJOR "0" 42 | #define MINOR "4" 43 | #define BUILD "0" 44 | 45 | /* Nothing to modify below this line. */ 46 | 47 | #define TA_VERSION_STRING(maj,min,build,date,time) maj"."min"."build" ("date" "time")" 48 | 49 | const char *TA_GetVersionString( void ) 50 | { 51 | return TA_VERSION_STRING(MAJOR,MINOR,BUILD,__DATE__,__TIME__); 52 | } 53 | 54 | const char *TA_GetVersionMajor( void ) 55 | { 56 | return MAJOR; 57 | } 58 | 59 | const char *TA_GetVersionMinor( void ) 60 | { 61 | return MINOR; 62 | } 63 | 64 | const char *TA_GetVersionBuild( void ) 65 | { 66 | return BUILD; 67 | } 68 | 69 | const char *TA_GetVersionDate( void ) 70 | { 71 | return __DATE__; 72 | } 73 | 74 | const char *TA_GetVersionTime( void ) 75 | { 76 | return __TIME__; 77 | } 78 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_ACOS.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 090807 MF Initial Version 45 | */ 46 | 47 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 48 | /* All code within this section is automatically 49 | * generated by gen_code. Any modification will be lost 50 | * next time gen_code is run. 51 | */ 52 | /* Generated */ 53 | /* Generated */ #if defined( _MANAGED ) 54 | /* Generated */ #include "TA-Lib-Core.h" 55 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError) 56 | /* Generated */ namespace TicTacTec { namespace TA { namespace Library { 57 | /* Generated */ #elif defined( _JAVA ) 58 | /* Generated */ #include "ta_defs.h" 59 | /* Generated */ #include "ta_java_defs.h" 60 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError) 61 | /* Generated */ #else 62 | /* Generated */ #include 63 | /* Generated */ #include 64 | /* Generated */ #include "ta_func.h" 65 | /* Generated */ #endif 66 | /* Generated */ 67 | /* Generated */ #ifndef TA_UTILITY_H 68 | /* Generated */ #include "ta_utility.h" 69 | /* Generated */ #endif 70 | /* Generated */ 71 | /* Generated */ #ifndef TA_MEMORY_H 72 | /* Generated */ #include "ta_memory.h" 73 | /* Generated */ #endif 74 | /* Generated */ 75 | /* Generated */ #define TA_PREFIX(x) TA_##x 76 | /* Generated */ #define INPUT_TYPE double 77 | /* Generated */ 78 | /* Generated */ #if defined( _MANAGED ) 79 | /* Generated */ int Core::AcosLookback( void ) 80 | /* Generated */ 81 | /* Generated */ #elif defined( _JAVA ) 82 | /* Generated */ public int acosLookback( ) 83 | /* Generated */ 84 | /* Generated */ #else 85 | /* Generated */ int TA_ACOS_Lookback( void ) 86 | /* Generated */ 87 | /* Generated */ #endif 88 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 89 | { 90 | /* insert local variable here */ 91 | 92 | /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 93 | /* Generated */ /* No parameters to validate. */ 94 | /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 95 | 96 | /* insert lookback code here. */ 97 | 98 | return 0; 99 | } 100 | 101 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 102 | /* 103 | * TA_ACOS - Vector Trigonometric ACos 104 | * 105 | * Input = double 106 | * Output = double 107 | * 108 | */ 109 | /* Generated */ 110 | /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) 111 | /* Generated */ enum class Core::RetCode Core::Acos( int startIdx, 112 | /* Generated */ int endIdx, 113 | /* Generated */ SubArray^ inReal, 114 | /* Generated */ [Out]int% outBegIdx, 115 | /* Generated */ [Out]int% outNBElement, 116 | /* Generated */ cli::array^ outReal ) 117 | /* Generated */ #elif defined( _MANAGED ) 118 | /* Generated */ enum class Core::RetCode Core::Acos( int startIdx, 119 | /* Generated */ int endIdx, 120 | /* Generated */ cli::array^ inReal, 121 | /* Generated */ [Out]int% outBegIdx, 122 | /* Generated */ [Out]int% outNBElement, 123 | /* Generated */ cli::array^ outReal ) 124 | /* Generated */ #elif defined( _JAVA ) 125 | /* Generated */ public RetCode acos( int startIdx, 126 | /* Generated */ int endIdx, 127 | /* Generated */ double inReal[], 128 | /* Generated */ MInteger outBegIdx, 129 | /* Generated */ MInteger outNBElement, 130 | /* Generated */ double outReal[] ) 131 | /* Generated */ #else 132 | /* Generated */ TA_RetCode TA_ACOS( int startIdx, 133 | /* Generated */ int endIdx, 134 | /* Generated */ const double inReal[], 135 | /* Generated */ int *outBegIdx, 136 | /* Generated */ int *outNBElement, 137 | /* Generated */ double outReal[] ) 138 | /* Generated */ #endif 139 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 140 | { 141 | /* insert local variable here */ 142 | int outIdx; 143 | int i; 144 | 145 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 146 | /* Generated */ 147 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 148 | /* Generated */ 149 | /* Generated */ /* Validate the requested output range. */ 150 | /* Generated */ if( startIdx < 0 ) 151 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 152 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 153 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 154 | /* Generated */ 155 | /* Generated */ #if !defined(_JAVA) 156 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 157 | /* Generated */ #endif /* !defined(_JAVA)*/ 158 | /* Generated */ #if !defined(_JAVA) 159 | /* Generated */ if( !outReal ) 160 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 161 | /* Generated */ 162 | /* Generated */ #endif /* !defined(_JAVA) */ 163 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 164 | /* Generated */ 165 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 166 | 167 | /* Insert TA function code here. */ 168 | 169 | /* Default return values */ 170 | for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 171 | { 172 | outReal[outIdx] = std_acos(inReal[i]); 173 | } 174 | 175 | VALUE_HANDLE_DEREF(outNBElement) = outIdx; 176 | VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 177 | 178 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 179 | } 180 | 181 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 182 | /* Generated */ 183 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 184 | /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA ) 185 | /* Generated */ #undef TA_PREFIX 186 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 187 | /* Generated */ #endif 188 | /* Generated */ #undef INPUT_TYPE 189 | /* Generated */ #define INPUT_TYPE float 190 | /* Generated */ #if defined( _MANAGED ) 191 | /* Generated */ enum class Core::RetCode Core::Acos( int startIdx, 192 | /* Generated */ int endIdx, 193 | /* Generated */ cli::array^ inReal, 194 | /* Generated */ [Out]int% outBegIdx, 195 | /* Generated */ [Out]int% outNBElement, 196 | /* Generated */ cli::array^ outReal ) 197 | /* Generated */ #elif defined( _JAVA ) 198 | /* Generated */ public RetCode acos( int startIdx, 199 | /* Generated */ int endIdx, 200 | /* Generated */ float inReal[], 201 | /* Generated */ MInteger outBegIdx, 202 | /* Generated */ MInteger outNBElement, 203 | /* Generated */ double outReal[] ) 204 | /* Generated */ #else 205 | /* Generated */ TA_RetCode TA_S_ACOS( int startIdx, 206 | /* Generated */ int endIdx, 207 | /* Generated */ const float inReal[], 208 | /* Generated */ int *outBegIdx, 209 | /* Generated */ int *outNBElement, 210 | /* Generated */ double outReal[] ) 211 | /* Generated */ #endif 212 | /* Generated */ { 213 | /* Generated */ int outIdx; 214 | /* Generated */ int i; 215 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 216 | /* Generated */ if( startIdx < 0 ) 217 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 218 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 219 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 220 | /* Generated */ #if !defined(_JAVA) 221 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 222 | /* Generated */ #endif 223 | /* Generated */ #if !defined(_JAVA) 224 | /* Generated */ if( !outReal ) 225 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 226 | /* Generated */ #endif 227 | /* Generated */ #endif 228 | /* Generated */ for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 229 | /* Generated */ { 230 | /* Generated */ outReal[outIdx] = std_acos(inReal[i]); 231 | /* Generated */ } 232 | /* Generated */ VALUE_HANDLE_DEREF(outNBElement) = outIdx; 233 | /* Generated */ VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 234 | /* Generated */ return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 235 | /* Generated */ } 236 | /* Generated */ 237 | /* Generated */ #if defined( _MANAGED ) 238 | /* Generated */ }}} // Close namespace TicTacTec.TA.Lib 239 | /* Generated */ #endif 240 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 241 | 242 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_CEIL.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 090807 MF Initial Version 45 | */ 46 | 47 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 48 | /* All code within this section is automatically 49 | * generated by gen_code. Any modification will be lost 50 | * next time gen_code is run. 51 | */ 52 | /* Generated */ 53 | /* Generated */ #if defined( _MANAGED ) 54 | /* Generated */ #include "TA-Lib-Core.h" 55 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError) 56 | /* Generated */ namespace TicTacTec { namespace TA { namespace Library { 57 | /* Generated */ #elif defined( _JAVA ) 58 | /* Generated */ #include "ta_defs.h" 59 | /* Generated */ #include "ta_java_defs.h" 60 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError) 61 | /* Generated */ #else 62 | /* Generated */ #include 63 | /* Generated */ #include 64 | /* Generated */ #include "ta_func.h" 65 | /* Generated */ #endif 66 | /* Generated */ 67 | /* Generated */ #ifndef TA_UTILITY_H 68 | /* Generated */ #include "ta_utility.h" 69 | /* Generated */ #endif 70 | /* Generated */ 71 | /* Generated */ #ifndef TA_MEMORY_H 72 | /* Generated */ #include "ta_memory.h" 73 | /* Generated */ #endif 74 | /* Generated */ 75 | /* Generated */ #define TA_PREFIX(x) TA_##x 76 | /* Generated */ #define INPUT_TYPE double 77 | /* Generated */ 78 | /* Generated */ #if defined( _MANAGED ) 79 | /* Generated */ int Core::CeilLookback( void ) 80 | /* Generated */ 81 | /* Generated */ #elif defined( _JAVA ) 82 | /* Generated */ public int ceilLookback( ) 83 | /* Generated */ 84 | /* Generated */ #else 85 | /* Generated */ int TA_CEIL_Lookback( void ) 86 | /* Generated */ 87 | /* Generated */ #endif 88 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 89 | { 90 | /* insert local variable here */ 91 | 92 | /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 93 | /* Generated */ /* No parameters to validate. */ 94 | /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 95 | 96 | /* insert lookback code here. */ 97 | 98 | return 0; 99 | } 100 | 101 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 102 | /* 103 | * TA_CEIL - Vector Ceil 104 | * 105 | * Input = double 106 | * Output = double 107 | * 108 | */ 109 | /* Generated */ 110 | /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) 111 | /* Generated */ enum class Core::RetCode Core::Ceil( int startIdx, 112 | /* Generated */ int endIdx, 113 | /* Generated */ SubArray^ inReal, 114 | /* Generated */ [Out]int% outBegIdx, 115 | /* Generated */ [Out]int% outNBElement, 116 | /* Generated */ cli::array^ outReal ) 117 | /* Generated */ #elif defined( _MANAGED ) 118 | /* Generated */ enum class Core::RetCode Core::Ceil( int startIdx, 119 | /* Generated */ int endIdx, 120 | /* Generated */ cli::array^ inReal, 121 | /* Generated */ [Out]int% outBegIdx, 122 | /* Generated */ [Out]int% outNBElement, 123 | /* Generated */ cli::array^ outReal ) 124 | /* Generated */ #elif defined( _JAVA ) 125 | /* Generated */ public RetCode ceil( int startIdx, 126 | /* Generated */ int endIdx, 127 | /* Generated */ double inReal[], 128 | /* Generated */ MInteger outBegIdx, 129 | /* Generated */ MInteger outNBElement, 130 | /* Generated */ double outReal[] ) 131 | /* Generated */ #else 132 | /* Generated */ TA_RetCode TA_CEIL( int startIdx, 133 | /* Generated */ int endIdx, 134 | /* Generated */ const double inReal[], 135 | /* Generated */ int *outBegIdx, 136 | /* Generated */ int *outNBElement, 137 | /* Generated */ double outReal[] ) 138 | /* Generated */ #endif 139 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 140 | { 141 | /* insert local variable here */ 142 | int outIdx; 143 | int i; 144 | 145 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 146 | /* Generated */ 147 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 148 | /* Generated */ 149 | /* Generated */ /* Validate the requested output range. */ 150 | /* Generated */ if( startIdx < 0 ) 151 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 152 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 153 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 154 | /* Generated */ 155 | /* Generated */ #if !defined(_JAVA) 156 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 157 | /* Generated */ #endif /* !defined(_JAVA)*/ 158 | /* Generated */ #if !defined(_JAVA) 159 | /* Generated */ if( !outReal ) 160 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 161 | /* Generated */ 162 | /* Generated */ #endif /* !defined(_JAVA) */ 163 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 164 | /* Generated */ 165 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 166 | 167 | /* Insert TA function code here. */ 168 | 169 | /* Default return values */ 170 | for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 171 | { 172 | outReal[outIdx] = std_ceil(inReal[i]); 173 | } 174 | 175 | VALUE_HANDLE_DEREF(outNBElement) = outIdx; 176 | VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 177 | 178 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 179 | } 180 | 181 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 182 | /* Generated */ 183 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 184 | /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA ) 185 | /* Generated */ #undef TA_PREFIX 186 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 187 | /* Generated */ #endif 188 | /* Generated */ #undef INPUT_TYPE 189 | /* Generated */ #define INPUT_TYPE float 190 | /* Generated */ #if defined( _MANAGED ) 191 | /* Generated */ enum class Core::RetCode Core::Ceil( int startIdx, 192 | /* Generated */ int endIdx, 193 | /* Generated */ cli::array^ inReal, 194 | /* Generated */ [Out]int% outBegIdx, 195 | /* Generated */ [Out]int% outNBElement, 196 | /* Generated */ cli::array^ outReal ) 197 | /* Generated */ #elif defined( _JAVA ) 198 | /* Generated */ public RetCode ceil( int startIdx, 199 | /* Generated */ int endIdx, 200 | /* Generated */ float inReal[], 201 | /* Generated */ MInteger outBegIdx, 202 | /* Generated */ MInteger outNBElement, 203 | /* Generated */ double outReal[] ) 204 | /* Generated */ #else 205 | /* Generated */ TA_RetCode TA_S_CEIL( int startIdx, 206 | /* Generated */ int endIdx, 207 | /* Generated */ const float inReal[], 208 | /* Generated */ int *outBegIdx, 209 | /* Generated */ int *outNBElement, 210 | /* Generated */ double outReal[] ) 211 | /* Generated */ #endif 212 | /* Generated */ { 213 | /* Generated */ int outIdx; 214 | /* Generated */ int i; 215 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 216 | /* Generated */ if( startIdx < 0 ) 217 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 218 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 219 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 220 | /* Generated */ #if !defined(_JAVA) 221 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 222 | /* Generated */ #endif 223 | /* Generated */ #if !defined(_JAVA) 224 | /* Generated */ if( !outReal ) 225 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 226 | /* Generated */ #endif 227 | /* Generated */ #endif 228 | /* Generated */ for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 229 | /* Generated */ { 230 | /* Generated */ outReal[outIdx] = std_ceil(inReal[i]); 231 | /* Generated */ } 232 | /* Generated */ VALUE_HANDLE_DEREF(outNBElement) = outIdx; 233 | /* Generated */ VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 234 | /* Generated */ return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 235 | /* Generated */ } 236 | /* Generated */ 237 | /* Generated */ #if defined( _MANAGED ) 238 | /* Generated */ }}} // Close namespace TicTacTec.TA.Lib 239 | /* Generated */ #endif 240 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 241 | 242 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_COS.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 090807 MF Initial Version 45 | */ 46 | 47 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 48 | /* All code within this section is automatically 49 | * generated by gen_code. Any modification will be lost 50 | * next time gen_code is run. 51 | */ 52 | /* Generated */ 53 | /* Generated */ #if defined( _MANAGED ) 54 | /* Generated */ #include "TA-Lib-Core.h" 55 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError) 56 | /* Generated */ namespace TicTacTec { namespace TA { namespace Library { 57 | /* Generated */ #elif defined( _JAVA ) 58 | /* Generated */ #include "ta_defs.h" 59 | /* Generated */ #include "ta_java_defs.h" 60 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError) 61 | /* Generated */ #else 62 | /* Generated */ #include 63 | /* Generated */ #include 64 | /* Generated */ #include "ta_func.h" 65 | /* Generated */ #endif 66 | /* Generated */ 67 | /* Generated */ #ifndef TA_UTILITY_H 68 | /* Generated */ #include "ta_utility.h" 69 | /* Generated */ #endif 70 | /* Generated */ 71 | /* Generated */ #ifndef TA_MEMORY_H 72 | /* Generated */ #include "ta_memory.h" 73 | /* Generated */ #endif 74 | /* Generated */ 75 | /* Generated */ #define TA_PREFIX(x) TA_##x 76 | /* Generated */ #define INPUT_TYPE double 77 | /* Generated */ 78 | /* Generated */ #if defined( _MANAGED ) 79 | /* Generated */ int Core::CosLookback( void ) 80 | /* Generated */ 81 | /* Generated */ #elif defined( _JAVA ) 82 | /* Generated */ public int cosLookback( ) 83 | /* Generated */ 84 | /* Generated */ #else 85 | /* Generated */ int TA_COS_Lookback( void ) 86 | /* Generated */ 87 | /* Generated */ #endif 88 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 89 | { 90 | /* insert local variable here */ 91 | 92 | /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 93 | /* Generated */ /* No parameters to validate. */ 94 | /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 95 | 96 | /* insert lookback code here. */ 97 | 98 | return 0; 99 | } 100 | 101 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 102 | /* 103 | * TA_COS - Vector Trigonometric Cos 104 | * 105 | * Input = double 106 | * Output = double 107 | * 108 | */ 109 | /* Generated */ 110 | /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) 111 | /* Generated */ enum class Core::RetCode Core::Cos( int startIdx, 112 | /* Generated */ int endIdx, 113 | /* Generated */ SubArray^ inReal, 114 | /* Generated */ [Out]int% outBegIdx, 115 | /* Generated */ [Out]int% outNBElement, 116 | /* Generated */ cli::array^ outReal ) 117 | /* Generated */ #elif defined( _MANAGED ) 118 | /* Generated */ enum class Core::RetCode Core::Cos( int startIdx, 119 | /* Generated */ int endIdx, 120 | /* Generated */ cli::array^ inReal, 121 | /* Generated */ [Out]int% outBegIdx, 122 | /* Generated */ [Out]int% outNBElement, 123 | /* Generated */ cli::array^ outReal ) 124 | /* Generated */ #elif defined( _JAVA ) 125 | /* Generated */ public RetCode cos( int startIdx, 126 | /* Generated */ int endIdx, 127 | /* Generated */ double inReal[], 128 | /* Generated */ MInteger outBegIdx, 129 | /* Generated */ MInteger outNBElement, 130 | /* Generated */ double outReal[] ) 131 | /* Generated */ #else 132 | /* Generated */ TA_RetCode TA_COS( int startIdx, 133 | /* Generated */ int endIdx, 134 | /* Generated */ const double inReal[], 135 | /* Generated */ int *outBegIdx, 136 | /* Generated */ int *outNBElement, 137 | /* Generated */ double outReal[] ) 138 | /* Generated */ #endif 139 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 140 | { 141 | /* insert local variable here */ 142 | int outIdx; 143 | int i; 144 | 145 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 146 | /* Generated */ 147 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 148 | /* Generated */ 149 | /* Generated */ /* Validate the requested output range. */ 150 | /* Generated */ if( startIdx < 0 ) 151 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 152 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 153 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 154 | /* Generated */ 155 | /* Generated */ #if !defined(_JAVA) 156 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 157 | /* Generated */ #endif /* !defined(_JAVA)*/ 158 | /* Generated */ #if !defined(_JAVA) 159 | /* Generated */ if( !outReal ) 160 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 161 | /* Generated */ 162 | /* Generated */ #endif /* !defined(_JAVA) */ 163 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 164 | /* Generated */ 165 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 166 | 167 | /* Insert TA function code here. */ 168 | 169 | /* Default return values */ 170 | for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 171 | { 172 | outReal[outIdx] = std_cos(inReal[i]); 173 | } 174 | 175 | VALUE_HANDLE_DEREF(outNBElement) = outIdx; 176 | VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 177 | 178 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 179 | } 180 | 181 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 182 | /* Generated */ 183 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 184 | /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA ) 185 | /* Generated */ #undef TA_PREFIX 186 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 187 | /* Generated */ #endif 188 | /* Generated */ #undef INPUT_TYPE 189 | /* Generated */ #define INPUT_TYPE float 190 | /* Generated */ #if defined( _MANAGED ) 191 | /* Generated */ enum class Core::RetCode Core::Cos( int startIdx, 192 | /* Generated */ int endIdx, 193 | /* Generated */ cli::array^ inReal, 194 | /* Generated */ [Out]int% outBegIdx, 195 | /* Generated */ [Out]int% outNBElement, 196 | /* Generated */ cli::array^ outReal ) 197 | /* Generated */ #elif defined( _JAVA ) 198 | /* Generated */ public RetCode cos( int startIdx, 199 | /* Generated */ int endIdx, 200 | /* Generated */ float inReal[], 201 | /* Generated */ MInteger outBegIdx, 202 | /* Generated */ MInteger outNBElement, 203 | /* Generated */ double outReal[] ) 204 | /* Generated */ #else 205 | /* Generated */ TA_RetCode TA_S_COS( int startIdx, 206 | /* Generated */ int endIdx, 207 | /* Generated */ const float inReal[], 208 | /* Generated */ int *outBegIdx, 209 | /* Generated */ int *outNBElement, 210 | /* Generated */ double outReal[] ) 211 | /* Generated */ #endif 212 | /* Generated */ { 213 | /* Generated */ int outIdx; 214 | /* Generated */ int i; 215 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 216 | /* Generated */ if( startIdx < 0 ) 217 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 218 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 219 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 220 | /* Generated */ #if !defined(_JAVA) 221 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 222 | /* Generated */ #endif 223 | /* Generated */ #if !defined(_JAVA) 224 | /* Generated */ if( !outReal ) 225 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 226 | /* Generated */ #endif 227 | /* Generated */ #endif 228 | /* Generated */ for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 229 | /* Generated */ { 230 | /* Generated */ outReal[outIdx] = std_cos(inReal[i]); 231 | /* Generated */ } 232 | /* Generated */ VALUE_HANDLE_DEREF(outNBElement) = outIdx; 233 | /* Generated */ VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 234 | /* Generated */ return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 235 | /* Generated */ } 236 | /* Generated */ 237 | /* Generated */ #if defined( _MANAGED ) 238 | /* Generated */ }}} // Close namespace TicTacTec.TA.Lib 239 | /* Generated */ #endif 240 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 241 | 242 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_EXP.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 090807 MF Initial Version 45 | */ 46 | 47 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 48 | /* All code within this section is automatically 49 | * generated by gen_code. Any modification will be lost 50 | * next time gen_code is run. 51 | */ 52 | /* Generated */ 53 | /* Generated */ #if defined( _MANAGED ) 54 | /* Generated */ #include "TA-Lib-Core.h" 55 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError) 56 | /* Generated */ namespace TicTacTec { namespace TA { namespace Library { 57 | /* Generated */ #elif defined( _JAVA ) 58 | /* Generated */ #include "ta_defs.h" 59 | /* Generated */ #include "ta_java_defs.h" 60 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError) 61 | /* Generated */ #else 62 | /* Generated */ #include 63 | /* Generated */ #include 64 | /* Generated */ #include "ta_func.h" 65 | /* Generated */ #endif 66 | /* Generated */ 67 | /* Generated */ #ifndef TA_UTILITY_H 68 | /* Generated */ #include "ta_utility.h" 69 | /* Generated */ #endif 70 | /* Generated */ 71 | /* Generated */ #ifndef TA_MEMORY_H 72 | /* Generated */ #include "ta_memory.h" 73 | /* Generated */ #endif 74 | /* Generated */ 75 | /* Generated */ #define TA_PREFIX(x) TA_##x 76 | /* Generated */ #define INPUT_TYPE double 77 | /* Generated */ 78 | /* Generated */ #if defined( _MANAGED ) 79 | /* Generated */ int Core::ExpLookback( void ) 80 | /* Generated */ 81 | /* Generated */ #elif defined( _JAVA ) 82 | /* Generated */ public int expLookback( ) 83 | /* Generated */ 84 | /* Generated */ #else 85 | /* Generated */ int TA_EXP_Lookback( void ) 86 | /* Generated */ 87 | /* Generated */ #endif 88 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 89 | { 90 | /* insert local variable here */ 91 | 92 | /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 93 | /* Generated */ /* No parameters to validate. */ 94 | /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 95 | 96 | /* insert lookback code here. */ 97 | 98 | return 0; 99 | } 100 | 101 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 102 | /* 103 | * TA_EXP - Vector Arithmetic Exp 104 | * 105 | * Input = double 106 | * Output = double 107 | * 108 | */ 109 | /* Generated */ 110 | /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) 111 | /* Generated */ enum class Core::RetCode Core::Exp( int startIdx, 112 | /* Generated */ int endIdx, 113 | /* Generated */ SubArray^ inReal, 114 | /* Generated */ [Out]int% outBegIdx, 115 | /* Generated */ [Out]int% outNBElement, 116 | /* Generated */ cli::array^ outReal ) 117 | /* Generated */ #elif defined( _MANAGED ) 118 | /* Generated */ enum class Core::RetCode Core::Exp( int startIdx, 119 | /* Generated */ int endIdx, 120 | /* Generated */ cli::array^ inReal, 121 | /* Generated */ [Out]int% outBegIdx, 122 | /* Generated */ [Out]int% outNBElement, 123 | /* Generated */ cli::array^ outReal ) 124 | /* Generated */ #elif defined( _JAVA ) 125 | /* Generated */ public RetCode exp( int startIdx, 126 | /* Generated */ int endIdx, 127 | /* Generated */ double inReal[], 128 | /* Generated */ MInteger outBegIdx, 129 | /* Generated */ MInteger outNBElement, 130 | /* Generated */ double outReal[] ) 131 | /* Generated */ #else 132 | /* Generated */ TA_RetCode TA_EXP( int startIdx, 133 | /* Generated */ int endIdx, 134 | /* Generated */ const double inReal[], 135 | /* Generated */ int *outBegIdx, 136 | /* Generated */ int *outNBElement, 137 | /* Generated */ double outReal[] ) 138 | /* Generated */ #endif 139 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 140 | { 141 | /* insert local variable here */ 142 | int outIdx; 143 | int i; 144 | 145 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 146 | /* Generated */ 147 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 148 | /* Generated */ 149 | /* Generated */ /* Validate the requested output range. */ 150 | /* Generated */ if( startIdx < 0 ) 151 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 152 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 153 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 154 | /* Generated */ 155 | /* Generated */ #if !defined(_JAVA) 156 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 157 | /* Generated */ #endif /* !defined(_JAVA)*/ 158 | /* Generated */ #if !defined(_JAVA) 159 | /* Generated */ if( !outReal ) 160 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 161 | /* Generated */ 162 | /* Generated */ #endif /* !defined(_JAVA) */ 163 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 164 | /* Generated */ 165 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 166 | 167 | /* Insert TA function code here. */ 168 | 169 | /* Default return values */ 170 | for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 171 | { 172 | outReal[outIdx] = std_exp(inReal[i]); 173 | } 174 | 175 | VALUE_HANDLE_DEREF(outNBElement) = outIdx; 176 | VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 177 | 178 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 179 | } 180 | 181 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 182 | /* Generated */ 183 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 184 | /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA ) 185 | /* Generated */ #undef TA_PREFIX 186 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 187 | /* Generated */ #endif 188 | /* Generated */ #undef INPUT_TYPE 189 | /* Generated */ #define INPUT_TYPE float 190 | /* Generated */ #if defined( _MANAGED ) 191 | /* Generated */ enum class Core::RetCode Core::Exp( int startIdx, 192 | /* Generated */ int endIdx, 193 | /* Generated */ cli::array^ inReal, 194 | /* Generated */ [Out]int% outBegIdx, 195 | /* Generated */ [Out]int% outNBElement, 196 | /* Generated */ cli::array^ outReal ) 197 | /* Generated */ #elif defined( _JAVA ) 198 | /* Generated */ public RetCode exp( int startIdx, 199 | /* Generated */ int endIdx, 200 | /* Generated */ float inReal[], 201 | /* Generated */ MInteger outBegIdx, 202 | /* Generated */ MInteger outNBElement, 203 | /* Generated */ double outReal[] ) 204 | /* Generated */ #else 205 | /* Generated */ TA_RetCode TA_S_EXP( int startIdx, 206 | /* Generated */ int endIdx, 207 | /* Generated */ const float inReal[], 208 | /* Generated */ int *outBegIdx, 209 | /* Generated */ int *outNBElement, 210 | /* Generated */ double outReal[] ) 211 | /* Generated */ #endif 212 | /* Generated */ { 213 | /* Generated */ int outIdx; 214 | /* Generated */ int i; 215 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 216 | /* Generated */ if( startIdx < 0 ) 217 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 218 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 219 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 220 | /* Generated */ #if !defined(_JAVA) 221 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 222 | /* Generated */ #endif 223 | /* Generated */ #if !defined(_JAVA) 224 | /* Generated */ if( !outReal ) 225 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 226 | /* Generated */ #endif 227 | /* Generated */ #endif 228 | /* Generated */ for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 229 | /* Generated */ { 230 | /* Generated */ outReal[outIdx] = std_exp(inReal[i]); 231 | /* Generated */ } 232 | /* Generated */ VALUE_HANDLE_DEREF(outNBElement) = outIdx; 233 | /* Generated */ VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 234 | /* Generated */ return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 235 | /* Generated */ } 236 | /* Generated */ 237 | /* Generated */ #if defined( _MANAGED ) 238 | /* Generated */ }}} // Close namespace TicTacTec.TA.Lib 239 | /* Generated */ #endif 240 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 241 | 242 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_LN.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 090807 MF Initial Version 45 | */ 46 | 47 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 48 | /* All code within this section is automatically 49 | * generated by gen_code. Any modification will be lost 50 | * next time gen_code is run. 51 | */ 52 | /* Generated */ 53 | /* Generated */ #if defined( _MANAGED ) 54 | /* Generated */ #include "TA-Lib-Core.h" 55 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError) 56 | /* Generated */ namespace TicTacTec { namespace TA { namespace Library { 57 | /* Generated */ #elif defined( _JAVA ) 58 | /* Generated */ #include "ta_defs.h" 59 | /* Generated */ #include "ta_java_defs.h" 60 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError) 61 | /* Generated */ #else 62 | /* Generated */ #include 63 | /* Generated */ #include 64 | /* Generated */ #include "ta_func.h" 65 | /* Generated */ #endif 66 | /* Generated */ 67 | /* Generated */ #ifndef TA_UTILITY_H 68 | /* Generated */ #include "ta_utility.h" 69 | /* Generated */ #endif 70 | /* Generated */ 71 | /* Generated */ #ifndef TA_MEMORY_H 72 | /* Generated */ #include "ta_memory.h" 73 | /* Generated */ #endif 74 | /* Generated */ 75 | /* Generated */ #define TA_PREFIX(x) TA_##x 76 | /* Generated */ #define INPUT_TYPE double 77 | /* Generated */ 78 | /* Generated */ #if defined( _MANAGED ) 79 | /* Generated */ int Core::LnLookback( void ) 80 | /* Generated */ 81 | /* Generated */ #elif defined( _JAVA ) 82 | /* Generated */ public int lnLookback( ) 83 | /* Generated */ 84 | /* Generated */ #else 85 | /* Generated */ int TA_LN_Lookback( void ) 86 | /* Generated */ 87 | /* Generated */ #endif 88 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 89 | { 90 | /* insert local variable here */ 91 | 92 | /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 93 | /* Generated */ /* No parameters to validate. */ 94 | /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 95 | 96 | /* insert lookback code here. */ 97 | 98 | return 0; 99 | } 100 | 101 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 102 | /* 103 | * TA_LN - Vector Log Natural 104 | * 105 | * Input = double 106 | * Output = double 107 | * 108 | */ 109 | /* Generated */ 110 | /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) 111 | /* Generated */ enum class Core::RetCode Core::Ln( int startIdx, 112 | /* Generated */ int endIdx, 113 | /* Generated */ SubArray^ inReal, 114 | /* Generated */ [Out]int% outBegIdx, 115 | /* Generated */ [Out]int% outNBElement, 116 | /* Generated */ cli::array^ outReal ) 117 | /* Generated */ #elif defined( _MANAGED ) 118 | /* Generated */ enum class Core::RetCode Core::Ln( int startIdx, 119 | /* Generated */ int endIdx, 120 | /* Generated */ cli::array^ inReal, 121 | /* Generated */ [Out]int% outBegIdx, 122 | /* Generated */ [Out]int% outNBElement, 123 | /* Generated */ cli::array^ outReal ) 124 | /* Generated */ #elif defined( _JAVA ) 125 | /* Generated */ public RetCode ln( int startIdx, 126 | /* Generated */ int endIdx, 127 | /* Generated */ double inReal[], 128 | /* Generated */ MInteger outBegIdx, 129 | /* Generated */ MInteger outNBElement, 130 | /* Generated */ double outReal[] ) 131 | /* Generated */ #else 132 | /* Generated */ TA_RetCode TA_LN( int startIdx, 133 | /* Generated */ int endIdx, 134 | /* Generated */ const double inReal[], 135 | /* Generated */ int *outBegIdx, 136 | /* Generated */ int *outNBElement, 137 | /* Generated */ double outReal[] ) 138 | /* Generated */ #endif 139 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 140 | { 141 | /* insert local variable here */ 142 | int outIdx; 143 | int i; 144 | 145 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 146 | /* Generated */ 147 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 148 | /* Generated */ 149 | /* Generated */ /* Validate the requested output range. */ 150 | /* Generated */ if( startIdx < 0 ) 151 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 152 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 153 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 154 | /* Generated */ 155 | /* Generated */ #if !defined(_JAVA) 156 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 157 | /* Generated */ #endif /* !defined(_JAVA)*/ 158 | /* Generated */ #if !defined(_JAVA) 159 | /* Generated */ if( !outReal ) 160 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 161 | /* Generated */ 162 | /* Generated */ #endif /* !defined(_JAVA) */ 163 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 164 | /* Generated */ 165 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 166 | 167 | /* Insert TA function code here. */ 168 | 169 | /* Default return values */ 170 | for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 171 | { 172 | outReal[outIdx] = std_log(inReal[i]); 173 | } 174 | 175 | VALUE_HANDLE_DEREF(outNBElement) = outIdx; 176 | VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 177 | 178 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 179 | } 180 | 181 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 182 | /* Generated */ 183 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 184 | /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA ) 185 | /* Generated */ #undef TA_PREFIX 186 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 187 | /* Generated */ #endif 188 | /* Generated */ #undef INPUT_TYPE 189 | /* Generated */ #define INPUT_TYPE float 190 | /* Generated */ #if defined( _MANAGED ) 191 | /* Generated */ enum class Core::RetCode Core::Ln( int startIdx, 192 | /* Generated */ int endIdx, 193 | /* Generated */ cli::array^ inReal, 194 | /* Generated */ [Out]int% outBegIdx, 195 | /* Generated */ [Out]int% outNBElement, 196 | /* Generated */ cli::array^ outReal ) 197 | /* Generated */ #elif defined( _JAVA ) 198 | /* Generated */ public RetCode ln( int startIdx, 199 | /* Generated */ int endIdx, 200 | /* Generated */ float inReal[], 201 | /* Generated */ MInteger outBegIdx, 202 | /* Generated */ MInteger outNBElement, 203 | /* Generated */ double outReal[] ) 204 | /* Generated */ #else 205 | /* Generated */ TA_RetCode TA_S_LN( int startIdx, 206 | /* Generated */ int endIdx, 207 | /* Generated */ const float inReal[], 208 | /* Generated */ int *outBegIdx, 209 | /* Generated */ int *outNBElement, 210 | /* Generated */ double outReal[] ) 211 | /* Generated */ #endif 212 | /* Generated */ { 213 | /* Generated */ int outIdx; 214 | /* Generated */ int i; 215 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 216 | /* Generated */ if( startIdx < 0 ) 217 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 218 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 219 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 220 | /* Generated */ #if !defined(_JAVA) 221 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 222 | /* Generated */ #endif 223 | /* Generated */ #if !defined(_JAVA) 224 | /* Generated */ if( !outReal ) 225 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 226 | /* Generated */ #endif 227 | /* Generated */ #endif 228 | /* Generated */ for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 229 | /* Generated */ { 230 | /* Generated */ outReal[outIdx] = std_log(inReal[i]); 231 | /* Generated */ } 232 | /* Generated */ VALUE_HANDLE_DEREF(outNBElement) = outIdx; 233 | /* Generated */ VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 234 | /* Generated */ return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 235 | /* Generated */ } 236 | /* Generated */ 237 | /* Generated */ #if defined( _MANAGED ) 238 | /* Generated */ }}} // Close namespace TicTacTec.TA.Lib 239 | /* Generated */ #endif 240 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 241 | 242 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_NVI.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * 41 | * Change history: 42 | * 43 | * MMDDYY BY Description 44 | * ------------------------------------------------------------------- 45 | * 120802 MF Template creation. 46 | * 47 | */ 48 | 49 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 50 | /* All code within this section is automatically 51 | * generated by gen_code. Any modification will be lost 52 | * next time gen_code is run. 53 | */ 54 | /* Generated */ 55 | /* Generated */ #if defined( _MANAGED ) 56 | /* Generated */ #using 57 | /* Generated */ #include "Core.h" 58 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (TA_INTERNAL_ERROR) 59 | /* Generated */ namespace TA { namespace Library { 60 | /* Generated */ #else 61 | /* Generated */ #include 62 | /* Generated */ #include 63 | /* Generated */ #include "ta_func.h" 64 | /* Generated */ #endif 65 | /* Generated */ 66 | /* Generated */ #ifndef TA_UTILITY_H 67 | /* Generated */ #include "ta_utility.h" 68 | /* Generated */ #endif 69 | /* Generated */ 70 | /* Generated */ #ifndef TA_MEMORY_H 71 | /* Generated */ #include "ta_memory.h" 72 | /* Generated */ #endif 73 | /* Generated */ 74 | /* Generated */ #define TA_PREFIX(x) TA_##x 75 | /* Generated */ #define INPUT_TYPE double 76 | /* Generated */ 77 | /* Generated */ #if defined( _MANAGED ) 78 | /* Generated */ int Core::NVI_Lookback( /* Generated */ void ) 79 | /* Generated */ 80 | /* Generated */ #else 81 | /* Generated */ int TA_NVI_Lookback( /* Generated */ void ) 82 | /* Generated */ 83 | /* Generated */ #endif 84 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 85 | { 86 | /* insert lookback code here. */ 87 | return 0; 88 | } 89 | 90 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 91 | /* 92 | * TA_NVI - Negative Volume Index 93 | * 94 | * Input = Close, Volume 95 | * Output = double 96 | * 97 | */ 98 | /* Generated */ 99 | /* Generated */ #if defined( _MANAGED ) 100 | /* Generated */ enum Core::TA_RetCode Core::NVI( int startIdx, 101 | /* Generated */ int endIdx, 102 | /* Generated */ double inClose __gc [], 103 | /* Generated */ int inVolume __gc [], 104 | /* Generated */ [OutAttribute]Int32 REF(outBegIdx), 105 | /* Generated */ [OutAttribute]Int32 REF(outNBElement), 106 | /* Generated */ double outReal __gc [] ) 107 | /* Generated */ #else 108 | /* Generated */ TA_RetCode TA_NVI( int startIdx, 109 | /* Generated */ int endIdx, 110 | /* Generated */ const double inClose[], 111 | /* Generated */ const int inVolume[], 112 | /* Generated */ int *outBegIdx, 113 | /* Generated */ int *outNBElement, 114 | /* Generated */ double outReal[] ) 115 | /* Generated */ #endif 116 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 117 | { 118 | /* insert local variable here */ 119 | 120 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 121 | /* Generated */ 122 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 123 | /* Generated */ 124 | /* Generated */ /* Validate the requested output range. */ 125 | /* Generated */ if( startIdx < 0 ) 126 | /* Generated */ return TA_OUT_OF_RANGE_START_INDEX; 127 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 128 | /* Generated */ return TA_OUT_OF_RANGE_END_INDEX; 129 | /* Generated */ 130 | /* Generated */ /* Validate the parameters. */ 131 | /* Generated */ /* Verify required price component. */ 132 | /* Generated */ if(!inClose||!inVolume) 133 | /* Generated */ return TA_BAD_PARAM; 134 | /* Generated */ 135 | /* Generated */ if( outReal == NULL ) 136 | /* Generated */ return TA_BAD_PARAM; 137 | /* Generated */ 138 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 139 | /* Generated */ 140 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 141 | 142 | /* Insert TA function code here. */ 143 | 144 | /* Default return values */ 145 | *outBegIdx = 0; 146 | *outNBElement = 0; 147 | 148 | return TA_SUCCESS; 149 | } 150 | 151 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 152 | /* Generated */ 153 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 154 | /* Generated */ #if !defined( _MANAGED ) 155 | /* Generated */ #undef TA_PREFIX 156 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 157 | /* Generated */ #endif 158 | /* Generated */ #undef INPUT_TYPE 159 | /* Generated */ #define INPUT_TYPE float 160 | /* Generated */ #if defined( _MANAGED ) 161 | /* Generated */ enum Core::TA_RetCode Core::NVI( int startIdx, 162 | /* Generated */ int endIdx, 163 | /* Generated */ float inClose __gc [], 164 | /* Generated */ int inVolume __gc [], 165 | /* Generated */ [OutAttribute]Int32 REF(outBegIdx), 166 | /* Generated */ [OutAttribute]Int32 REF(outNBElement), 167 | /* Generated */ double outReal __gc [] ) 168 | /* Generated */ #else 169 | /* Generated */ TA_RetCode TA_S_NVI( int startIdx, 170 | /* Generated */ int endIdx, 171 | /* Generated */ const float inClose[], 172 | /* Generated */ const int inVolume[], 173 | /* Generated */ int *outBegIdx, 174 | /* Generated */ int *outNBElement, 175 | /* Generated */ double outReal[] ) 176 | /* Generated */ #endif 177 | /* Generated */ { 178 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 179 | /* Generated */ if( startIdx < 0 ) 180 | /* Generated */ return TA_OUT_OF_RANGE_START_INDEX; 181 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 182 | /* Generated */ return TA_OUT_OF_RANGE_END_INDEX; 183 | /* Generated */ if(!inClose||!inVolume) 184 | /* Generated */ return TA_BAD_PARAM; 185 | /* Generated */ if( outReal == NULL ) 186 | /* Generated */ return TA_BAD_PARAM; 187 | /* Generated */ #endif 188 | /* Generated */ *outBegIdx = 0; 189 | /* Generated */ *outNBElement = 0; 190 | /* Generated */ return TA_SUCCESS; 191 | /* Generated */ } 192 | /* Generated */ 193 | /* Generated */ #if defined( _MANAGED ) 194 | /* Generated */ }} // Close namespace TA.Lib 195 | /* Generated */ #endif 196 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 197 | 198 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_PVI.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * 41 | * Change history: 42 | * 43 | * MMDDYY BY Description 44 | * ------------------------------------------------------------------- 45 | * 120802 MF Template creation. 46 | * 47 | */ 48 | 49 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 50 | /* All code within this section is automatically 51 | * generated by gen_code. Any modification will be lost 52 | * next time gen_code is run. 53 | */ 54 | /* Generated */ 55 | /* Generated */ #if defined( _MANAGED ) 56 | /* Generated */ #using 57 | /* Generated */ #include "Core.h" 58 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (TA_INTERNAL_ERROR) 59 | /* Generated */ namespace TA { namespace Library { 60 | /* Generated */ #else 61 | /* Generated */ #include 62 | /* Generated */ #include 63 | /* Generated */ #include "ta_func.h" 64 | /* Generated */ #endif 65 | /* Generated */ 66 | /* Generated */ #ifndef TA_UTILITY_H 67 | /* Generated */ #include "ta_utility.h" 68 | /* Generated */ #endif 69 | /* Generated */ 70 | /* Generated */ #ifndef TA_MEMORY_H 71 | /* Generated */ #include "ta_memory.h" 72 | /* Generated */ #endif 73 | /* Generated */ 74 | /* Generated */ #define TA_PREFIX(x) TA_##x 75 | /* Generated */ #define INPUT_TYPE double 76 | /* Generated */ 77 | /* Generated */ #if defined( _MANAGED ) 78 | /* Generated */ int Core::PVI_Lookback( /* Generated */ void ) 79 | /* Generated */ 80 | /* Generated */ #else 81 | /* Generated */ int TA_PVI_Lookback( /* Generated */ void ) 82 | /* Generated */ 83 | /* Generated */ #endif 84 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 85 | { 86 | /* insert lookback code here. */ 87 | return 0; 88 | } 89 | 90 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 91 | /* 92 | * TA_PVI - Positive Volume Index 93 | * 94 | * Input = Close, Volume 95 | * Output = double 96 | * 97 | */ 98 | /* Generated */ 99 | /* Generated */ #if defined( _MANAGED ) 100 | /* Generated */ enum Core::TA_RetCode Core::PVI( int startIdx, 101 | /* Generated */ int endIdx, 102 | /* Generated */ double inClose __gc [], 103 | /* Generated */ int inVolume __gc [], 104 | /* Generated */ [OutAttribute]Int32 REF(outBegIdx), 105 | /* Generated */ [OutAttribute]Int32 REF(outNBElement), 106 | /* Generated */ double outReal __gc [] ) 107 | /* Generated */ #else 108 | /* Generated */ TA_RetCode TA_PVI( int startIdx, 109 | /* Generated */ int endIdx, 110 | /* Generated */ const double inClose[], 111 | /* Generated */ const int inVolume[], 112 | /* Generated */ int *outBegIdx, 113 | /* Generated */ int *outNBElement, 114 | /* Generated */ double outReal[] ) 115 | /* Generated */ #endif 116 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 117 | { 118 | /* insert local variable here */ 119 | 120 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 121 | /* Generated */ 122 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 123 | /* Generated */ 124 | /* Generated */ /* Validate the requested output range. */ 125 | /* Generated */ if( startIdx < 0 ) 126 | /* Generated */ return TA_OUT_OF_RANGE_START_INDEX; 127 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 128 | /* Generated */ return TA_OUT_OF_RANGE_END_INDEX; 129 | /* Generated */ 130 | /* Generated */ /* Validate the parameters. */ 131 | /* Generated */ /* Verify required price component. */ 132 | /* Generated */ if(!inClose||!inVolume) 133 | /* Generated */ return TA_BAD_PARAM; 134 | /* Generated */ 135 | /* Generated */ if( outReal == NULL ) 136 | /* Generated */ return TA_BAD_PARAM; 137 | /* Generated */ 138 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 139 | /* Generated */ 140 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 141 | 142 | /* Insert TA function code here. */ 143 | 144 | /* Default return values */ 145 | *outBegIdx = 0; 146 | *outNBElement = 0; 147 | 148 | return TA_SUCCESS; 149 | } 150 | 151 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 152 | /* Generated */ 153 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 154 | /* Generated */ #if !defined( _MANAGED ) 155 | /* Generated */ #undef TA_PREFIX 156 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 157 | /* Generated */ #endif 158 | /* Generated */ #undef INPUT_TYPE 159 | /* Generated */ #define INPUT_TYPE float 160 | /* Generated */ #if defined( _MANAGED ) 161 | /* Generated */ enum Core::TA_RetCode Core::PVI( int startIdx, 162 | /* Generated */ int endIdx, 163 | /* Generated */ float inClose __gc [], 164 | /* Generated */ int inVolume __gc [], 165 | /* Generated */ [OutAttribute]Int32 REF(outBegIdx), 166 | /* Generated */ [OutAttribute]Int32 REF(outNBElement), 167 | /* Generated */ double outReal __gc [] ) 168 | /* Generated */ #else 169 | /* Generated */ TA_RetCode TA_S_PVI( int startIdx, 170 | /* Generated */ int endIdx, 171 | /* Generated */ const float inClose[], 172 | /* Generated */ const int inVolume[], 173 | /* Generated */ int *outBegIdx, 174 | /* Generated */ int *outNBElement, 175 | /* Generated */ double outReal[] ) 176 | /* Generated */ #endif 177 | /* Generated */ { 178 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 179 | /* Generated */ if( startIdx < 0 ) 180 | /* Generated */ return TA_OUT_OF_RANGE_START_INDEX; 181 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 182 | /* Generated */ return TA_OUT_OF_RANGE_END_INDEX; 183 | /* Generated */ if(!inClose||!inVolume) 184 | /* Generated */ return TA_BAD_PARAM; 185 | /* Generated */ if( outReal == NULL ) 186 | /* Generated */ return TA_BAD_PARAM; 187 | /* Generated */ #endif 188 | /* Generated */ *outBegIdx = 0; 189 | /* Generated */ *outNBElement = 0; 190 | /* Generated */ return TA_SUCCESS; 191 | /* Generated */ } 192 | /* Generated */ 193 | /* Generated */ #if defined( _MANAGED ) 194 | /* Generated */ }} // Close namespace TA.Lib 195 | /* Generated */ #endif 196 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 197 | 198 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_SQRT.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 090807 MF Initial Version 45 | */ 46 | 47 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 48 | /* All code within this section is automatically 49 | * generated by gen_code. Any modification will be lost 50 | * next time gen_code is run. 51 | */ 52 | /* Generated */ 53 | /* Generated */ #if defined( _MANAGED ) 54 | /* Generated */ #include "TA-Lib-Core.h" 55 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError) 56 | /* Generated */ namespace TicTacTec { namespace TA { namespace Library { 57 | /* Generated */ #elif defined( _JAVA ) 58 | /* Generated */ #include "ta_defs.h" 59 | /* Generated */ #include "ta_java_defs.h" 60 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError) 61 | /* Generated */ #else 62 | /* Generated */ #include 63 | /* Generated */ #include 64 | /* Generated */ #include "ta_func.h" 65 | /* Generated */ #endif 66 | /* Generated */ 67 | /* Generated */ #ifndef TA_UTILITY_H 68 | /* Generated */ #include "ta_utility.h" 69 | /* Generated */ #endif 70 | /* Generated */ 71 | /* Generated */ #ifndef TA_MEMORY_H 72 | /* Generated */ #include "ta_memory.h" 73 | /* Generated */ #endif 74 | /* Generated */ 75 | /* Generated */ #define TA_PREFIX(x) TA_##x 76 | /* Generated */ #define INPUT_TYPE double 77 | /* Generated */ 78 | /* Generated */ #if defined( _MANAGED ) 79 | /* Generated */ int Core::SqrtLookback( void ) 80 | /* Generated */ 81 | /* Generated */ #elif defined( _JAVA ) 82 | /* Generated */ public int sqrtLookback( ) 83 | /* Generated */ 84 | /* Generated */ #else 85 | /* Generated */ int TA_SQRT_Lookback( void ) 86 | /* Generated */ 87 | /* Generated */ #endif 88 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 89 | { 90 | /* insert local variable here */ 91 | 92 | /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 93 | /* Generated */ /* No parameters to validate. */ 94 | /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 95 | 96 | /* insert lookback code here. */ 97 | 98 | return 0; 99 | } 100 | 101 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 102 | /* 103 | * TA_SQRT - Vector Square Root 104 | * 105 | * Input = double 106 | * Output = double 107 | * 108 | */ 109 | /* Generated */ 110 | /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) 111 | /* Generated */ enum class Core::RetCode Core::Sqrt( int startIdx, 112 | /* Generated */ int endIdx, 113 | /* Generated */ SubArray^ inReal, 114 | /* Generated */ [Out]int% outBegIdx, 115 | /* Generated */ [Out]int% outNBElement, 116 | /* Generated */ cli::array^ outReal ) 117 | /* Generated */ #elif defined( _MANAGED ) 118 | /* Generated */ enum class Core::RetCode Core::Sqrt( int startIdx, 119 | /* Generated */ int endIdx, 120 | /* Generated */ cli::array^ inReal, 121 | /* Generated */ [Out]int% outBegIdx, 122 | /* Generated */ [Out]int% outNBElement, 123 | /* Generated */ cli::array^ outReal ) 124 | /* Generated */ #elif defined( _JAVA ) 125 | /* Generated */ public RetCode sqrt( int startIdx, 126 | /* Generated */ int endIdx, 127 | /* Generated */ double inReal[], 128 | /* Generated */ MInteger outBegIdx, 129 | /* Generated */ MInteger outNBElement, 130 | /* Generated */ double outReal[] ) 131 | /* Generated */ #else 132 | /* Generated */ TA_RetCode TA_SQRT( int startIdx, 133 | /* Generated */ int endIdx, 134 | /* Generated */ const double inReal[], 135 | /* Generated */ int *outBegIdx, 136 | /* Generated */ int *outNBElement, 137 | /* Generated */ double outReal[] ) 138 | /* Generated */ #endif 139 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 140 | { 141 | /* insert local variable here */ 142 | int outIdx; 143 | int i; 144 | 145 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 146 | /* Generated */ 147 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 148 | /* Generated */ 149 | /* Generated */ /* Validate the requested output range. */ 150 | /* Generated */ if( startIdx < 0 ) 151 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 152 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 153 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 154 | /* Generated */ 155 | /* Generated */ #if !defined(_JAVA) 156 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 157 | /* Generated */ #endif /* !defined(_JAVA)*/ 158 | /* Generated */ #if !defined(_JAVA) 159 | /* Generated */ if( !outReal ) 160 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 161 | /* Generated */ 162 | /* Generated */ #endif /* !defined(_JAVA) */ 163 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 164 | /* Generated */ 165 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 166 | 167 | /* Insert TA function code here. */ 168 | 169 | /* Default return values */ 170 | for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 171 | { 172 | outReal[outIdx] = std_sqrt(inReal[i]); 173 | } 174 | 175 | VALUE_HANDLE_DEREF(outNBElement) = outIdx; 176 | VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 177 | 178 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 179 | } 180 | 181 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 182 | /* Generated */ 183 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 184 | /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA ) 185 | /* Generated */ #undef TA_PREFIX 186 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 187 | /* Generated */ #endif 188 | /* Generated */ #undef INPUT_TYPE 189 | /* Generated */ #define INPUT_TYPE float 190 | /* Generated */ #if defined( _MANAGED ) 191 | /* Generated */ enum class Core::RetCode Core::Sqrt( int startIdx, 192 | /* Generated */ int endIdx, 193 | /* Generated */ cli::array^ inReal, 194 | /* Generated */ [Out]int% outBegIdx, 195 | /* Generated */ [Out]int% outNBElement, 196 | /* Generated */ cli::array^ outReal ) 197 | /* Generated */ #elif defined( _JAVA ) 198 | /* Generated */ public RetCode sqrt( int startIdx, 199 | /* Generated */ int endIdx, 200 | /* Generated */ float inReal[], 201 | /* Generated */ MInteger outBegIdx, 202 | /* Generated */ MInteger outNBElement, 203 | /* Generated */ double outReal[] ) 204 | /* Generated */ #else 205 | /* Generated */ TA_RetCode TA_S_SQRT( int startIdx, 206 | /* Generated */ int endIdx, 207 | /* Generated */ const float inReal[], 208 | /* Generated */ int *outBegIdx, 209 | /* Generated */ int *outNBElement, 210 | /* Generated */ double outReal[] ) 211 | /* Generated */ #endif 212 | /* Generated */ { 213 | /* Generated */ int outIdx; 214 | /* Generated */ int i; 215 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 216 | /* Generated */ if( startIdx < 0 ) 217 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 218 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 219 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 220 | /* Generated */ #if !defined(_JAVA) 221 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 222 | /* Generated */ #endif 223 | /* Generated */ #if !defined(_JAVA) 224 | /* Generated */ if( !outReal ) 225 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 226 | /* Generated */ #endif 227 | /* Generated */ #endif 228 | /* Generated */ for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 229 | /* Generated */ { 230 | /* Generated */ outReal[outIdx] = std_sqrt(inReal[i]); 231 | /* Generated */ } 232 | /* Generated */ VALUE_HANDLE_DEREF(outNBElement) = outIdx; 233 | /* Generated */ VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 234 | /* Generated */ return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 235 | /* Generated */ } 236 | /* Generated */ 237 | /* Generated */ #if defined( _MANAGED ) 238 | /* Generated */ }}} // Close namespace TicTacTec.TA.Lib 239 | /* Generated */ #endif 240 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 241 | 242 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_TAN.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * 40 | * Change history: 41 | * 42 | * MMDDYY BY Description 43 | * ------------------------------------------------------------------- 44 | * 090807 MF Initial Version 45 | */ 46 | 47 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 48 | /* All code within this section is automatically 49 | * generated by gen_code. Any modification will be lost 50 | * next time gen_code is run. 51 | */ 52 | /* Generated */ 53 | /* Generated */ #if defined( _MANAGED ) 54 | /* Generated */ #include "TA-Lib-Core.h" 55 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError) 56 | /* Generated */ namespace TicTacTec { namespace TA { namespace Library { 57 | /* Generated */ #elif defined( _JAVA ) 58 | /* Generated */ #include "ta_defs.h" 59 | /* Generated */ #include "ta_java_defs.h" 60 | /* Generated */ #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError) 61 | /* Generated */ #else 62 | /* Generated */ #include 63 | /* Generated */ #include 64 | /* Generated */ #include "ta_func.h" 65 | /* Generated */ #endif 66 | /* Generated */ 67 | /* Generated */ #ifndef TA_UTILITY_H 68 | /* Generated */ #include "ta_utility.h" 69 | /* Generated */ #endif 70 | /* Generated */ 71 | /* Generated */ #ifndef TA_MEMORY_H 72 | /* Generated */ #include "ta_memory.h" 73 | /* Generated */ #endif 74 | /* Generated */ 75 | /* Generated */ #define TA_PREFIX(x) TA_##x 76 | /* Generated */ #define INPUT_TYPE double 77 | /* Generated */ 78 | /* Generated */ #if defined( _MANAGED ) 79 | /* Generated */ int Core::TanLookback( void ) 80 | /* Generated */ 81 | /* Generated */ #elif defined( _JAVA ) 82 | /* Generated */ public int tanLookback( ) 83 | /* Generated */ 84 | /* Generated */ #else 85 | /* Generated */ int TA_TAN_Lookback( void ) 86 | /* Generated */ 87 | /* Generated */ #endif 88 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 89 | { 90 | /* insert local variable here */ 91 | 92 | /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 93 | /* Generated */ /* No parameters to validate. */ 94 | /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/ 95 | 96 | /* insert lookback code here. */ 97 | 98 | return 0; 99 | } 100 | 101 | /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 102 | /* 103 | * TA_TAN - Vector Trigonometric Tan 104 | * 105 | * Input = double 106 | * Output = double 107 | * 108 | */ 109 | /* Generated */ 110 | /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY ) 111 | /* Generated */ enum class Core::RetCode Core::Tan( int startIdx, 112 | /* Generated */ int endIdx, 113 | /* Generated */ SubArray^ inReal, 114 | /* Generated */ [Out]int% outBegIdx, 115 | /* Generated */ [Out]int% outNBElement, 116 | /* Generated */ cli::array^ outReal ) 117 | /* Generated */ #elif defined( _MANAGED ) 118 | /* Generated */ enum class Core::RetCode Core::Tan( int startIdx, 119 | /* Generated */ int endIdx, 120 | /* Generated */ cli::array^ inReal, 121 | /* Generated */ [Out]int% outBegIdx, 122 | /* Generated */ [Out]int% outNBElement, 123 | /* Generated */ cli::array^ outReal ) 124 | /* Generated */ #elif defined( _JAVA ) 125 | /* Generated */ public RetCode tan( int startIdx, 126 | /* Generated */ int endIdx, 127 | /* Generated */ double inReal[], 128 | /* Generated */ MInteger outBegIdx, 129 | /* Generated */ MInteger outNBElement, 130 | /* Generated */ double outReal[] ) 131 | /* Generated */ #else 132 | /* Generated */ TA_RetCode TA_TAN( int startIdx, 133 | /* Generated */ int endIdx, 134 | /* Generated */ const double inReal[], 135 | /* Generated */ int *outBegIdx, 136 | /* Generated */ int *outNBElement, 137 | /* Generated */ double outReal[] ) 138 | /* Generated */ #endif 139 | /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/ 140 | { 141 | /* insert local variable here */ 142 | int outIdx; 143 | int i; 144 | 145 | /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 146 | /* Generated */ 147 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 148 | /* Generated */ 149 | /* Generated */ /* Validate the requested output range. */ 150 | /* Generated */ if( startIdx < 0 ) 151 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 152 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 153 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 154 | /* Generated */ 155 | /* Generated */ #if !defined(_JAVA) 156 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 157 | /* Generated */ #endif /* !defined(_JAVA)*/ 158 | /* Generated */ #if !defined(_JAVA) 159 | /* Generated */ if( !outReal ) 160 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 161 | /* Generated */ 162 | /* Generated */ #endif /* !defined(_JAVA) */ 163 | /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */ 164 | /* Generated */ 165 | /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/ 166 | 167 | /* Insert TA function code here. */ 168 | 169 | /* Default return values */ 170 | for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 171 | { 172 | outReal[outIdx] = std_tan(inReal[i]); 173 | } 174 | 175 | VALUE_HANDLE_DEREF(outNBElement) = outIdx; 176 | VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 177 | 178 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 179 | } 180 | 181 | /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 182 | /* Generated */ 183 | /* Generated */ #define USE_SINGLE_PRECISION_INPUT 184 | /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA ) 185 | /* Generated */ #undef TA_PREFIX 186 | /* Generated */ #define TA_PREFIX(x) TA_S_##x 187 | /* Generated */ #endif 188 | /* Generated */ #undef INPUT_TYPE 189 | /* Generated */ #define INPUT_TYPE float 190 | /* Generated */ #if defined( _MANAGED ) 191 | /* Generated */ enum class Core::RetCode Core::Tan( int startIdx, 192 | /* Generated */ int endIdx, 193 | /* Generated */ cli::array^ inReal, 194 | /* Generated */ [Out]int% outBegIdx, 195 | /* Generated */ [Out]int% outNBElement, 196 | /* Generated */ cli::array^ outReal ) 197 | /* Generated */ #elif defined( _JAVA ) 198 | /* Generated */ public RetCode tan( int startIdx, 199 | /* Generated */ int endIdx, 200 | /* Generated */ float inReal[], 201 | /* Generated */ MInteger outBegIdx, 202 | /* Generated */ MInteger outNBElement, 203 | /* Generated */ double outReal[] ) 204 | /* Generated */ #else 205 | /* Generated */ TA_RetCode TA_S_TAN( int startIdx, 206 | /* Generated */ int endIdx, 207 | /* Generated */ const float inReal[], 208 | /* Generated */ int *outBegIdx, 209 | /* Generated */ int *outNBElement, 210 | /* Generated */ double outReal[] ) 211 | /* Generated */ #endif 212 | /* Generated */ { 213 | /* Generated */ int outIdx; 214 | /* Generated */ int i; 215 | /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK 216 | /* Generated */ if( startIdx < 0 ) 217 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex); 218 | /* Generated */ if( (endIdx < 0) || (endIdx < startIdx)) 219 | /* Generated */ return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex); 220 | /* Generated */ #if !defined(_JAVA) 221 | /* Generated */ if( !inReal ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 222 | /* Generated */ #endif 223 | /* Generated */ #if !defined(_JAVA) 224 | /* Generated */ if( !outReal ) 225 | /* Generated */ return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 226 | /* Generated */ #endif 227 | /* Generated */ #endif 228 | /* Generated */ for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ ) 229 | /* Generated */ { 230 | /* Generated */ outReal[outIdx] = std_tan(inReal[i]); 231 | /* Generated */ } 232 | /* Generated */ VALUE_HANDLE_DEREF(outNBElement) = outIdx; 233 | /* Generated */ VALUE_HANDLE_DEREF(outBegIdx) = startIdx; 234 | /* Generated */ return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 235 | /* Generated */ } 236 | /* Generated */ 237 | /* Generated */ #if defined( _MANAGED ) 238 | /* Generated */ }}} // Close namespace TicTacTec.TA.Lib 239 | /* Generated */ #endif 240 | /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/ 241 | 242 | -------------------------------------------------------------------------------- /Cocoa-KLine/Cocoa_KLine/TALib/src/ta_func/ta_utility.c: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* List of contributors: 35 | * 36 | * Initial Name/description 37 | * ------------------------------------------------------------------- 38 | * MF Mario Fortier 39 | * RM Robert Meier (talib@meierlim.com http://www.meierlim.com) 40 | * 41 | * Change history: 42 | * 43 | * MMDDYY BY Description 44 | * ------------------------------------------------------------------- 45 | * 052603 MF Adapt code to compile with .NET Managed C++ 46 | * 123004 RM,MF Adapt code to work with Visual Studio 2005 47 | * 48 | */ 49 | 50 | #if defined( _MANAGED ) 51 | #using 52 | #include "TA-Lib-Core.h" 53 | #include "ta_memory.h" 54 | namespace TicTacTec { namespace TA { namespace Library { 55 | #else 56 | #include "ta_utility.h" 57 | #include "ta_func.h" 58 | #include "ta_memory.h" 59 | #endif 60 | 61 | #if defined( _MANAGED ) 62 | enum class Core::RetCode Core::SetUnstablePeriod( enum class FuncUnstId id, 63 | unsigned int unstablePeriod ) 64 | #else 65 | TA_RetCode TA_SetUnstablePeriod( TA_FuncUnstId id, 66 | unsigned int unstablePeriod ) 67 | #endif 68 | { 69 | int i; 70 | 71 | if( id > ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll) ) 72 | return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam); 73 | 74 | if( id == ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll) ) 75 | { 76 | for( i=0; i < (int)ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll); i++ ) 77 | { 78 | #if defined( _MANAGED ) 79 | Globals->unstablePeriod[(int)i] = unstablePeriod; 80 | #else 81 | TA_Globals->unstablePeriod[i] = unstablePeriod; 82 | #endif 83 | } 84 | } 85 | else 86 | { 87 | #if defined( _MANAGED ) 88 | Globals->unstablePeriod[(int)id] = unstablePeriod; 89 | #else 90 | TA_Globals->unstablePeriod[id] = unstablePeriod; 91 | #endif 92 | } 93 | 94 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 95 | } 96 | 97 | #if defined( _MANAGED ) 98 | unsigned int Core::GetUnstablePeriod( enum class FuncUnstId id ) 99 | #else 100 | unsigned int TA_GetUnstablePeriod( TA_FuncUnstId id ) 101 | #endif 102 | { 103 | if( id >= ENUM_VALUE(FuncUnstId,TA_FUNC_UNST_ALL,FuncUnstAll) ) 104 | return 0; 105 | 106 | #if defined( _MANAGED ) 107 | return Globals->unstablePeriod[(int)id]; 108 | #else 109 | return TA_Globals->unstablePeriod[id]; 110 | #endif 111 | } 112 | 113 | #if defined( _MANAGED ) 114 | enum class Core::RetCode Core::SetCompatibility( enum class Compatibility value ) 115 | #else 116 | TA_RetCode TA_SetCompatibility( TA_Compatibility value ) 117 | #endif 118 | { 119 | TA_GLOBALS_COMPATIBILITY = value; 120 | return ENUM_VALUE(RetCode,TA_SUCCESS,Success); 121 | } 122 | 123 | #if defined( _MANAGED ) 124 | enum class Core::Compatibility Core::GetCompatibility( void ) 125 | #else 126 | TA_Compatibility TA_GetCompatibility( void ) 127 | #endif 128 | { 129 | return TA_GLOBALS_COMPATIBILITY; 130 | } 131 | 132 | #if defined( _MANAGED ) 133 | }}} // Close namespace TicTacTec::TA::Lib 134 | #endif 135 | -------------------------------------------------------------------------------- /Cocoa-KLine/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSAppTransportSecurity 24 | 25 | NSAllowsArbitraryLoads 26 | 27 | 28 | UILaunchStoryboardName 29 | LaunchScreen 30 | UIMainStoryboardFile 31 | Main 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | 40 | UISupportedInterfaceOrientations~ipad 41 | 42 | UIInterfaceOrientationPortrait 43 | UIInterfaceOrientationPortraitUpsideDown 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | UIViewControllerBasedStatusBarAppearance 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Cocoa-KLine/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Cocoa-KLine/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Cocoa-KLine 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "Cocoa_KLine.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (nonatomic, strong) Cocoa_ChartManager *chartsView; 15 | @property (nonatomic, assign) NSInteger pageIndex; 16 | @property (nonatomic, strong) NSDateFormatter *formatter; 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view, typically from a nib. 25 | 26 | self.view.backgroundColor = COLOR_BACKGROUND; 27 | _chartsView = [[Cocoa_ChartManager alloc] initWithFrame:CGRectMake(0, 64, kSCREENWIDTH, kSCREENWIDTH)]; 28 | [self.view addSubview:_chartsView]; 29 | _pageIndex = 1; 30 | [self getOneDayStockData]; 31 | } 32 | 33 | #pragma mark - loadData 34 | 35 | - (NSArray *)getOneDayStockData 36 | { 37 | long long startValue = [[self timestampToString] longLongValue] - _pageIndex * 15*60*100*1000; 38 | 39 | NSString *requestStr = [NSString stringWithFormat:@"https://api.ziniu.io/www/kline/history?resolution=15&start=%@&symbol=XRP_BTC&to=%@", [NSString stringWithFormat:@"%lld",startValue],[self timestampToString]]; 40 | 41 | NSLog(@"requestStr : %@ index : %ld", requestStr, self.pageIndex); 42 | 43 | NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:requestStr]]; 44 | NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); 45 | NSString *str = [[NSString alloc] initWithData:data encoding:enc]; 46 | NSString *regularStr = @"^[^=]*="; 47 | NSError *error = nil; 48 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regularStr options:NSRegularExpressionCaseInsensitive error:&error]; 49 | NSArray *resultArray = [regex matchesInString:str options:0 range:NSMakeRange(0, str.length)]; 50 | NSTextCheckingResult *result = [resultArray firstObject]; 51 | str = [str stringByReplacingOccurrencesOfString:[str substringWithRange:result.range] withString:@""]; 52 | NSArray *klineData = [NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; 53 | 54 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 55 | [self.chartsView.dataArray removeAllObjects]; 56 | [self assignmentKlineData:klineData isSocketLoading:NO]; 57 | }); 58 | 59 | /** 获取了到了股票数据 */ 60 | __weak typeof(self) weakself = self; 61 | self.chartsView.loadmoredataBlock = ^(id DataInfo) { 62 | __strong typeof (self) self = weakself; 63 | 64 | [self getOneDayStockData]; 65 | 66 | }; 67 | 68 | return klineData; 69 | } 70 | 71 | - (void)assignmentKlineData:(NSArray *)resultData isSocketLoading:(BOOL)isSocketLoading 72 | { 73 | NSMutableArray *tempArray = [NSMutableArray array]; 74 | 75 | if ([resultData isKindOfClass:[NSArray class]]) { 76 | 77 | NSArray *dataArray = resultData; 78 | 79 | for (int i = 0; i 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cocoa-KLineTests/Cocoa_KLineTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_KLineTests.m 3 | // Cocoa-KLineTests 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Cocoa_KLineTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation Cocoa_KLineTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Cocoa-KLineTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Cocoa-KLineUITests/Cocoa_KLineUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // Cocoa_KLineUITests.m 3 | // Cocoa-KLineUITests 4 | // 5 | // Created by Yochi on 2018/7/31. 6 | // Copyright © 2018年 Yochi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Cocoa_KLineUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation Cocoa_KLineUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Cocoa-KLineUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cocoa-KLine 2 | --------------------------------------------------------------------------------