Implement candle command
This commit is contained in:
@@ -478,7 +478,7 @@
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
@@ -487,7 +487,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.3;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
|
||||
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++20";
|
||||
@@ -516,7 +516,7 @@
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
@@ -525,7 +525,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.3;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
|
||||
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++20";
|
||||
|
||||
@@ -69,6 +69,7 @@ extension Domestic {
|
||||
"appkey": credential.appKey,
|
||||
"appsecret": credential.appSecret,
|
||||
"tr_id": trId,
|
||||
"tr_cont": isNext ? "N": " ",
|
||||
"custtype": CustomerType.personal.rawValue,
|
||||
]
|
||||
}
|
||||
@@ -78,7 +79,7 @@ extension Domestic {
|
||||
"FID_COND_MRKT_DIV_CODE": "J",
|
||||
"FID_INPUT_ISCD": productNo,
|
||||
"FID_INPUT_HOUR_1": startTodayTime,
|
||||
"FID_PW_DATA_INCU_YN": "N",
|
||||
"FID_PW_DATA_INCU_YN": "Y",
|
||||
]
|
||||
}
|
||||
public var result: KResult? = nil
|
||||
@@ -92,12 +93,14 @@ extension Domestic {
|
||||
public let accessToken: String
|
||||
let productNo: String
|
||||
let startTodayTime: String // HHMMSS
|
||||
let isNext: Bool
|
||||
|
||||
public init(credential: Credential, accessToken: String, productNo: String, startTodayTime: String) {
|
||||
public init(credential: Credential, accessToken: String, productNo: String, startTodayTime: String, isNext: Bool) {
|
||||
self.credential = credential
|
||||
self.accessToken = accessToken
|
||||
self.productNo = productNo
|
||||
self.startTodayTime = startTodayTime
|
||||
self.isNext = isNext
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,7 +142,7 @@ extension KissAccount {
|
||||
return
|
||||
}
|
||||
|
||||
let request = Domestic.StockTodayMinutePriceRequest(credential: credential, accessToken: accessToken, productNo: productNo, startTodayTime: startTodayTime.HHmmss)
|
||||
let request = Domestic.StockTodayMinutePriceRequest(credential: credential, accessToken: accessToken, productNo: productNo, startTodayTime: startTodayTime.HHmmss, isNext: false)
|
||||
request.query { result in
|
||||
switch result {
|
||||
case .success(let result):
|
||||
|
||||
@@ -416,7 +416,7 @@ public struct MinutePriceResult: Codable {
|
||||
public let resultCode: String
|
||||
public let messageCode: String
|
||||
public let message: String
|
||||
public let output1: [OutputSummary]?
|
||||
public let output1: OutputSummary?
|
||||
public let output2: [OutputPrice]?
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.3;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@@ -268,7 +268,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.3;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
|
||||
@@ -39,3 +39,15 @@ extension String {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
extension Date {
|
||||
public func changing(hour: Int, min: Int, sec: Int, timeZone: String = "KST") -> Date? {
|
||||
let sets: Set<Calendar.Component> = [.year, .month, .day, .hour, .minute, .second]
|
||||
var components = Calendar.current.dateComponents(sets, from: self)
|
||||
components.timeZone = TimeZone(abbreviation: timeZone)
|
||||
components.hour = hour
|
||||
components.minute = min
|
||||
components.second = sec
|
||||
return Calendar.current.date(from: components)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ extension KissConsole {
|
||||
// TODO: work
|
||||
|
||||
do {
|
||||
let success = try await account?.cancelOrder()
|
||||
let _ = try await account?.cancelOrder()
|
||||
} catch {
|
||||
print("\(error)")
|
||||
}
|
||||
@@ -396,6 +396,7 @@ extension KissConsole {
|
||||
do {
|
||||
let result = try await account!.getCurrentPrice(productNo: productNo)
|
||||
if let output = result.output {
|
||||
currentShortCode = output.shortProductCode
|
||||
let productName = getProduct(shortCode: output.shortProductCode)?.itemName ?? ""
|
||||
print("\t종목명: ", productName)
|
||||
print("\t업종명: ", output.koreanMarketName, output.koreanBusinessTypeName)
|
||||
@@ -425,7 +426,26 @@ extension KissConsole {
|
||||
|
||||
|
||||
private func onCandle(_ args: [String]) async {
|
||||
|
||||
let productNo: String? = (args.isEmpty ? currentShortCode: args[0])
|
||||
guard let productNo = productNo else {
|
||||
print("Invalid productNo")
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
let lastWeek = Date().addingTimeInterval(-60 * 60 * 24 * 7)
|
||||
guard let startTime = lastWeek.changing(hour: 9, min: 0, sec: 0) else {
|
||||
print("Invalid start time")
|
||||
return
|
||||
}
|
||||
let result = try await account!.getMinutePrice(productNo: productNo, startTodayTime: startTime)
|
||||
|
||||
// TODO: work on result
|
||||
|
||||
print(result)
|
||||
} catch {
|
||||
print("\(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ func test_json_result() {
|
||||
|
||||
|
||||
func test_xml_result() {
|
||||
/*
|
||||
let str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><response><header><resultCode>00</resultCode><resultMsg>NORMAL SERVICE.</resultMsg></header><body><items><item><korSecnNm>이스트아시아홀딩스인베스트먼트리미티드</korSecnNm><shotnIsin>900110</shotnIsin></item><item><korSecnNm>삼천당제약</korSecnNm><shotnIsin>000250</shotnIsin></item><item><korSecnNm>중앙에너비스</korSecnNm><shotnIsin>000440</shotnIsin></item><item><korSecnNm>신라섬유</korSecnNm><shotnIsin>001000</shotnIsin></item><item><korSecnNm>안국약품</korSecnNm><shotnIsin>001540</shotnIsin></item><item><korSecnNm>무림에스피</korSecnNm><shotnIsin>001810</shotnIsin></item><item><korSecnNm>이화공영</korSecnNm><shotnIsin>001840</shotnIsin></item><item><korSecnNm>피에스텍</korSecnNm><shotnIsin>002230</shotnIsin></item><item><korSecnNm>삼일기업공사</korSecnNm><shotnIsin>002290</shotnIsin></item><item><korSecnNm>한일사료</korSecnNm><shotnIsin>005860</shotnIsin></item></items><numOfRows>10</numOfRows><pageNo>1</pageNo><totalCount>1637</totalCount></body></response>"
|
||||
|
||||
let data = Data(str.utf8)
|
||||
@@ -97,4 +98,5 @@ func test_xml_result() {
|
||||
print(helper.result)
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user