/// <summary> Executes the produce report action. </summary> /// /// <remarks> Paul, 14/03/2015. </remarks> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> public Task OnProduceReport(RequestContext ctx, T dummy) { uint sinceTid = RestHelpers.GetQueryArg <uint, ApiExceptionMissingParameter>(ctx, WebForms.kSince); string market = RestHelpers.GetQueryArg <string>(ctx, WebForms.kSymbolPair); MarketRow m = m_database.GetMarket(market); if (m == null) { throw new ApiExceptionUnknownMarket(market); } List <TransactionsRow> allTrans = m_database.GetCompletedTransactionsInMarketSince(market, sinceTid); StringWriter stream = new StringWriter(); stream.WriteLine("All completed transactions in market " + market + " since tid " + sinceTid + "<br/>"); stream.WriteLine("<br/>"); stream.WriteLine("Tid, Type, Price, Amount, Fee, Date<br/>"); foreach (TransactionsRow t in allTrans) { stream.WriteLine(t.uid + "," + t.order_type + "," + t.price + "," + t.amount + "," + t.fee + "," + t.date + "<br/>"); } ctx.Respond(stream.ToString(), System.Net.HttpStatusCode.OK); return(null); }
public bool Release(ResourceComponent res, out MarketRow row) { ResourceRow <Market> fromParent = null; bool released = _Release(res, out fromParent); row = fromParent as MarketRow; return(released); }
public void OnChildTriggerEnter(TriggerForwarder child, Collider other, IMovableSnappable res) { MarketRow whichRow = GetRow(child.name); if (whichRow != null && res is ResourceComponent && !CrateInterferenceTimers.ContainsKey(whichRow)) { whichRow.Capture(this, res as ResourceComponent); } }
void GetMarketSuccess(string market) { string content = Post(Routes.kGetMarket, RestHelpers.BuildPostArgs(WebForms.kSymbolPair, market)); MarketRow check = GetMarket(market); string reality = JsonSerializer.SerializeToString <MarketRow>(check); content.Should().Be.EqualTo(reality); }
public MarketBase(MetaDaemonApi daemon, MarketRow market, BitsharesWallet bitshares, BitcoinWallet bitcoin, string bitsharesAccount) { m_daemon = daemon; m_market = market; m_bitshares = bitshares; m_bitcoin = bitcoin; m_bitsharesAccount = bitsharesAccount; }
/// <summary> Forward post specific. </summary> /// /// <remarks> Paul, 19/02/2015. </remarks> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> Task <string> ForwardPostSpecific(RequestContext ctx, IDummy dummy) { // pull out the daemon address from the market row string symbolPair = RestHelpers.GetPostArg <string, ApiExceptionMissingParameter>(ctx, WebForms.kSymbolPair); MarketRow m = dummy.m_database.GetMarket(symbolPair); // forward the post on return(ForwardTrackIpBans(ctx, c => Rest.ExecutePostAsync(ApiUrl(m.daemon_url, c.Request.Url.LocalPath), c.Request.PostArgString))); }
/// <summary> Handles the command. </summary> /// /// <remarks> Paul, 26/02/2015. </remarks> /// /// <param name="l"> The BitsharesLedgerEntry to process. </param> /// <param name="handler"> The handler. </param> /// <param name="market"> The market. </param> /// /// <returns> true if it succeeds, false if it fails. </returns> public bool HandleCommand(BitsharesLedgerEntry l, MarketBase handler, MarketRow market, string trxid) { if (m_adminUsernames.Contains(l.from_account)) { try { string[] parts = l.memo.Split(' '); if (l.memo.StartsWith(kSetPricesMemoStart)) { HandlePriceSetting(parts, l, handler, market); return(true); } else if (l.memo.StartsWith(kWithdrawMemo)) { // process withdrawal if (parts[0] == kWithdrawMemo) { // make sure we didn't already process this transaction! if (!m_dataAccess.IsWithdrawalProcessed(trxid)) { decimal amount = decimal.Parse(parts[1]); CurrenciesRow type = CurrencyHelpers.FromSymbol(parts[2], m_allCurrencies); string to; string txid; if (!CurrencyHelpers.IsBitsharesAsset(type)) { to = m_dataAccess.GetStats().bitcoin_withdraw_address; Debug.Assert(to != null); txid = m_bitcoin.SendToAddress(to, amount); } else { to = l.from_account; BitsharesTransactionResponse response = m_bitshares.WalletTransfer(amount, CurrencyHelpers.ToBitsharesSymbol(type), m_bitsharesAccount, to); txid = response.record_id; } // log in DB m_dataAccess.InsertWithdrawal(trxid, txid, type.ToString(), amount, to, DateTime.UtcNow); } return(true); } } } catch (Exception e) { LogGeneralException(e.ToString()); } } return(false); }
/// <summary> Check handlers. </summary> /// /// <remarks> Paul, 25/02/2015. </remarks> void CheckMarketHandlers(Dictionary <string, MarketRow> allMarkets) { // make sure we have handlers for all markets foreach (KeyValuePair <string, MarketRow> kvp in allMarkets) { MarketRow market = kvp.Value; if (!m_marketHandlers.ContainsKey(market.symbol_pair)) { m_marketHandlers[market.symbol_pair] = CreateHandlerForMarket(market); } } }
/// <summary> Constructor. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="uid"> The UID. </param> /// <param name="base"> The base. </param> /// <param name="quote"> The quote. </param> /// <param name="bitshares"> The bitshares. </param> /// <param name="bitcoin"> The bitcoin. </param> /// <param name="bitsharesAccount"> The bitshares account. </param> public InternalMarket(MetaDaemonApi daemon, MarketRow market, BitsharesWallet bitshares, BitcoinWallet bitcoin, string bitsharesAccount, CurrenciesRow bitsharesAsset) : base(daemon, market, bitshares, bitcoin, bitsharesAccount) { m_currency = bitsharesAsset; m_flipped = m_market.GetBase(daemon.m_AllCurrencies) != bitsharesAsset; m_asset = m_bitshares.BlockchainGetAsset(CurrencyHelpers.ToBitsharesSymbol(bitsharesAsset)); Dictionary <int, ulong> allBitsharesBalances = m_bitshares.WalletAccountBalance(bitsharesAccount)[bitsharesAccount]; decimal bitcoinBalance = bitcoin.GetBalance(); ComputeMarketPricesAndLimits(ref m_market, allBitsharesBalances, bitcoinBalance); }
public void DetachCrate(IMovableSnappable detaching) { MarketRow wasAttachedTo = null; //we don't know which row we are detaching from! so... //we have to search them all possibly //short circuit hack = if one of them returns true, the remaining calls will not be made if (this.left.Release(detaching as ResourceComponent, out wasAttachedTo) || //this.middle.Release(detaching as ResourceComponent, out wasAttachedTo) || this.right.Release(detaching as ResourceComponent, out wasAttachedTo)) { this.CrateInterferenceTimers.Add(wasAttachedTo, StartCoroutine(CrateInterferenceCountdown(wasAttachedTo))); } }
/// <summary> Executes the push market action. </summary> /// /// <remarks> Paul, 19/02/2015. </remarks> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> Task OnPushMarket(RequestContext ctx, IDummy dummy) { if (ConfirmDaemon(ctx, dummy)) { MarketRow market = JsonSerializer.DeserializeFromString <MarketRow>(ctx.Request.Body); dummy.m_database.UpdateMarketInDatabase(market); ctx.Respond <bool>(true); } else { ctx.Respond <bool>(false); } return(null); }
string SubmitValidBitsharesAccount(string market) { string content = SubmitAddress(kBitsharesAccount, MetaOrderType.buy, market); MarketRow m = GetMarket(market); SenderToDepositRow s2d = m_database.Query <SenderToDepositRow>("SELECT * FROM sender_to_deposit WHERE receiving_address=@r AND symbol_pair=@m;", kBitsharesAccount, m.symbol_pair).FirstOrDefault(); string reality = JsonSerializer.SerializeToString <SubmitAddressResponse>(new SubmitAddressResponse { deposit_address = s2d.deposit_address }); content.Should().Be.EqualTo(reality); return(content); }
/// <summary> Executes the submit address action. </summary> /// /// <remarks> Paul, 19/02/2015. </remarks> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> async Task OnSubmitAddress(RequestContext ctx, IDummy dummy) { // intercept the response and stick it in the site database so we can handle forwarding future queries string symbolPair = RestHelpers.GetPostArg <string, ApiExceptionMissingParameter>(ctx, WebForms.kSymbolPair); uint referralUser = RestHelpers.GetPostArg <uint>(ctx, WebForms.kReferralId); string receivingAddress = RestHelpers.GetPostArg <string, ApiExceptionMissingParameter>(ctx, WebForms.kReceivingAddress); // do this at the site level, because we need to prevent this from occuring across nodes if (dummy.m_database.IsAnyDepositAddress(receivingAddress)) { throw new ApiExceptionInvalidAddress("<internal deposit address>"); } // forward the post on string response = await ForwardPostSpecific(ctx, dummy); if (response != null) { // get the juicy data out SubmitAddressResponse data = JsonSerializer.DeserializeFromString <SubmitAddressResponse>(response); // pull the market out of the request MarketRow m = dummy.m_database.GetMarket(symbolPair); // stick it in the master database dummy.m_database.InsertSenderToDeposit(data.receiving_address, data.deposit_address, m.symbol_pair, referralUser, true); if (referralUser > 0) { // track referrals string depositAddress; if (data.memo != null) { depositAddress = data.memo; } else { depositAddress = data.deposit_address; } dummy.m_database.InsertReferralAddress(depositAddress, referralUser); } } }
/// <summary> Executes the get market action. </summary> /// /// <remarks> Paul, 28/02/2015. </remarks> /// /// <exception cref="ApiExceptionUnknownMarket"> Thrown when an API exception unknown market /// error condition occurs. </exception> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> Task OnGetMarket(RequestContext ctx, IDummy dummy) { string symbolPair = RestHelpers.GetPostArg <string, ApiExceptionMissingParameter>(ctx, WebForms.kSymbolPair); MarketRow market = m_Database.GetMarket(symbolPair); if (market == null) // || !market.visible) { throw new ApiExceptionUnknownMarket(symbolPair); } else { //ctx.Respond<MarketRow>(market); m_api.SendCorsResponse <MarketRow>(ctx, market); } return(null); }
/// <summary> Creates handler for market. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <exception cref="UnexpectedCaseException"> Thrown when an Unexpected Case error condition /// occurs. </exception> /// /// <param name="market"> The market. </param> /// /// <returns> The new handler for market. </returns> MarketBase CreateHandlerForMarket(MarketRow market) { CurrenciesRow @base, quote; CurrencyHelpers.GetBaseAndQuoteFromSymbolPair(market.symbol_pair, m_allCurrencies, out @base, out quote); if (CurrencyHelpers.IsBitsharesAsset(@base) && !CurrencyHelpers.IsBitsharesAsset(quote)) { return(new InternalMarket(this, market, m_bitshares, m_bitcoin, m_bitsharesAccount, @base)); } else if (!CurrencyHelpers.IsBitsharesAsset(@base) && CurrencyHelpers.IsBitsharesAsset(quote)) { return(new InternalMarket(this, market, m_bitshares, m_bitcoin, m_bitsharesAccount, @quote)); } else { throw new UnexpectedCaseException(); } }
/// <summary> Recompute transaction limits and prices. </summary> /// /// <remarks> Paul, 30/01/2015. </remarks> virtual protected void RecomputeTransactionLimitsAndPrices(Dictionary <string, MarketRow> allMarkets) { // get balances for both wallets Dictionary <int, ulong> bitsharesBalances = m_bitshares.WalletAccountBalance(m_bitsharesAccount)[m_bitsharesAccount]; // has to be at 1 minimum because we can't spend at 0 confirmations decimal bitcoinBalance = m_bitcoin.GetBalance("", Math.Max(kBitcoinConfirms, 1)); // update all the limits in our handlers foreach (KeyValuePair <string, MarketBase> kvp in m_marketHandlers) { MarketRow market = allMarkets[kvp.Key]; // compute new limits and prices for this market kvp.Value.ComputeMarketPricesAndLimits(ref market, bitsharesBalances, bitcoinBalance); // write them back out UpdateMarketInDatabase(market); } }
/// <summary> Updates this object. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> async public override void Update() { try { // // don't process transactions if the network is in danger // GetInfoResponse info = m_bitshares.GetInfo(); m_suspended = info.blockchain_average_delegate_participation < kMinDelegateParticipation; if (!m_suspended) { Dictionary <string, MarketRow> allMarkets = GetAllMarkets().ToDictionary(m => m.symbol_pair); m_allCurrencies = m_dataAccess.GetAllCurrencies(); // create any handlers we need for new markets CheckMarketHandlers(allMarkets); // get all markets RecomputeTransactionLimitsAndPrices(allMarkets); // // handle bitshares->bitcoin // Dictionary <string, BitsharesLedgerEntry> bitsharesDeposits = HandleBitsharesDesposits(); // // handle bitcoin->bitshares // List <TransactionSinceBlock> bitcoinDeposits = HandleBitcoinDeposits(); // // process bitshares deposits // uint siteLastTid = m_dataAccess.GetSiteLastTransactionUid(); foreach (KeyValuePair <string, BitsharesLedgerEntry> kvpDeposit in bitsharesDeposits) { // figure out which market each deposit belongs to foreach (KeyValuePair <string, MarketBase> kvpHandler in m_marketHandlers) { BitsharesLedgerEntry l = kvpDeposit.Value; MarketRow m = allMarkets[kvpHandler.Key]; BitsharesAsset depositAsset = m_allBitsharesAssets[l.amount.asset_id]; if (!HandleCommand(l, kvpHandler.Value, m, kvpDeposit.Key)) { if (IsDepositForMarket(l.memo, m.symbol_pair)) { // make sure the deposit is for this market! if (kvpHandler.Value.CanDepositAsset(CurrencyHelpers.FromBitsharesSymbol(depositAsset.symbol, m_allCurrencies, depositAsset.IsUia()))) { kvpHandler.Value.HandleBitsharesDeposit(kvpDeposit); } } } } // this needs to happen for every transaction RecomputeTransactionLimitsAndPrices(allMarkets); } // // process bitcoin deposits // List <TransactionsRow> pendingTransactions = m_dataAccess.GetAllPendingTransactions(); foreach (TransactionSinceBlock deposit in bitcoinDeposits) { // figure out which market each deposit belongs to foreach (KeyValuePair <string, MarketBase> kvpHandler in m_marketHandlers) { if (IsDepositForMarket(deposit.Address, allMarkets[kvpHandler.Key].symbol_pair)) { kvpHandler.Value.HandleBitcoinDeposit(deposit); } } // this needs to happen for every transaction RecomputeTransactionLimitsAndPrices(allMarkets); } // // handle changes in transaction status // List <TransactionsRow> updatedTrans = new List <TransactionsRow>(); foreach (TransactionsRow pending in pendingTransactions) { TransactionsRow updated = m_dataAccess.GetTransaction(pending.received_txid); if (updated.status != MetaOrderStatus.pending) { updatedTrans.Add(updated); } } // // push any new transactions, make sure site acknowledges receipt // uint latestTid = m_dataAccess.GetLastTransactionUid(); if (latestTid > siteLastTid || updatedTrans.Count > 0) { List <TransactionsRow> newTrans = m_dataAccess.GetAllTransactionsSince(siteLastTid); // lump them together newTrans.AddRange(updatedTrans); // send 'em all string result = await ApiPush <List <TransactionsRow> >(Routes.kPushTransactions, newTrans); if (bool.Parse(result)) { m_dataAccess.UpdateSiteLastTransactionUid(latestTid); } else { throw new Exception("API push response unknown! " + result); } } // // push market updates // foreach (KeyValuePair <string, MarketBase> kvpHandler in m_marketHandlers) { if (kvpHandler.Value.m_IsDirty) { m_dataAccess.UpdateMarketInDatabase(kvpHandler.Value.m_Market); #pragma warning disable 4014 ApiPush <MarketRow>(Routes.kPushMarket, kvpHandler.Value.m_Market); #pragma warning restore 4014 kvpHandler.Value.m_IsDirty = false; } } // // push fee collections // if (m_bitcoinFeeAddress != null && m_bitshaaresFeeAccount != null) { uint lastFeeId = m_dataAccess.GetSiteLastFeeUid(); // collect our fees foreach (KeyValuePair <string, MarketBase> kvpHandler in m_marketHandlers) { kvpHandler.Value.CollectFees(m_bitcoinFeeAddress, m_bitshaaresFeeAccount); } // keep the site up to date, make sure it acknowledges receipt uint latestFeeId = m_dataAccess.GetLastFeeCollectionUid(); if (latestFeeId > lastFeeId) { List <FeeCollectionRow> fees = m_dataAccess.GetFeeCollectionsSince(lastFeeId); string result = await ApiPush <List <FeeCollectionRow> >(Routes.kPushFees, fees); if (bool.Parse(result)) { m_dataAccess.UpdateSiteLastFeeUid(latestFeeId); } else { throw new Exception("API push response unknown! " + result); } } } } // // wait for a stop command to exit gracefully // if (m_lastCommand == null) { m_lastCommand = ReadConsoleAsync(); string command = await m_lastCommand; // remember we never get here unless a command was entered Console.WriteLine("got command: " + command); if (command == "stop") { m_scheduler.Dispose(); } m_lastCommand = null; } } catch (UnsupportedTransactionException ute) { // ignore so we can move on! m_dataAccess.IgnoreTransaction(ute.m_trxId); // log it LogGeneralException(ute.ToString()); } catch (Exception e) { LogGeneralException(e.ToString()); } }
/// <summary> Calculates the market prices and limits. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="market"> [in,out] The market. </param> /// <param name="bitsharesBalances"> The bitshares balances. </param> /// <param name="bitcoinBalance"> The bitcoin balance. </param> public override void ComputeMarketPricesAndLimits(ref MarketRow market, Dictionary <int, ulong> bitsharesBalances, decimal bitcoinBalance) { base.ComputeMarketPricesAndLimits(ref market, bitsharesBalances, bitcoinBalance); decimal baseBalance = 0; decimal quoteBalance = bitcoinBalance; if (bitsharesBalances.ContainsKey(m_asset.id)) { // only non zero balances return data, so this guard is necessary baseBalance = m_asset.GetAmountFromLarimers(bitsharesBalances[m_asset.id]); } decimal maxTransactionFactor; if (m_currency.uia) { // with UIA we got to handle the maximum buy size differently BitsharesAccount account = m_bitshares.WalletGetAccount(m_bitsharesAccount); if (m_asset.issuer_id == account.id) { // we are the issuer! // refresh the asset m_asset = m_bitshares.BlockchainGetAsset(m_asset.symbol); // this is how much we can issue, so lets stick that in there baseBalance = m_asset.GetAmountFromLarimers(m_asset.max_supply - m_asset.current_supply); } else { throw new UnexpectedCaseException(); } maxTransactionFactor = 1; //maxTransactionFactor = kMaxTransactionFactor; } else { maxTransactionFactor = kMaxTransactionFactor; } decimal newAskMax, newBidMax; // askMax is in BITCOINS // bidMax is in BITASSETS if (m_flipped) { // BTC_bitUSD // baseBalance = 10 bitUSD // ask = 240 // askMax = 10 / 240 = 0.04 BTC newAskMax = Numeric.TruncateDecimal((baseBalance / m_market.ask) * maxTransactionFactor, 8); newBidMax = Numeric.TruncateDecimal((quoteBalance * m_market.bid) * maxTransactionFactor, 8); } else { // BTS_BTC // // baseBalance = 1 BTS // ask = 0.00004 // askMax = 1 * 0.0004 = 0.0004 BTC newAskMax = Numeric.TruncateDecimal((baseBalance * m_market.ask) * maxTransactionFactor, 8); newBidMax = Numeric.TruncateDecimal((quoteBalance / m_market.bid) * maxTransactionFactor, 8); } m_isDirty |= newAskMax != m_market.ask_max || newBidMax != m_market.bid_max; market.ask_max = newAskMax; market.bid_max = newBidMax; if (m_market.price_discovery) { // // update price discovery engine // decimal bitsharesBalance = m_asset.GetAmountFromLarimers(bitsharesBalances[m_asset.id]); if (m_asset.symbol == CurrencyHelpers.kBtcSymbol) { m_lastFeedPrice = 1; } else { m_lastFeedPrice = RecomputeFeedPriceInBtc(); } decimal inventoryRatio = ComputeInventoryRatio(bitsharesBalances, bitcoinBalance); if (m_prices == null) { // // initialise the price discovery engine // m_prices = new PriceDiscovery(market.spread_percent, market.window_percent, m_lastFeedPrice, inventoryRatio); } decimal oldBid = m_market.bid; decimal oldAsk = m_market.ask; m_prices.UpdateParameters(m_lastFeedPrice, inventoryRatio, m_market.spread_percent, m_market.window_percent, out m_market.bid, out m_market.ask); m_isDirty |= oldBid != m_market.bid || oldAsk != m_market.ask; } }
/// <summary> Calculates the market prices and limits./ </summary> /// /// <remarks> Paul, 19/02/2015. </remarks> /// /// <param name="market"> [in,out] The market. </param> /// <param name="bitsharesBalances"> The bitshares balances. </param> /// <param name="bitcoinBalances"> The bitcoin balances. </param> /// /// <returns> Whether the prices were updated </returns> public virtual void ComputeMarketPricesAndLimits(ref MarketRow market, Dictionary <int, ulong> bitsharesBalances, decimal bitcoinBalances) { m_market = market; }
/// <summary> Sets prices from single unit quantities. </summary> /// /// <remarks> Paul, 14/02/2015. </remarks> /// /// <exception cref="Exception"> Thrown when an exception error condition occurs. </exception> /// /// <param name="baseQuantity"> The base quantity. </param> /// <param name="quoteQuantity"> The quote quantity. </param> virtual public void SetPricesFromSingleUnitQuantities(decimal baseQuantity, decimal quoteQuantity, bool flipped, MarketRow market) { decimal bid, ask; decimal buyFee = baseQuantity * market.bid_fee_percent / 100; decimal sellFee = quoteQuantity * market.ask_fee_percent / 100; baseQuantity -= buyFee; quoteQuantity += sellFee; if (flipped) { bid = baseQuantity; ask = quoteQuantity; } else { bid = 1 / baseQuantity; ask = 1 / quoteQuantity; } if (Math.Abs(bid - m_market.bid) > m_market.bid / 10 || Math.Abs(ask - m_market.ask) > m_market.ask / 10) { throw new Exception("New prices are too different!"); } int updated = m_daemon.UpdateMarketPrices(m_market.symbol_pair, bid, ask); if (updated == 0) { throw new Exception("No market row updated!"); } else { m_market.ask = ask; m_market.bid = bid; } m_isDirty = true; }
/// <summary> Sets prices from single unit quantities. </summary> /// /// <remarks> Paul, 25/02/2015. </remarks> /// /// <param name="baseQuantity"> The base quantity. </param> /// <param name="quoteQuantity"> The quote quantity. </param> /// <param name="flipped"> true if flipped. </param> /// <param name="market"> The market. </param> public override void SetPricesFromSingleUnitQuantities(decimal baseQuantity, decimal quoteQuantity, bool flipped, MarketRow market) { base.SetPricesFromSingleUnitQuantities(baseQuantity, quoteQuantity, flipped, market); // disable further price discovery m_market.price_discovery = false; // disable in database too m_daemon.EnablePriceDiscovery(m_market.symbol_pair, false); }
/// <summary> Handles the price setting. </summary> /// /// <remarks> Paul, 14/02/2015. </remarks> /// /// <param name="l"> The BitsharesLedgerEntry to process. </param> /// <param name="handler"> The handler. </param> /// <param name="market"> The market. </param> void HandlePriceSetting(string[] parts, BitsharesLedgerEntry l, MarketBase handler, MarketRow market) { // parse if (parts[0] == kSetPricesMemoStart) { if (parts[1] == market.symbol_pair) { // setting is for this market! decimal basePrice = decimal.Parse(parts[2]); decimal quotePrice = decimal.Parse(parts[3]); // go do it! handler.SetPricesFromSingleUnitQuantities(basePrice, quotePrice, market.flipped, market); } } }
// Use this for initialization protected override void OnStart() { Markets.Add(this); left = new MarketRow(this, transform.GetChild(1).position); right = new MarketRow(this, transform.GetChild(2).position); }
/// <summary> Updates the market in database described by market. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="market"> The market. </param> protected void UpdateMarketInDatabase(MarketRow market) { bool updated = m_dataAccess.UpdateMarketInDatabase(market); Debug.Assert(updated); }
private IEnumerator CrateInterferenceCountdown(MarketRow row) { yield return(new WaitForSeconds(SnapInterferenceTimerSeconds)); this.CrateInterferenceTimers.Remove(row); }
/// <summary> Updates the market in database described by market. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="market"> The market. </param> public bool UpdateMarketInDatabase(MarketRow market) { return(m_database.Statement("UPDATE markets SET ask=@a, bid=@b, ask_max=@c, bid_max=@d, ask_fee_percent=@e, bid_fee_percent=@f WHERE symbol_pair=@g;", market.ask, market.bid, market.ask_max, market.bid_max, market.ask_fee_percent, market.bid_fee_percent, market.symbol_pair) > 0); }