MCPcopy
hub / github.com/thrasher-corp/gocryptotrader / New

Function New

exchanges/asset/asset.go:268–315  ·  view source on GitHub ↗

New takes an input matches to relevant package assets

(input string)

Source from the content-addressed store, hash-verified

266
267// New takes an input matches to relevant package assets
268func New(input string) (Item, error) {
269 switch input = strings.ToLower(input); input {
270 case spot:
271 return Spot, nil
272 case margin:
273 return Margin, nil
274 case marginFunding:
275 return MarginFunding, nil
276 case crossMargin:
277 return CrossMargin, nil
278 case deliveryFutures:
279 return DeliveryFutures, nil
280 case index:
281 return Index, nil
282 case binary:
283 return Binary, nil
284 case perpetualContract:
285 return PerpetualContract, nil
286 case perpetualSwap, swap:
287 return PerpetualSwap, nil
288 case spread:
289 return Spread, nil
290 case futures:
291 return Futures, nil
292 case upsideProfitContract:
293 return UpsideProfitContract, nil
294 case downsideProfitContract:
295 return DownsideProfitContract, nil
296 case coinMarginedFutures:
297 return CoinMarginedFutures, nil
298 case usdtMarginedFutures:
299 return USDTMarginedFutures, nil
300 case usdcMarginedFutures:
301 return USDCMarginedFutures, nil
302 case options, "option":
303 return Options, nil
304 case optionCombo:
305 return OptionCombo, nil
306 case futureCombo:
307 return FutureCombo, nil
308 case linearContract:
309 return LinearContract, nil
310 case all:
311 return All, nil
312 default:
313 return 0, fmt.Errorf("%w '%v', only supports %s", ErrNotSupported, input, supportedList)
314 }
315}
316
317// UseDefault returns default asset type
318func UseDefault() Item {

Callers 15

GetOrderHistoryMethod · 0.92
processSpotOrdersMethod · 0.92
SQLDataToTradeFunction · 0.92
dataHistoryTraderLoaderFunction · 0.92
GetTickerMethod · 0.92
GetOrderbookMethod · 0.92
GetAccountBalancesMethod · 0.92
UpdateAccountBalancesMethod · 0.92
GetOrdersMethod · 0.92
GetManagedOrdersMethod · 0.92
GetOrderMethod · 0.92

Calls

no outgoing calls

Tested by 2

dataHistoryTraderLoaderFunction · 0.74
TestNewFunction · 0.56