Skip to content

Commit

Permalink
Merge branch 'v020'
Browse files Browse the repository at this point in the history
  • Loading branch information
walkjivefly committed Oct 27, 2017
2 parents 1de8812 + 1562e26 commit 8534ae4
Show file tree
Hide file tree
Showing 15 changed files with 21,265 additions and 46 deletions.
Binary file modified LOC.oxt
Binary file not shown.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
LibreOffice Calc crypto price lookup extension
LOC-Extension: LibreOffice calc Cryptocurrency market functions
===
The LOC extension allows you to create customized spreadsheets with crypto currency market data directly from the web. The initial version supports only one source - [Poloniex](https://poloniex.com) - but others are planned.
The LOC extension allows you to create customized spreadsheets with cryptocurrency market data directly from the web. This version provides 2 lookup functions: a dedicated getPoloniex() (for compatibility with version 0.1.0) and a generic ccxt() which uses an embedded snapshot of the amazing ccxt library. This means over 90 exchanges are now supported.

### Download
You can download the current version of the LOC Extension here [0.1.0](https://github.com/walkjivefly/LOC-Extension/releases/tag/v0.1.0)
You can download the current version of the LOC Extension here [0.2.0](https://github.com/walkjivefly/LOC-Extension/releases/tag/v0.2.0)

The LOC extension is also available at the [LibreOffice Extension Center](https://extensions.libreoffice.org/extensions/loc-extension-for-libreoffice-calc).
The LOC extension is also available from the [LibreOffice Extension Center](https://extensions.libreoffice.org/extensions/loc-extension-for-libreoffice-calc).

**NOTE**: The extension itself is LOC.oxt. The example .ods worksheet demonstrates how to use the extension.

### Usage

The LOC Extension adds a new function to Calc:
The LOC Extension adds two new functions to Calc. The first is:
```
GETPOLONIEX(Ticker,Datacode)
```
Expand All @@ -22,9 +22,25 @@ In the latter case the data in A1 should be ```BTC_ETH```, not ```"BTC_ETH"```.

**NOTE**: The full set of datacodes are demonstrated in the example .ods worksheet included with the release. The worksheet also contains a full list of the available symbols/currency-pairs.

The second new function is:
```
CCXT(Exchange, Ticker, Datacode)
```

Exchange is any exchange name supported by the embedded ccxt snapshot (version 1.9.262). Quotes **must** be used according to the same rules as for GETPOLONIEX().

Ticker is a currency pair from the ccxt unified API.
**NOTE**: The format of the ticker is different from that for GETPOLONIEX(). The valid values depend on the exchange being addressed.

Datacode is one of the ccxt supported data items for the fetch_ticker function. The one you'll probably use most is "last"

### Upgrading

The LibreOffice extension mechanism is poorly documented and extremely fragile. It is recommended that you remove the previous version of LOC-Extension before adding this one. If you use the replace option you might or might not end up with indecipherable error messages or an unusable extension. If you really screw things up I recommend closing LibreOffice, renaming the entire customisation directory (~/.config/libreoffice/4 on linux), restarting LibreOffice and re-installing (all) your extensions.

### Dependencies

Version 0.1.0 is fully standalone. The 3rd-party Poloniex API wrapper requirement has been removed.
Version 0.2.0 is fully standalone. It includes an embedded snapshot of Igor Kroitor's ccxt.

### Support

Expand All @@ -45,8 +61,11 @@ The LOC Extension is released under the [![][shield:LGPL3]][License:3.0] which i
* You must track changes you make in the source files.
* You must include or make available the source code with your release.

ccxt is released under the MIT license.

### Other Contributors and Thanks!
* madsailor - provided the original SMF Extension that LOC is based on
* Igor Kroitor - actively maintains the ccxt library

[GIT:release]: http://github.com/walkjivefly/LOC-Extension/releases/latest
[License:3.0]: http://www.gnu.org/licenses/lgpl.html
Expand Down
16 changes: 1 addition & 15 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
Some ideas for improvements/things todo:

1. Cache results to improve performance and reduce the likelihood of
hitting the Poloniex 6 calls per second limit. A call to returnTicker
gets the prices for everything on the exchange so only 1 API call
should be needed to get the prices for anything on the sheet. But
where to cache the results? What is the lifetime of the python
session which services the request?

2. Switch to using ccxt (https://github.com/kroitor/ccxt.git). This much
more comprehensive wrapper talks to 77+ exchanges.

3.




1. Further investigate caching
10 changes: 7 additions & 3 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ mkdir "${PWD}"/LOC/
mkdir "${PWD}"/LOC/META-INF/

#Compile the binaries
idlc -I /opt/libreoffice5.3/sdk/idl "${PWD}"/idl/XLoc.idl
regmerge -v "${PWD}"/LOC/XLoc.rdb UCR "${PWD}"/idl/XLoc.urd
rm "${PWD}"/idl/XLoc.urd
idlc -I /opt/libreoffice5.3/sdk/idl "${PWD}"/idl/LOC.idl
regmerge -v "${PWD}"/LOC/LOC.rdb UCR "${PWD}"/idl/LOC.urd
rm "${PWD}"/idl/LOC.urd

#Copy extension files and generate metadata
cp -f "${PWD}"/src/loc.py "${PWD}"/LOC/
cp -f "${PWD}"/src/errors.py "${PWD}"/LOC/
cp -f "${PWD}"/src/exchange.py "${PWD}"/LOC/
cp -f "${PWD}"/src/exchanges.py "${PWD}"/LOC/
cp -f "${PWD}"/src/version.py "${PWD}"/LOC/
cp -f "${PWD}"/src/description-en-US.txt "${PWD}"/LOC/
python "${PWD}"/src/generate_metainfo.py

Expand Down
Binary file added examples/Examples.ods
Binary file not shown.
Binary file removed examples/PoloniexExample.ods
Binary file not shown.
4 changes: 3 additions & 1 deletion idl/XLoc.idl → idl/LOC.idl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

module com { module loc { module crypto { module getinfo {

interface XLoc
interface LOC
{
// Modeled as an 'any' to allow it to be NULL/None/Missing.
any getPoloniex( [in] string a, [in] any b );
// Expecting parms to be exchange and function.
any ccxt( [in] string a, [in] any b, [in] any c );
};

}; }; }; };
2 changes: 1 addition & 1 deletion src/description-en-US.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The LOC Extension enables you to create spreadsheets with crypto currency market data pulled directly from the web. This version supports only one datasource: Poloniex, but others are planned.
The LOC Extension enables you to create spreadsheets with crypto currency market data pulled directly from the web. This version directly supports Poloniex and additionally, all of the datasources supported by ccxt version 1.9.262
103 changes: 103 additions & 0 deletions src/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-

"""
MIT License
Copyright (c) 2017 Igor Kroitor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

# -----------------------------------------------------------------------------

__all__ = [
'BaseError',
'ExchangeError',
'AuthenticationError',
'InsufficientFunds',
'InvalidOrder',
'NetworkError',
'DDoSProtection',
'RequestTimeout',
'ExchangeNotAvailable',
]

# -----------------------------------------------------------------------------


class BaseError(Exception):
"""Base class for all exceptions"""
pass


class ExchangeError(BaseError):
""""Raised when an exchange server replies with an error in JSON"""
pass


class NotSupported(ExchangeError):
"""Raised if the endpoint is not offered/not yet supported by the exchange API"""
pass


class AuthenticationError(ExchangeError):
"""Raised when API credentials are required but missing or wrong"""
pass


class InsufficientFunds(ExchangeError):
"""Raised when you don't have enough currency on your account balance to place an order"""
pass


class InvalidOrder(ExchangeError):
""""Base class for all exceptions related to the unified order API"""
pass


class OrderNotFound(InvalidOrder):
"""Raised when you are trying to fetch or cancel a non-existent order"""
pass


class OrderNotCached(InvalidOrder):
"""Raised when the order is not found in local cache (where applicable)"""
pass


class NetworkError(BaseError):
"""Base class for all errors related to networking"""
pass


class DDoSProtection(NetworkError):
"""Raised whenever DDoS protection restrictions are enforced per user or region/location"""
pass


class RequestTimeout(NetworkError):
"""Raised when the exchange fails to reply in .timeout time"""
pass


class ExchangeNotAvailable(NetworkError):
"""Raised if a reply from an exchange contains keywords related to maintenance or downtime"""
pass

# =============================================================================
Loading

0 comments on commit 8534ae4

Please sign in to comment.