ronaldlam / Autotrageur

Automated arbitrageur
2 stars 1 forks source link

Arbitrage: Store forex rates in database #139

Closed ronaldlam closed 6 years ago

ronaldlam commented 6 years ago

After some thinking, it may not be best to have the forex rate stored in the trade_opportunity table. The trade_opportunity currently has quote prices, and there are two rates that can possibly for any given bot. We can associate each trade_opportunity record with either one or two forex_rate records, which will give the quote per USD rates.

We can then update the forex_rate table on every poll. If at some point the forex turns into a separate service of some sort, the db structure to support that will be readily available.

Proposal 1

trade_opportunity

type name nullable fk
VARCHAR(36) id false
DECIMAL(18,8) e1_spread false
DECIMAL(18,8) e2_spread false
DECIMAL(27,8) e1_buy false
DECIMAL(27,8) e1_sell false
DECIMAL(27,8) e2_buy false
DECIMAL(27,8) e2_sell false
VARCHAR(36) forex_rate_id true forex_rate.id

forex_rate

type name nullable
VARCHAR(36) id false
VARCHAR(10) e1_quote false
VARCHAR(10) e2_quote false
DECIMAL(27,8) e1_rate false
DECIMAL(27,8) e2_rate false
INT(11) UNSIGNED timestamp false

Proposal 2

trade_opportunity

type name nullable fk
VARCHAR(36) id false
DECIMAL(18,8) e1_spread false
DECIMAL(18,8) e2_spread false
DECIMAL(27,8) e1_buy false
DECIMAL(27,8) e1_sell false
DECIMAL(27,8) e2_buy false
DECIMAL(27,8) e2_sell false
VARCHAR(36) e1_forex_rate_id true forex_rate.id
VARCHAR(36) e2_forex_rate_id true forex_rate.id

forex_rate

type name nullable
VARCHAR(36) id false
VARCHAR(10) quote false
DECIMAL(27,8) rate false
INT(11) UNSIGNED timestamp false