Constructor
new Trader(optionsopt)
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
passed to Agent constructor(); Trader specific properties detailed below
Properties
|
Listens to Events:
- event:{wake} to trigger sendBidsAndAsks()
Classes
Methods
(abstract) ask(market, myPrice)
send a limit order to sell one unit to the indicated market at myPrice. Placeholder throws error. Must be overridden and implemented in other code.
Parameters:
Name | Type | Description |
---|---|---|
market |
Object | |
myPrice |
number |
Throws:
-
when calling placeholder
- Type
- Error
(abstract) askPrice(marginalCost, market) → {number|undefined}
calculate price this agent is willing to accept. Placeholder throws error. Must be overridden and implemented in other code.
Parameters:
Name | Type | Description |
---|---|---|
marginalCost |
number | The marginal cost of producing the next unit. |
market |
Object | For requesting current market conditions, previous trade price, etc. |
Throws:
-
when calling placeholder
- Type
- Error
Returns:
agent's sell price or undefined if not willing to sell
- Type
- number | undefined
(abstract) bid(market, myPrice)
send a limit order to buy one unit to the indicated market at myPrice. Placeholder throws error. Must be overridden and implemented in other code.
Parameters:
Name | Type | Description |
---|---|---|
market |
Object | |
myPrice |
number |
Throws:
-
when calling placeholder
- Type
- Error
(abstract) bidPrice(marginalValue, market) → {number|undefined}
calculate price this agent is willing to pay. Placeholder throws error. Must be overridden and implemented in other code.
Parameters:
Name | Type | Description |
---|---|---|
marginalValue |
number | The marginal value of redeeming the next unit. |
market |
Object | For requesting current market conditions, previous trade price, etc. |
Throws:
-
when calling placeholder
- Type
- Error
Returns:
agent's buy price or undefined if not willing to buy
- Type
- number | undefined
sendBidsAndAsks()
For each market in agent's configured markets, calculates agent's price strategy for buy or sell prices and then sends limit orders for 1 unit at those prices.
Normally you do not need to explicltly call this function: the wake listener set in the constructor of Trader and subclasses calls sendBidsAndAsks() automatcally on each wake event.