-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add useParam* hooks and encodePath, decodePath (#36)
- Loading branch information
Showing
16 changed files
with
84 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Use OHLC with parameter | ||
*/ | ||
export const useParamOHLC = (key: string) => { | ||
const OHLCKey = useParamSchema<string>(key, { | ||
type: "string", | ||
format: "OHLC-key", | ||
}); | ||
const { datasource_id, product_id, period_in_sec } = useMemo(() => { | ||
const [datasource_id = "", product_id = "", _period_in_sec] = decodePath( | ||
OHLCKey || "" | ||
); | ||
const period_in_sec = +_period_in_sec; | ||
return { datasource_id, product_id, period_in_sec }; | ||
}, []); | ||
|
||
const periods = useOHLC(datasource_id, product_id, period_in_sec); | ||
return { datasource_id, product_id, period_in_sec, ...periods }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Use parameter as Product | ||
* @param key - parameter's name | ||
*/ | ||
export const useParamProduct = (key: string): IProduct => { | ||
const productKey = useParamSchema<string>(key, { | ||
type: "string", | ||
format: "product-key", | ||
}); | ||
|
||
const { datasource_id, product_id } = useMemo(() => { | ||
const [datasource_id = "", product_id = ""] = decodePath(productKey || ""); | ||
return { datasource_id, product_id }; | ||
}, []); | ||
return useProduct(datasource_id, product_id); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { useSinglePosition } from "@libs"; | ||
/** | ||
* Derive a PositionLimit account from the source account. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { | |
useMAX, | ||
useMIN, | ||
useParamNumber, | ||
useParamOHLC, | ||
useSimplePositionManager, | ||
} from "@libs"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import { | ||
useHPFilter, | ||
useParamNumber, | ||
useParamOHLC, | ||
useSMA, | ||
useSimplePositionManager, | ||
} from "@libs"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters