Add doc strings to model

This commit is contained in:
Jacob Plaster
2018-12-05 14:55:20 +00:00
parent 3760efcc16
commit 9309692344
3 changed files with 66 additions and 1 deletions

View File

@@ -1,6 +1,22 @@
import time
import datetime
class OrderType:
MARKET = 'market'
LIMIT = 'limit'
STOP = 'stop'
TRAILING_STOP = 'trailing-stop'
FILL_OR_KILL = 'fill-or-kill'
EXCHANGE_MARKET = 'exchange market'
EXCHANGE_LIMIT = 'exchange limit'
EXCHANGE_STOP = 'exchange stop'
EXCHANGE_TRAILING_STOP = 'exchange trailing-stop'
EXCHANGE_FILL_OR_KILL = 'exchange fill-or-kill'
class OrderSide:
BUY = 'buy'
SELL = 'sell'
class OrderClosedModel:
ID = 0
GID = 1
@@ -25,6 +41,30 @@ def now_in_mills():
return int(round(time.time() * 1000))
class Order:
"""
ID int64 Order ID
GID int Group ID
CID int Client Order ID
SYMBOL string Pair (tBTCUSD, …)
MTS_CREATE int Millisecond timestamp of creation
MTS_UPDATE int Millisecond timestamp of update
AMOUNT float Positive means buy, negative means sell.
AMOUNT_ORIG float Original amount
TYPE string The type of the order: LIMIT, MARKET, STOP, TRAILING STOP, EXCHANGE MARKET, EXCHANGE LIMIT, EXCHANGE STOP, EXCHANGE TRAILING STOP, FOK, EXCHANGE FOK.
TYPE_PREV string Previous order type
FLAGS int Upcoming Params Object (stay tuned)
ORDER_STATUS string Order Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
PRICE float Price
PRICE_AVG float Average price
PRICE_TRAILING float The trailing price
PRICE_AUX_LIMIT float Auxiliary Limit price (for STOP LIMIT)
HIDDEN int 1 if Hidden, 0 if not hidden
PLACED_ID int If another order caused this order to be placed (OCO) this will be that other order's ID
"""
Type = OrderType()
Side = OrderSide()
def __init__(self, id, gId, cId, symbol, mtsCreate, mtsUpdate, amount, amountOrig, oType,
typePrev, flags, status, price, priceAvg, priceTrailing, priceAuxLimit, notfiy, placeId):
self.id = id

View File

@@ -1,9 +1,20 @@
class Position:
"""
SYMBOL string Pair (tBTCUSD, …).
STATUS string Status (ACTIVE, CLOSED).
±AMOUNT float Size of the position. Positive values means a long position, negative values means a short position.
BASE_PRICE float The price at which you entered your position.
MARGIN_FUNDING float The amount of funding being used for this position.
MARGIN_FUNDING_TYPE int 0 for daily, 1 for term.
PL float Profit & Loss
PL_PERC float Profit & Loss Percentage
PRICE_LIQ float Liquidation price
LEVERAGE float Beta value
"""
def __init__(self, symbol, status, amount, bPrice, mFunding, mFundingType,
profit_loss, profit_loss_perc, lPrice, lev):
# [['tBTCUSD', 'ACTIVE', -2.37709587, 20720, -0.00066105, 0, 13115.99728968, 26.6296139, 104156.986252, -1.2332]]
self.symbol = symbol
self.status = status
self.amount = amount

View File

@@ -1,6 +1,20 @@
import datetime
class Trade:
"""
ID integer Trade database id
PAIR string Pair (BTCUSD, …)
MTS_CREATE integer Execution timestamp
ORDER_ID integer Order id
EXEC_AMOUNT float Positive means buy, negative means sell
EXEC_PRICE float Execution price
ORDER_TYPE string Order type
ORDER_PRICE float Order price
MAKER int 1 if true, 0 if false
FEE float Fee
FEE_CURRENCY string Fee currency
"""
SHORT = 'SHORT'
LONG = 'LONG'