mango

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2023 License: MIT Imports: 17 Imported by: 0

README

Mango 🥭

Mango is a Go library for interacting with Manifold Markets. It provides wrapper functions for every documented API call that Manifold offers. It also offers data types representing each data structure that can be returned by the API.

See the Manifold API docs for more details.

Installation

go get github.com/jonnyspicer/mango

Usage

Mango offers custom structs representing different data structures used by Manifold, as well as methods to call the Manifold API and retrieve those objects.

In order for some functions to work correctly, you will need to have a MANIFOLD_API_KEY set in the .env file in the root of your project. Your key can be found on the edit profile screen in the Manifold UI.

Basics

Full documentation, including all available functions and types, is available on pkg.go.dev.

Get information about the currently authenticated user:

package main

import (
	"github.com/jonnyspicer/mango"
	"fmt"
)

// Initialize the default mango client
// This will try to read the value of `MANIFOLD_API_KEY` from your .env file
// and will use the base URL `https://manifold.markets` for all requests.
mc := mango.DefaultClientInstance()

user, err := mc.GetAuthenticatedUser()
if err != nil {
  log.Errorf("error getting authenticated user: %v", err)
}

fmt.Printf("authenticated user: %+v", *user)
$ authenticated user: {Id:xN67Q0mAhddL0X9wVYP2YfOrYH42 CreatedTime:1653515196337 Name:Jonny Spicer Username:jonny Url: AvatarUrl:https://lh3.googleuser
content.com/a-/AOh14GikSB2nbgbE_S2n-QUj9ydaNOX1w3QHIQrkvSsQHA=s96-c BannerUrl: Balance:10701.116370604414 TotalDeposits:12267.829283182942 ProfitCach
ed:{Weekly:107.5333580138431 Daily:19.18702587612779 AllTime:3409.646711972091 Monthly:307.27444250182816} Bio: Website:https://jonnyspicer.com Twitt
erHandle:https://twitter.com/jjspicer DiscordHandle:}

Create a new market:

mc := mango.DefaultClientInstance()

pmr := mango.PostMarketRequest{
    OutcomeType: mango.Binary,
    Question:    "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
    Description: "Will resolve based on some completely arbitrary criteria",
    InitialProb: 50,
    CloseTime:   1704067199000, // Sunday, December 31, 2023 11:59:59 PM
}

marketId, err := mc.CreateMarket(pmr)
if err != nil {
    fmt.Printf("error creating market: %v", err)
}

fmt.Printf("created market id: %v", *marketId)
$ created market id: 1LZpVeeTGAjkF4IgPAMk

Bet on a market:

mc := mango.DefaultClientInstance()

pbr := mango.PostBetRequest{
    Amount:     10,
    ContractId: "1LZpVeeTGAjkF4IgPAMk",
    Outcome:    "YES",
}

err := mc.PostBet(pbr)
if err != nil {
    fmt.Printf("error posting bet: %v", err)
}

Documentation

Overview

Package mango provides a client that can be used to make calls to the Manifold Markets API.

Currently, it provides wrapper functions for every documented API call that Manifold offers. It also offers data types representing each data structure that can be returned by the API.

See the Manifold API docs for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KellyBet added in v0.2.0

func KellyBet(prob, payout float64) float64

KellyBet returns the percentage of your bankroll that you ought to bet, for a given computed probability and payout.

Payout is in decimal odds.

See the Kelly Criterion Wikipedia page for more details.

Types

type Answer

type Answer struct {
	Id          string  `json:"id"`
	Username    string  `json:"username"`
	Name        string  `json:"name"`
	UserId      string  `json:"userId"`
	CreatedTime int64   `json:"createdTime"`
	AvatarUrl   string  `json:"avatarUrl"`
	Number      int64   `json:"number"`
	ContractId  string  `json:"contractId"`
	Text        string  `json:"text"`
	Probability float64 `json:"probability"`
}

Answer represents a potential answer on a free response market

type Bet

type Bet struct {
	Outcome       string  `json:"outcome"`
	Fees          Fees    `json:"fees"`
	IsAnte        bool    `json:"isAnte"`
	IsCancelled   bool    `json:"isCancelled,omitempty"`
	UserId        string  `json:"userId"`
	ProbBefore    float64 `json:"probBefore"`
	LoanAmount    float64 `json:"loanAmount"`
	ContractId    string  `json:"contractId"`
	UserUsername  string  `json:"userUsername"`
	CreatedTime   int64   `json:"createdTime"`
	UserAvatarUrl string  `json:"userAvatarUrl"`
	Id            string  `json:"id"`
	Amount        float64 `json:"amount"`
	Fills         []Fill  `json:"fills,omitempty"`
	Shares        float64 `json:"shares"`
	IsRedemption  bool    `json:"isRedemption"`
	IsFilled      bool    `json:"isFilled,omitempty"`
	UserName      string  `json:"userName"`
	OrderAmount   float64 `json:"orderAmount,omitempty"`
	IsChallenge   bool    `json:"isChallenge"`
	ProbAfter     float64 `json:"probAfter"`
}

Bet represents a Bet object in the Manifold backend.

See the Manifold API docs for GET /v0/bets for more details

type CachedLeaderboard

type CachedLeaderboard struct {
	TopTraders  []GroupLeader `json:"topTraders"`
	TopCreators []GroupLeader `json:"topCreators"`
}

CachedLeaderboard represents the leaderboard os a Group

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents the main Mango client, used to make requests to the Manifold API

func ClientInstance

func ClientInstance(client *http.Client, url, ak *string) *Client

ClientInstance creates a singleton of the Mango Client. It optionally takes a http.Client, base URL, and API key.

If you don't specify a base URL, the default Manifold Markets domain will be used.

If no API key is provided then you will need to specify a `MANIFOLD_API_KEY` in your .env file

Just because you *can* specify an API key here doesn't mean that you *should*! Please don't put your API key in code.

func DefaultClientInstance

func DefaultClientInstance() *Client

DefaultClientInstance returns a singleton of the Mango Client using all default values.

It will use a default http.Client, the primary Manifold domain as the base URL, and the value of `MANIFOLD_API_KEY` in your .env file as the API key.

func (*Client) AddLiquidity

func (mc *Client) AddLiquidity(marketId string, amount int64) error

AddLiquidity adds a given amount of liquidity to a given market.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/market/marketId/add-liquidity for more details.

func (*Client) AddMarketToGroup

func (mc *Client) AddMarketToGroup(marketId, gi string) error

AddMarketToGroup adds a given market to a given group.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/market/marketId/group for more details.

func (*Client) CancelBet

func (mc *Client) CancelBet(betId string) error

CancelBet cancels an existing limit order for the given betId.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/bet/cancel/id for more details.

func (*Client) CloseMarket

func (mc *Client) CloseMarket(marketId string, ct *int64) error

CloseMarket updates the closing time of a given market to be the given epoch timestamp, or closes it immediately if no new time is provided.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/market/marketId/close for more details.

func (*Client) CreateMarket

func (mc *Client) CreateMarket(pmr PostMarketRequest) (*string, error)

CreateMarket creates a new market. It takes a PostMarketRequest which has the following parameters:

  • [PostMarketRequest.OutcomeType] - Required. One of OutcomeType
  • [PostMarketRequest.Question] - Required.
  • [PostMarketRequest.Description] - Optional. Non-rich text description.
  • [PostMarketRequest.DescriptionHtml] - Optional.
  • [PostMarketRequest.DescriptionMarkdown] - Optional.
  • [PostMarketRequest.CloseTime] - Optional. In epoch time. Default 7 days from time of creation.
  • [PostMarketRequest.Visibility] - Optional. One of "public" or "unlisted" TODO: make this an enum
  • [PostMarketRequest.GroupId] - Optional. A group to show the market under.
  • [PostMarketRequest.InitialProb] - Required for binary markets. Must be between 1 and 99.
  • [PostMarketRequest.Min] - Required for numeric markets. The minimum value that the market may resolve to.
  • [PostMarketRequest.Max] - Required for numeric markets. The maximum value that the market may resolve to.
  • [PostMarketRequest.IsLogScale] - Required for numeric markets. If true, your numeric market will increase exponentially from min to max.
  • [PostMarketRequest.InitialVal] - Required for numeric markets. An initial value for the market, between min and max, exclusive.
  • [PostMarketRequest.Answers] - Required for multiple choice markets. An array of strings, each of which will be a valid answer for the market.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/market for more details.

func (*Client) Destroy

func (mc *Client) Destroy()

Destroy destroys the current singleton of the Mango client.

Useful for testing.

func (*Client) GetAuthenticatedUser

func (mc *Client) GetAuthenticatedUser() (*User, error)

GetAuthenticatedUser returns the User associated with the current API key. If the key is invalid or not present, returns nil and an error.

See the Manifold API docs for GET /v0/me for more details.

func (*Client) GetBets

func (mc *Client) GetBets(gbr GetBetsRequest) (*[]Bet, error)

GetBets returns a slice of Bet and an error. It takes a GetBetsRequest which has the following optional parameters:

  • [GetBetsRequest.UserId]
  • [GetBetsRequest.Username]
  • [GetBetsRequest.ContractId]
  • [GetBetsRequest.ContractSlug]
  • [GetBetsRequest.Before] - the ID of the bet before which the list will start.
  • [GetBetsRequest.Limit] - the maximum and default limit is 1000.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/bets for more details.

func (*Client) GetComments

func (mc *Client) GetComments(gcr GetCommentsRequest) (*[]Comment, error)

GetComments returns a slice of Comment and an error. It takes a GetCommentsRequest which has the following optional parameters:

  • [GetCommentsRequest.ContractId]
  • [GetCommentsRequest.ContractSlug]

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/comments for more details.

func (*Client) GetGroupById

func (mc *Client) GetGroupById(id string) (*Group, error)

GetGroupById returns a Group by its unique id.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/group/by-id/id for more details.

func (*Client) GetGroupBySlug

func (mc *Client) GetGroupBySlug(slug string) (*Group, error)

GetGroupBySlug returns a Group by its slug.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/group/slug for more details.

func (*Client) GetGroups

func (mc *Client) GetGroups(userId *string) (*[]Group, error)

GetGroups returns a slice of Group. Optionally a userId can be passed: in this case, only groups available to the given user will be returned. Results are unordered.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/groups for more details.

func (*Client) GetLeaders added in v0.2.0

func (mc *Client) GetLeaders(t LeaderType, p LeaderPeriod) *[]LeadUser

GetLeaders returns a slice of LeadUser. It takes a LeaderType, which can have one of the following values:

  • Trader - an item on the top traders leaderboard
  • Creator - an item on the top creators leaderboard

And a LeaderPeriod, which can have one of the following values:

  • Daily
  • Weekly
  • Monthly
  • All

func (*Client) GetMarketByID

func (mc *Client) GetMarketByID(id string) (*FullMarket, error)

GetMarketByID returns a FullMarket by its unique id.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/market/marketId for more details.

func (*Client) GetMarketBySlug

func (mc *Client) GetMarketBySlug(slug string) (*FullMarket, error)

GetMarketBySlug returns a FullMarket by its unique slug.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/slug/marketSlug for more details.

func (*Client) GetMarketPositions

func (mc *Client) GetMarketPositions(gmpr GetMarketPositionsRequest) (*[]ContractMetric, error)

GetMarketPositions returns positions for a given Market ID. It takes a GetMarketPositionsRequest which has the following parameters:

  • [GetMarketPositionsRequest.MarketId] - Required.
  • [GetMarketPositionsRequest.Order] - Optional. The field to order results by. Default: "profit". Options: "shares" or "profit". // TODO: make this an enum
  • [GetMarketPositionsRequest.Top] - Optional. The number of top positions (ordered by order) to return. Default: null.
  • [GetMarketPositionsRequest.Bottom] - Optional. The number of bottom positions (ordered by order) to return. Default: null.
  • [GetMarketPositionsRequest.UserId] - Optional. The user ID to query by. Default: null. If provided, only the position for this user will be returned.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/market/marketId/positions for more details.

func (*Client) GetMarkets

func (mc *Client) GetMarkets(gmr GetMarketsRequest) (*[]LiteMarket, error)

GetMarkets returns a slice of LiteMarket and an error. It takes a GetMarketsRequest which has the following optional parameters:

  • [GetMarketsRequest.Before] - the ID of the market before which the list will start.
  • [GetMarketsRequest.Limit] - the maximum and default limit is 1000.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/markets for more details.

func (*Client) GetMarketsForGroup

func (mc *Client) GetMarketsForGroup(id string) (*[]LiteMarket, error)

GetMarketsForGroup returns a slice of LiteMarket and an error. It takes a group ID to retrieve the markets for.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/group/by-id/id/markets for more details

func (*Client) GetUserByID

func (mc *Client) GetUserByID(id string) (*User, error)

GetUserByID returns a User by user id.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/user/by-id/id for more details.

func (*Client) GetUserByUsername

func (mc *Client) GetUserByUsername(un string) (*User, error)

GetUserByUsername returns a User by username

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/user/username for more details.

func (*Client) GetUsers

func (mc *Client) GetUsers(gur GetUsersRequest) (*[]User, error)

GetUsers returns a slice of User and an error. It takes a GetUsersRequest which has the following parameters:

  • [GetUsersRequest.Before] - Optional. The ID of the user before which the list will start.
  • [GetUsersRequest.Limit] - Optional. The default and maximum limit is 1000.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/markets for more details.

func (*Client) GetUsersOfType added in v0.2.0

func (mc *Client) GetUsersOfType(t UsernameType) (*[]User, error)

GetUsersOfType returns a slice of User and an error. It takes a UsernameType, which can be one of the following values:

  • Bot - representing users with the `Bot` tag
  • Core - representing Manifold employees
  • Check - representing Manifold users with the `Trustworthy. ish.` label.

func (*Client) PostBet

func (mc *Client) PostBet(pbr PostBetRequest) error

PostBet makes a new bet on a market. It takes a PostBetRequest which has the following parameters:

  • [PostBetRequest.Amount] - Required.
  • [PostBetRequest.ContractId] - Required.
  • [PostBetRequest.Outcome] - Required.
  • [PostBetRequest.LimitProb] - Optional. A number between 0.001 and 0.999 inclusive representing the limit probability for your bet

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/bet for more details.

func (*Client) PostComment

func (mc *Client) PostComment(marketId string, pcr PostCommentRequest) error

PostComment makes a new bet on a market. It takes a PostCommentRequest which has the following parameters:

  • [PostCommentRequest.ContractId] - Required.
  • [PostCommentRequest.Content] - Optional. A plaintext string.
  • [PostCommentRequest.Html] - Optional.
  • [PostCommentRequest.Markdown] - Optional.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/comment for more details.

func (*Client) ResolveMarket

func (mc *Client) ResolveMarket(marketId string, rmr ResolveMarketRequest) error

ResolveMarket creates a new market. It takes a ResolveMarketRequest which has the following parameters:

  • [ResolveMarketRequest.Outcome] - Required. One of "YES", "NO", "MKT", "CANCEL" or a number depending on market type. TODO: make this an enum
  • [ResolveMarketRequest.Resolutions] - Required for free response or multiple choice markets.
  • [ResolveMarketRequest.ProbabilityInt] - Required if value is present.
  • [ResolveMarketRequest.Value] - Optional, only relevant to numeric markets.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/market/marketId/resolve for more details.

func (*Client) SearchMarkets

func (mc *Client) SearchMarkets(terms ...string) (*[]FullMarket, error)

SearchMarkets returns a slice of FullMarket that are the results of searching for provided terms. It can take any number of strings. Each string should be an individual search term.

If there is an error making the request, then nil and an error will be returned.

See the Manifold API docs for GET /v0/search-markets for more details.

func (*Client) SellShares

func (mc *Client) SellShares(marketId string, ssr SellSharesRequest) error

SellShares creates a new market. It takes a SellSharesRequest which has the following parameters:

  • [SellSharesRequest.Outcome] - Optional. One of "YES" or "NO". If omitted and only one kind of shares are held, sells those. TODO: make this an enum
  • [SellSharesRequest.Shares] - Optional. If omitted, all shares held will be sold.

If there is an error making the request, then an error will be returned.

See the Manifold API docs for POST /v0/market/marketId/sell for more details.

type Comment

type Comment struct {
	UserUsername             string  `json:"userUsername"`
	ContractSlug             string  `json:"contractSlug"`
	UserName                 string  `json:"userName"`
	CommentType              string  `json:"commentType"`
	Id                       string  `json:"id"`
	Text                     string  `json:"text"`
	CommenterPositionProb    float64 `json:"commenterPositionProb,omitempty"`
	ReplyToCommentId         string  `json:"replyToCommentId,omitempty"`
	ContractQuestion         string  `json:"contractQuestion"`
	CreatedTime              int64   `json:"createdTime"`
	UserAvatarUrl            string  `json:"userAvatarUrl"`
	ContractId               string  `json:"contractId"`
	UserId                   string  `json:"userId"`
	CommenterPositionShares  float64 `json:"commenterPositionShares,omitempty"`
	CommenterPositionOutcome string  `json:"commenterPositionOutcome,omitempty"`
	BetAmount                float64 `json:"betAmount,omitempty"`
	BetId                    string  `json:"betId,omitempty"`
	BetOutcome               string  `json:"betOutcome,omitempty"`
}

Comment represents a Comment object in the Manifold backend.

This type isn't documented by Manifold and its structure was inferred from API calls.

type ContractMetric

type ContractMetric struct {
	ContractId    string             `json:"contractId"`
	From          map[string]Period  `json:"from,omitempty"`
	HasNoShares   bool               `json:"hasNoShares"`
	HasShares     bool               `json:"hasShares"`
	HasYesShares  bool               `json:"hasYesShares"`
	Invested      float64            `json:"invested"`
	Loan          float64            `json:"loan"`
	MaxShares     string             `json:"maxSharesOutcome,omitempty"`
	Payout        float64            `json:"payout"`
	Profit        float64            `json:"profit"`
	ProfitPercent float64            `json:"profitPercent"`
	TotalShares   map[string]float64 `json:"totalShares"`
	UserId        string             `json:"userId,omitempty"`
	UserName      string             `json:"userName,omitempty"`
	UserUsername  string             `json:"userUsername,omitempty"`
	UserAvatarUrl string             `json:"userAvatarUrl,omitempty"`
	LastBetTime   int64              `json:"lastBetTime,omitempty"`
}

ContractMetric represents a single position in a market.

See the Manifold API docs for GET /v0/market/marketId/positions for more details

type Fees

type Fees struct {
	LiquidityFee int64 `json:"liquidityFee"`
	PlatformFee  int64 `json:"platformFee"`
	CreatorFee   int64 `json:"creatorFee"`
}

Fees represents the fees paid on a Bet.

type Fill

type Fill struct {
	MatchedBetId *string `json:"matchedBetId"`
	Amount       float64 `json:"amount"`
	Shares       float64 `json:"shares"`
	Timestamp    int64   `json:"timestamp"`
	IsSale       bool    `json:"isSale,omitempty"`
}

Fill represents the portion of a limit order that has been filled

type FullMarket

type FullMarket struct {
	Id                    string      `json:"id"`
	CreatorId             string      `json:"creatorId"`
	CreatorUsername       string      `json:"creatorUsername"`
	CreatorName           string      `json:"creatorName"`
	CreatedTime           int64       `json:"createdTime"`
	CreatorAvatarUrl      string      `json:"creatorAvatarUrl"`
	CloseTime             int64       `json:"closeTime"`
	Question              string      `json:"question"`
	Answers               []Answer    `json:"answers,omitempty"`
	Tags                  []string    `json:"tags"`
	Url                   string      `json:"url"`
	Pool                  Pool        `json:"pool"`
	Probability           float64     `json:"probability"`
	P                     float64     `json:"p"`
	TotalLiquidity        float64     `json:"totalLiquidity"`
	OutcomeType           OutcomeType `json:"OutcomeType"`
	Mechanism             string      `json:"mechanism"`
	Volume                float64     `json:"volume"`
	Volume24Hours         float64     `json:"volume24Hours"`
	IsResolved            bool        `json:"isResolved"`
	Resolution            string      `json:"resolution"`
	ResolutionTime        int64       `json:"resolutionTime"`
	ResolutionProbability float64     `json:"resolutionProbability"`
	LastUpdatedTime       int64       `json:"lastUpdatedTime"`
	// Description field returns HTML marshalled to JSON, see https://tiptap.dev/guide/output#option-1-json
	// Description     string `json:"description"` TODO: work out how to parse this field
	TextDescription string `json:"textDescription"`
}

FullMarket represents a FullMarket object in the Manifold backend. A FullMarket is similar to a LiteMarket, except it has more fields.

See [the Manifold API docs for GET /v0/market/[marketId]] for more details

type GetBetsRequest

type GetBetsRequest struct {
	UserId       string `json:"userId,omitempty"`
	Username     string `json:"username,omitempty"`
	ContractId   string `json:"contractID,omitempty"`
	ContractSlug string `json:"contractSlug,omitempty"`
	Before       string `json:"before,omitempty"`
	Limit        int64  `json:"limit,omitempty"`
}

GetBetsRequest represents the optional parameters that can be supplied to get bets via the API

type GetCommentsRequest

type GetCommentsRequest struct {
	ContractId   string `json:"contractId,omitempty"`
	ContractSlug string `json:"contractSlug,omitempty"`
}

GetCommentsRequest represents the optional parameters that can be supplied to get comments via the API

type GetMarketPositionsRequest

type GetMarketPositionsRequest struct {
	MarketId string `json:"marketId"`
	Order    string `json:"order,omitempty"`
	Top      int    `json:"top,omitempty"`
	Bottom   int    `json:"bottom,omitempty"`
	UserId   string `json:"userId,omitempty"`
}

GetMarketPositionsRequest represents the optional parameters that can be supplied to get market positions via the API

MarketId is required, all other fields are optional.

type GetMarketsRequest

type GetMarketsRequest struct {
	Before string `json:"before,omitempty"`
	Limit  int64  `json:"limit,omitempty"`
}

GetMarketsRequest represents the optional parameters that can be supplied to get markets via the API

type GetUsersRequest

type GetUsersRequest struct {
	Before string `json:"before,omitempty"`
	Limit  int64  `json:"limit,omitempty"`
}

GetUsersRequest represents the optional parameters that can be supplied to get users via the API

type Group

type Group struct {
	AboutPostId                 string            `json:"aboutPostId,omitempty"`
	MostRecentActivityTime      int64             `json:"mostRecentActivityTime"`
	AnyoneCanJoin               bool              `json:"anyoneCanJoin"`
	TotalContracts              int64             `json:"totalContracts"`
	Name                        string            `json:"name"`
	PinnedItems                 []PinnedItem      `json:"pinnedItems,omitempty"`
	TotalMembers                int64             `json:"totalMembers"`
	CreatedTime                 int64             `json:"createdTime"`
	Slug                        string            `json:"slug"`
	CachedLeaderboard           CachedLeaderboard `json:"cachedLeaderboard"`
	About                       string            `json:"about"`
	MostRecentContractAddedTime int64             `json:"mostRecentContractAddedTime,omitempty"`
	CreatorId                   string            `json:"creatorId"`
	Id                          string            `json:"id"`
	PostIds                     []string          `json:"postIds,omitempty"`
	BannerUrl                   string            `json:"bannerUrl,omitempty"`
	MostRecentChatActivityTime  int64             `json:"mostRecentChatActivityTime,omitempty"`
	ChatDisabled                bool              `json:"chatDisabled,omitempty"`
}

Group represents a Group object in the Manifold backend.

This type isn't documented by Manifold and its structure was inferred from API calls.

type GroupLeader added in v0.3.0

type GroupLeader struct {
	UserId string  `json:"userId"`
	Score  float64 `json:"score"`
}

GroupLeader represents the leader of a Group.

type LeadUser added in v0.2.0

type LeadUser struct {
	Rank     int
	Username string
	Mana     int
	Traders  int
	User     User
}

LeadUser represents a member of one of the Manifold leaderboards, and their associated user information

type LeaderPeriod added in v0.2.0

type LeaderPeriod int

LeaderPeriod represents a time period that a Manifold leaderboard can represent

const (
	Daily LeaderPeriod = iota
	Weekly
	Monthly
	All
)

type LeaderType added in v0.2.0

type LeaderType int

LeaderType represents a Manifold leaderboard which an item can be part of

const (
	Trader LeaderType = iota
	Creator
)

type LiteMarket

type LiteMarket struct {
	Id                    string        `json:"id"`
	CreatorId             string        `json:"creatorId"`
	CreatorUsername       string        `json:"creatorUsername"`
	CreatorName           string        `json:"creatorName"`
	CreatedTime           int64         `json:"createdTime"`
	CreatorAvatarUrl      string        `json:"creatorAvatarUrl"`
	CloseTime             int64         `json:"closeTime"`
	Question              string        `json:"question"`
	Tags                  []interface{} `json:"tags"`
	Url                   string        `json:"url"`
	Pool                  Pool          `json:"pool,omitempty"`
	Probability           float64       `json:"probability,omitempty"`
	P                     float64       `json:"p,omitempty"`
	TotalLiquidity        float64       `json:"totalLiquidity,omitempty"`
	OutcomeType           OutcomeType   `json:"OutcomeType"`
	Mechanism             string        `json:"mechanism"`
	Volume                float64       `json:"volume"`
	Volume24Hours         float64       `json:"volume24Hours"`
	IsResolved            bool          `json:"isResolved"`
	LastUpdatedTime       int64         `json:"lastUpdatedTime,omitempty"`
	Min                   float64       `json:"min,omitempty"`
	Max                   float64       `json:"max,omitempty"`
	IsLogScale            bool          `json:"isLogScale,omitempty"`
	Resolution            string        `json:"resolution,omitempty"`
	ResolutionTime        int64         `json:"resolutionTime,omitempty"`
	ResolutionProbability float64       `json:"resolutionProbability,omitempty"`
}

LiteMarket represents a LiteMarket object in the Manifold backend. A LiteMarket is similar to a FullMarket, except it has fewer fields.

See the Manifold API docs for GET /v0/markets for more details

type Market

type Market interface {
	LiteMarket | FullMarket
}

type OutcomeType

type OutcomeType string

OutcomeType represents the different types of markets available on Manifold.

const (
	Binary         OutcomeType = "BINARY"
	FreeResponse   OutcomeType = "FREE_RESPONSE"
	MultipleChoice OutcomeType = "MULTIPLE_CHOICE"
	Numeric        OutcomeType = "NUMERIC"
	PseudoNumeric  OutcomeType = "PSEUDO-NUMERIC"
)

type Period

type Period struct {
	Profit        float64 `json:"profit"`
	ProfitPercent float64 `json:"profitPercent"`
	Invested      float64 `json:"invested"`
	PrevValue     float64 `json:"prevValue"`
	Value         float64 `json:"value"`
}

Period represents activity on a contract during a given day, week or month

type PinnedItem

type PinnedItem struct {
	ItemId string `json:"itemId"`
	Type   string `json:"type"`
}

PinnedItem represents the pinned item of a Group.

type Pool

type Pool struct {
	No       float64 `json:"NO,omitempty"`
	Yes      float64 `json:"YES,omitempty"`
	Option0  float64 `json:"0,omitempty"`
	Option1  float64 `json:"1,omitempty"`
	Option2  float64 `json:"2,omitempty"`
	Option3  float64 `json:"3,omitempty"`
	Option4  float64 `json:"4,omitempty"`
	Option5  float64 `json:"5,omitempty"`
	Option6  float64 `json:"6,omitempty"`
	Option7  float64 `json:"7,omitempty"`
	Option8  float64 `json:"8,omitempty"`
	Option9  float64 `json:"9,omitempty"`
	Option10 float64 `json:"10,omitempty"`
	Option11 float64 `json:"11,omitempty"`
	Option12 float64 `json:"12,omitempty"`
	Option13 float64 `json:"13,omitempty"`
	Option14 float64 `json:"14,omitempty"`
	Option15 float64 `json:"15,omitempty"`
	Option16 float64 `json:"16,omitempty"`
	Option17 float64 `json:"17,omitempty"`
	Option18 float64 `json:"18,omitempty"`
	Option19 float64 `json:"19,omitempty"`
}

Pool represents the potential outcomes for a market.

type PostBetRequest

type PostBetRequest struct {
	Amount     float64  `json:"amount"`
	ContractId string   `json:"contractId"`
	Outcome    string   `json:"outcome"`
	LimitProb  *float64 `json:"limitProb,omitempty"`
}

PostBetRequest represents the parameters required to post a new Bet via the API

type PostCommentRequest

type PostCommentRequest struct {
	ContractId string `json:"contractId"`
	Content    string `json:"content,omitempty"`
	Html       string `json:"html,omitempty"`
	Markdown   string `json:"markdown,omitempty"`
}

PostCommentRequest represents the parameters required to post a new Comment via the API

type PostMarketRequest

type PostMarketRequest struct {
	OutcomeType         OutcomeType `json:"outcomeType"`
	Question            string      `json:"question"`
	Description         string      `json:"description,omitempty"`
	DescriptionHtml     string      `json:"descriptionHtml,omitempty"`
	DescriptionMarkdown string      `json:"descriptionMarkdown,omitempty"`
	CloseTime           int64       `json:"closeTime,omitempty"`
	Visibility          string      `json:"visibility,omitempty"`
	GroupId             string      `json:"groupId,omitempty"`
	InitialProb         int64       `json:"initialProb,omitempty"`
	Min                 int64       `json:"min,omitempty"`
	Max                 int64       `json:"max,omitempty"`
	IsLogScale          bool        `json:"isLogScale,omitempty"`
	InitialVal          int64       `json:"initialValue,omitempty"`
	Answers             []string    `json:"answers,omitempty"`
}

PostMarketRequest represents the parameters required to create a new market via the API

type ProfitCached

type ProfitCached struct {
	Weekly  float64 `json:"weekly"`
	Daily   float64 `json:"daily"`
	AllTime float64 `json:"allTime"`
	Monthly float64 `json:"monthly"`
}

ProfitCached represents the profit for a given User

type Resolution

type Resolution struct {
	Answer int64 `json:"answer"`
	Pct    int64 `json:"pct"`
}

Resolution represents the percentage a given answer should resolve to on a market

type ResolveMarketRequest

type ResolveMarketRequest struct {
	Outcome        string       `json:"outcome"`
	Resolutions    []Resolution `json:"resolutions,omitempty"`
	ProbabilityInt int64        `json:"probabilityInt,omitempty"`
	Value          float64      `json:"value,omitempty"`
}

ResolveMarketRequest represents the parameters required to resolve a market via the API

type SellSharesRequest

type SellSharesRequest struct {
	Outcome string `json:"outcome,omitempty"`
	Shares  int64  `json:"shares,omitempty"`
}

SellSharesRequest represents a request to sell shares

type User

type User struct {
	Id            string       `json:"id"`
	CreatedTime   int64        `json:"createdTime"`
	Name          string       `json:"name"`
	Username      string       `json:"username"`
	Url           string       `json:"url"`
	AvatarUrl     string       `json:"avatarUrl"`
	BannerUrl     string       `json:"bannerUrl"`
	Balance       float64      `json:"balance"`
	TotalDeposits float64      `json:"totalDeposits"`
	ProfitCached  ProfitCached `json:"profitCached"`
	Bio           string       `json:"bio,omitempty"`
	Website       string       `json:"website,omitempty"`
	TwitterHandle string       `json:"twitterHandle,omitempty"`
	DiscordHandle string       `json:"discordHandle,omitempty"`
}

User represents a User object in the Manifold backend.

This type isn't documented by Manifold and its structure was inferred from API calls.

type UsernameType added in v0.2.0

type UsernameType string

UsernameType represents a special category of users on Manifold

const (
	Bot   UsernameType = "BOT"
	Check UsernameType = "CHECK"
	Core  UsernameType = "CORE"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL