Skip to content

Commit abe4ed5

Browse files
committed
Add option to use flexible number types.
1 parent 6d853d6 commit abe4ed5

File tree

110 files changed

+16884
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+16884
-54
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ https://github.com/FiretronP75/HaasScriptLuaTypes/releases
2020
5. Run `yarn`.
2121
6. Run `yarn start`.
2222
7. Read and follow the help output in the console (pasted here for convenience):
23-
> This script requires 4 parameters: environment, file extension, interface key, user id.
23+
> This script requires 5 parameters: environment, file extension, flexible numbers, interface key, user id.
2424
>
2525
> Environment may be "production" or "staging". Anything other than "staging" (case-insensitive) assumes "production".
2626
>
2727
> File extension may be anything, but "lua" or "hs" is recommended.
2828
>
29+
> Flexible numbers may be "flex-num" or "not-flex-num". Anything other than "flex-num" (case-insensitive) assumes "not-flex-num".
30+
>
2931
> Interface key and user id can be copied from a web browser session that has not expired yet.
3032
>
3133
> Example: `yarn start prod lua 30w3jrv4pa-fj209-qj0934-295cn-qv9r0cev fm02q9rf0q2fqr2cv98r4v8q9tv8rq48`
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
--- Array Helpers
2+
3+
--- Adds an element to an existing array.
4+
--- @param input any Source data.
5+
--- @param element any Element which to add to the array.
6+
--- @return any Returns the input array.
7+
function ArrayAdd(input, element) end
8+
9+
--- The optional parameters of ArrayAny.
10+
--- @shape OptionalParametersOf_ArrayAny
11+
--- @field value any | nil Optional value to match.
12+
13+
--- Returns true if the array contains any element or an element matches a specific value.
14+
--- @param input any Source data.
15+
--- @param value any Optional - Optional value to match.
16+
--- @return boolean Returns true if the input has any elements or if 'value' is defined when any of the elements matches the value. Output Suggestions: Or, And, IsTrue, IsFalse, Not, BoolToSignal, IfElse, Switch, IfElseIf, DoBuy, DoLong, DoSell, DoShort, DoExitPosition, DoFlipPosition, DoSignal, PlaceBuyOrder, PlaceSellOrder, PlaceGoLongOrder, PlaceGoShortOrder, PlaceExitLongOrder, PlaceExitShortOrder, PlaceExitPositionOrder, PlaceCancelledOrder
17+
--- @overload fun(input: any): boolean
18+
--- @overload fun(input: any, optionalParameters: OptionalParametersOf_ArrayAny): boolean
19+
function ArrayAny(input, value) end
20+
21+
--- Concatenates two arrays.
22+
--- @param array1 any First array.
23+
--- @param array2 any Second array.
24+
--- @return any Returns the concatenated array.
25+
function ArrayConcat(array1, array2) end
26+
27+
--- The optional parameters of ArrayContains.
28+
--- @shape OptionalParametersOf_ArrayContains
29+
--- @field value any | nil Optional value to match.
30+
31+
--- Returns true if the array contains any element or an element matches a specific value.
32+
--- @param input any Source data.
33+
--- @param value any Optional - Optional value to match.
34+
--- @return boolean Returns true if the input has any elements or if 'value' is defined when any of the elements matches the value. Output Suggestions: Or, And, IsTrue, IsFalse, Not, BoolToSignal, IfElse, Switch, IfElseIf, DoBuy, DoLong, DoSell, DoShort, DoExitPosition, DoFlipPosition, DoSignal, PlaceBuyOrder, PlaceSellOrder, PlaceGoLongOrder, PlaceGoShortOrder, PlaceExitLongOrder, PlaceExitShortOrder, PlaceExitPositionOrder, PlaceCancelledOrder
35+
--- @overload fun(input: any): boolean
36+
--- @overload fun(input: any, optionalParameters: OptionalParametersOf_ArrayContains): boolean
37+
function ArrayContains(input, value) end
38+
39+
--- Returns a new list with only unique elements. In other words; removes all duplicates.
40+
--- @param input any Source data.
41+
--- @return any Returns the unique values of the input.
42+
function ArrayDistinct(input) end
43+
44+
--- The optional parameters of ArrayFilter.
45+
--- @shape OptionalParametersOf_ArrayFilter
46+
--- @field filterType Enum | nil The type of filter to use. Default is ArrayFilterInclusiveType.
47+
48+
--- Returns a new list with elements that only matches the value. Matching-rules specified by filterType.
49+
--- @param input any Source data.
50+
--- @param value any Value to match.
51+
--- @param filterType Enum Optional - The type of filter to use. Default is ArrayFilterInclusiveType. Suggestions: ArrayFilterInclusiveType, ArrayFilterExclusiveType, ArrayFilterLessThanType, ArrayFilterGreaterThanType
52+
--- @return any Returns the list.
53+
--- @overload fun(input: any, value: any): any
54+
--- @overload fun(input: any, value: any, optionalParameters: OptionalParametersOf_ArrayFilter): any
55+
function ArrayFilter(input, value, filterType) end
56+
57+
--- The optional parameters of ArrayFind.
58+
--- @shape OptionalParametersOf_ArrayFind
59+
--- @field filterType Enum | nil The type of filter to use. Default is ArrayFilterInclusiveType.
60+
61+
--- Returns a new list of indices of the matching values. Matching-rules specified by filterType.
62+
--- @param input any Source data.
63+
--- @param value any Value to match.
64+
--- @param filterType Enum Optional - The type of filter to use. Default is ArrayFilterInclusiveType. Suggestions: ArrayFilterInclusiveType, ArrayFilterExclusiveType, ArrayFilterLessThanType, ArrayFilterGreaterThanType
65+
--- @return any Returns the list.
66+
--- @overload fun(input: any, value: any): any
67+
--- @overload fun(input: any, value: any, optionalParameters: OptionalParametersOf_ArrayFind): any
68+
function ArrayFind(input, value, filterType) end
69+
70+
--- Gets the value on a specific index. A negative index will take from the end of the array.
71+
--- @param input any Source data.
72+
--- @param index number | number[] The index to get. Suggestions: Input
73+
--- @return any Return the value on that index. Output Suggestions: Equals, IsBiggerOrSmallerThan, IsSmallerThan, IsBiggerThan, Compare, Add, Sum, Sub, Mul, Mult, Div, AddPerc, AddPercentage, SubPerc, SubPercentage, Plot
74+
function ArrayGet(input, index) end
75+
76+
--- Gets the value on a specific index. A negative index will take from the end of the array.
77+
--- @param input any Source data.
78+
--- @param index number | number[] The index to get. Suggestions: Input
79+
--- @return any Return the value on that index. Output Suggestions: Equals, IsBiggerOrSmallerThan, IsSmallerThan, IsBiggerThan, Compare, Add, Sum, Sub, Mul, Mult, Div, AddPerc, AddPercentage, SubPerc, SubPercentage, Plot
80+
function ArrayIndex(input, index) end
81+
82+
--- The optional parameters of ArrayLast.
83+
--- @shape OptionalParametersOf_ArrayLast
84+
--- @field offset number | number[] | nil The offset from the last index.
85+
86+
--- Gets the last value of the array with an optional offset.
87+
--- @param input any Source data.
88+
--- @param offset number | number[] Optional - The offset from the last index. Suggestions: Input
89+
--- @return any Return the last value of the array taking the offset into account. Output Suggestions: Equals, IsBiggerOrSmallerThan, IsSmallerThan, IsBiggerThan, Compare, Add, Sum, Sub, Mul, Mult, Div, AddPerc, AddPercentage, SubPerc, SubPercentage, Plot
90+
--- @overload fun(input: any): any
91+
--- @overload fun(input: any, optionalParameters: OptionalParametersOf_ArrayLast): any
92+
function ArrayLast(input, offset) end
93+
94+
--- Remove an item from the end of an array.
95+
--- @param input any Source data.
96+
--- @return any Returns the input array.
97+
function ArrayPop(input) end
98+
99+
--- Removes an element from a specified index.
100+
--- @param input any Source data.
101+
--- @param index number | number[] Index of the element to remove. Suggestions: Input
102+
--- @return any Returns the input array.
103+
function ArrayRemove(input, index) end
104+
105+
--- Replaces a specific value with another value.
106+
--- @param input any Source data.
107+
--- @param oldValue any The old value.
108+
--- @param newValue any The new value.
109+
--- @return any The input with replaced values.
110+
function ArrayReplace(input, oldValue, newValue) end
111+
112+
--- Remove an item from the beginning of an array.
113+
--- @param input any Source data.
114+
--- @return any The input without the first value
115+
function ArrayShift(input) end
116+
117+
--- The optional parameters of ArraySort.
118+
--- @shape OptionalParametersOf_ArraySort
119+
--- @field descendValueing boolean | nil The order of the sort. If set to true, order will be descending. Otherwise ascending.
120+
121+
--- Sorts the array values in ascending or descending order.
122+
--- @param input any Source data.
123+
--- @param descendValueing boolean Optional - The order of the sort. If set to true, order will be descending. Otherwise ascending. Suggestions: And, IsTrue, IsFalse, Not, Or, Equals, IsBiggerThan, IsSmallerThan, IsBiggerOrSmallerThan, IsAnyOrderOpen, IsOrderFilled, IsOrderOpen, IsTradeAmountEnough
124+
--- @return any Returns the sorted array.
125+
--- @overload fun(input: any): any
126+
--- @overload fun(input: any, optionalParameters: OptionalParametersOf_ArraySort): any
127+
function ArraySort(input, descendValueing) end
128+
129+
--- The optional parameters of ArraySum.
130+
--- @shape OptionalParametersOf_ArraySum
131+
--- @field key string | nil The key of the data to be summed.
132+
133+
--- Computes the sum of the array. Can be used in combination with a list of numbers or container results like GetAllOpenOrders() or GetAllFinishedOrders().
134+
--- @param input any Source data.
135+
--- @param key string Optional - The key of the data to be summed.
136+
--- @return number | number[] Returns the sum of the array. Output Suggestions: Equals, IsBiggerOrSmallerThan, IsSmallerThan, IsBiggerThan, Compare, Add, Sum, Sub, Mul, Mult, Div, AddPerc, AddPercentage, SubPerc, SubPercentage, Plot
137+
--- @overload fun(input: any): number | number[]
138+
--- @overload fun(input: any, optionalParameters: OptionalParametersOf_ArraySum): number | number[]
139+
function ArraySum(input, key) end
140+
141+
--- Adds an element to the beginning of an array.
142+
--- @param input any Source data.
143+
--- @param element any Element which to add to the array.
144+
--- @return any The input with the element added in front of the array
145+
function ArrayUnshift(input, element) end
146+
147+
--- The optional parameters of Count.
148+
--- @shape OptionalParametersOf_Count
149+
--- @field value any | nil Optional value to match.
150+
151+
--- Gets the length of an array or the number of occurrences within the array of a specific value.
152+
--- @param input any Source data.
153+
--- @param value any Optional - Optional value to match.
154+
--- @return number | number[] Returns the length of an array or the number of occurrences within the array of a specific value. Output Suggestions: Equals, IsBiggerOrSmallerThan, IsSmallerThan, IsBiggerThan, Compare, Add, Sum, Sub, Mul, Mult, Div, AddPerc, AddPercentage, SubPerc, SubPercentage, Plot
155+
--- @overload fun(input: any): number | number[]
156+
--- @overload fun(input: any, optionalParameters: OptionalParametersOf_Count): number | number[]
157+
function Count(input, value) end
158+
159+
--- The optional parameters of Grab.
160+
--- @shape OptionalParametersOf_Grab
161+
--- @field count number | number[] | nil Number of items to grab.
162+
163+
--- Grabs a range from the array. If count is not set, return all after the offset.
164+
--- @param input any Source data.
165+
--- @param offset number | number[] Offset from start. Suggestions: Input
166+
--- @param count number | number[] Optional - Number of items to grab. Suggestions: Input
167+
--- @return any Specified range from the array.
168+
--- @overload fun(input: any, offset: number | number[]): any
169+
--- @overload fun(input: any, offset: number | number[], optionalParameters: OptionalParametersOf_Grab): any
170+
function Grab(input, offset, count) end
171+
172+
--- Gets an offset amount of the given array.
173+
--- @param input any Source data.
174+
--- @param offset number | number[] Number of record to remove. Suggestions: Input
175+
--- @return any Returns the given array with the offset amount of data removed from it.
176+
function Offset(input, offset) end
177+
178+
--- The optional parameters of Range.
179+
--- @shape OptionalParametersOf_Range
180+
--- @field count number | number[] | nil Number of items to grab.
181+
182+
--- Grabs a range from the array. If count is not set, return all after the offset.
183+
--- @param input any Source data.
184+
--- @param offset number | number[] Offset from start. Suggestions: Input
185+
--- @param count number | number[] Optional - Number of items to grab. Suggestions: Input
186+
--- @return any Specified range from the array.
187+
--- @overload fun(input: any, offset: number | number[]): any
188+
--- @overload fun(input: any, offset: number | number[], optionalParameters: OptionalParametersOf_Range): any
189+
function Range(input, offset, count) end
190+
191+
--- The optional parameters of SourceManager.
192+
--- @shape OptionalParametersOf_SourceManager
193+
--- @field interval number | number[] | nil The interval on which the data is based. Default is the selected main interval.
194+
--- @field cap number | number[] | nil Maximum size of the collection.
195+
--- @field initialValues number[] | nil The initial values when source in initialized
196+
197+
--- Stores numeric values in a collection. Only adds the new value when the candle on the specified interval closed. This results in interval based data.
198+
--- @param newValue number | number[] This value will be added in front of the collection when the candle closed.
199+
--- @param interval number | number[] Optional - The interval on which the data is based. Default is the selected main interval. Suggestions: InputInterval, CurrentInterval
200+
--- @param cap number | number[] Optional - Maximum size of the collection.
201+
--- @param initialValues number[] Optional - The initial values when source in initialized
202+
--- @return number[] Returns the numeric collection. Output Suggestions: Equals, IsBiggerOrSmallerThan, IsSmallerThan, IsBiggerThan, Compare, Add, Sum, Sub, Mul, Mult, Div, AddPerc, AddPercentage, SubPerc, SubPercentage, Plot
203+
--- @overload fun(newValue: number | number[]): number[]
204+
--- @overload fun(newValue: number | number[], interval: number | number[]): number[]
205+
--- @overload fun(newValue: number | number[], interval: number | number[], cap: number | number[]): number[]
206+
--- @overload fun(newValue: number | number[], optionalParameters: OptionalParametersOf_SourceManager): number[]
207+
function SourceManager(newValue, interval, cap, initialValues) end
208+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--- Base
2+
3+
--- Pretend enumeration for all other enumerations to inherit from.
4+
--- @class Enum
5+
6+
--- Pretend enumeration for all color enumerations to inherit from.
7+
--- @class ColorEnum

0 commit comments

Comments
 (0)